BeanRole.java
1.46 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
60
61
package fi.insomnia.bortal.enums;
import java.util.HashSet;
import java.util.Set;
public enum BeanRole {
// If modified update to sun-web.xml
// Bean level access
ANONYMOUS, // Unauthenticated web user
USER_BASE, // JAAS access for logged in user
ADMIN_BASE(USER_BASE), // JAAS access to administrative beans
// Admin for the whole system (JAAS, boolean in User)
SUPERADMIN(false, ADMIN_BASE),
ORGANIZATION_ROOT(ADMIN_BASE), // E.g. Vectorama organisation admin
;
private boolean inDatabase;
private Set<BeanRole> parents = new HashSet<BeanRole>();
BeanRole() {
}
/**
* Default (on-demand create time) parents for the role
*
* @param parent
*/
BeanRole(BeanRole... parent) {
for (BeanRole role : parent) {
parents.add(role);
}
}
/**
* Is the role stored in the database (default true) or is it a magic role
* like superadmin (stored as boolean in User).
*
* @param inDb
* stored in roles-table
* @param parent
* default (create time) parent roles
*/
BeanRole(boolean inDb, BeanRole... parent) {
this(parent);
this.inDatabase = inDb;
}
public boolean isInDatabase() {
return inDatabase;
}
/**
* Default parent roles (when creating role on first use)
*
* @return
*/
public Set<BeanRole> getParents() {
return parents;
}
}