SessionHandler.java
1.28 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.insomnia.bortal.handler;
import javax.ejb.EJB;
import javax.enterprise.context.SessionScoped;
import javax.faces.bean.ManagedBean;
import fi.insomnia.bortal.RolePermission;
import fi.insomnia.bortal.SessionHandlerBeanLocal;
import fi.insomnia.bortal.model.User;
/**
*
* @author tuukka
*/
@ManagedBean(name = "SessionHandler")
@SessionScoped
public class SessionHandler {
@EJB
private SessionHandlerBeanLocal handlerbean;
private User user;
/** Creates a new instance of SessionHandler */
public SessionHandler() {
}
public boolean hasPermission(String target, String permission) {
RolePermission perm = RolePermission.READ;
if (permission.equals("write")) {
perm = RolePermission.WRITE;
} else if (permission.equals("execute")) {
perm = RolePermission.EXECUTE;
}
return hasPermission(target, perm);
}
public boolean hasPermission(String target, RolePermission permission) {
return handlerbean.hasPermission(target, getUser(), permission);
}
public void setUser(User user) {
this.user = user;
}
public User getUser() {
return user;
}
}