SessionContext.java
848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package net.ziemers.swxercise.lg.user.service;
import javax.enterprise.context.SessionScoped;
import net.ziemers.swxercise.lg.model.user.User;
/**
* Verwaltet den SessionContext des zurzeit angemeldeten Benutzers.
*/
@SessionScoped
public class SessionContext implements java.io.Serializable {
private static final long serialVersionUID = 8624253586553865146L;
private User user = null;
public User getUser() {
return user;
}
private void setUser(User user) {
this.user = user;
}
public boolean login(final User user) {
if (getUser() == null) {
setUser(user);
return true;
}
return false;
}
public boolean logout() {
if (getUser() != null) {
setUser(null);
return true;
}
return false;
}
}