SecurityController.java
1.2 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
package fi.insomnia.intra.web;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SecurityController {
private Set<String> revokeList = Collections.synchronizedSet(new HashSet<String>());
private static final Logger logger = LoggerFactory.getLogger(SecurityController.class);
protected ExternalContext getContext()
{
return FacesContext.getCurrentInstance().getExternalContext();
}
public String getAuthType()
{
return getContext().getAuthType();
}
public String getUsername()
{
return getContext().getRemoteUser();
}
public boolean isUserInRole(String role)
{
if(revokeList.contains(role))
{
logger.debug("RevokeList contained role {}, returning false..");
return false;
}
return getContext().isUserInRole(role);
}
public void resetRevokeList()
{
revokeList.clear();
}
public void addRevokeList(String role)
{
revokeList.add(role);
}
public void removeRevokeList(String role)
{
revokeList.remove(role);
}
}