19 package org.turro.security;
21 import java.util.List;
22 import java.util.TreeMap;
23 import java.util.TreeSet;
24 import org.turro.actor.Actors;
25 import org.turro.elephant.context.Application;
26 import org.turro.plugin.contacts.IContact;
27 import org.turro.reflection.Reflections;
36 String[] roles = role.split(
"\\s*\\|\\s*");
37 for(String r : roles) {
38 if(checkRole(r))
return true;
44 return roles.stream().anyMatch(role -> containsKey(role));
51 public void addPermissions(TreeMap<String, TreeSet<String>> rolePermissions) {
52 rolePermissions.entrySet().forEach(entry -> {
53 TreeSet<String>
set =
get(entry.getKey());
54 if(
set ==
null)
set =
new TreeSet<>();
55 set.addAll(entry.getValue());
56 put(entry.getKey(),
set);
65 private boolean checkRole(String role) {
66 String[] value = role.split(
"\\s*:\\s*");
67 if(value.length == 2) {
68 if(role.startsWith(
"class:")) {
69 return Reflections.exist(role.substring(6));
70 }
else if(
"@actor".equals(value[0])) {
72 }
else if(containsKey(value[0])) {
73 return get(value[0]).contains(value[1]);
static boolean isActor(String actor)
static IContact getUser()
boolean isInRole(String role)
boolean anyKeyMatch(List< String > roles)
boolean isActor(IContact contact, String actor)
void addPermissions(TreeMap< String, TreeSet< String >> rolePermissions)