Commit 3b58dba8 by Tuomas Riihimäki

Permission and RolePermission changes

1 parent 9ca7ef64
...@@ -13,49 +13,56 @@ import org.slf4j.LoggerFactory; ...@@ -13,49 +13,56 @@ import org.slf4j.LoggerFactory;
*/ */
public enum Permission { public enum Permission {
// NOTE. add conversion Value to RoleRight // NOTE. add conversion Value to RoleRight
// PERMISSION("Description"), // PERMISSION("Description"),
LOGIN("User can see loginbutton(r), create new user(w)"), LOGIN("User can see loginbutton(r), create new user(w), invite others (x)"),
USER_MANAGEMENT("User has right to view all users(r), modify users(w), execute actions for user(x) "), USER_MANAGEMENT("View all users(r), modify users(w), execute actions for user(x) "),
ACCOUNT_MANAGEMENT("Manage users account events. view(r), modify(w) and create(x)"), ACCOUNT_MANAGEMENT("Manage others account events. view(r), modify(w) and create (shop)(x)"),
BILL("View bills(r), Mark paid & modify(w), and create (buy) bills (x)"), BILL("View all bills(r), Mark paid & modify(w), and create own bills (x)"),
MAP("view maps(r), Modify(w), reserve places from maps(x)"), MAP("view maps(r), Modify(w), reserve places from maps(x)"),
ROLE_MANAGEMENT("User has right to view(r), modify(w) and assign(x) roles"), ROLE_MANAGEMENT("User has right to view(r), modify(w) and assign(x) roles"),
PRODUCT("View(r), modify(w), and shop(x) products"), PRODUCT("View(r), modify(w), and shop(x) products"),
SHOP("View shopped events(r), Modify AccountEvents() and Shop(x)"), SHOP("View own shopped events(r), Modify own AccountEvents() and Shop(x)"),
GAME("View(r) own, write(w) modify, view all(X)"), GAME("View(r) own, modify(w), view all(X)"),
POLL("View answers(r), create (w) and answer(x) to polls"); POLL("View answers(r), create polls (w), answer to polls(x)");
private String description; private String description;
private static final Logger logger = LoggerFactory.getLogger(Permission.class); private static final Logger logger = LoggerFactory.getLogger(Permission.class);
public static final String EXECUTE = "/EXECUTE";
public static Permission getPermission(String name) { public static final String READ = "/READ";
if (name == null || name.isEmpty()) { public static final String WRITE = "/WRITE";
logger.warn("Trying to get permission for empty name {}", name);
return null; public static Permission getPermission(String name) {
} if (name == null || name.isEmpty()) {
try { logger.warn("Trying to get permission for empty name {}", name);
return valueOf(name); return null;
} catch (IllegalArgumentException x) { }
throw x; try {
} return valueOf(name);
} } catch (IllegalArgumentException x) {
throw x;
Permission(String description) { }
this.description = description; }
}
Permission(String description) {
Permission() { this.description = description;
} }
public String getName() { Permission() {
return name(); }
}
public String getName() {
/** return name();
* @return the description }
*/
public String getDescription() { /**
return description; * @return the description
} */
public String getDescription() {
return description;
}
public String append(RolePermission permission) {
return name() + "/" + permission.name();
}
} }
package fi.insomnia.bortal.enums; package fi.insomnia.bortal.enums;
public enum RolePermission { public enum RolePermission {
READ, WRITE, EXECUTE READ, WRITE, EXECUTE
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!