use of org.apache.shiro.authz.SimpleRole in project shiro by apache.
the class TextConfigurationRealm method processRoleDefinitions.
protected void processRoleDefinitions(Map<String, String> roleDefs) {
if (roleDefs == null || roleDefs.isEmpty()) {
return;
}
for (String rolename : roleDefs.keySet()) {
String value = roleDefs.get(rolename);
SimpleRole role = getRole(rolename);
if (role == null) {
role = new SimpleRole(rolename);
add(role);
}
Set<Permission> permissions = PermissionUtils.resolveDelimitedPermissions(value, getPermissionResolver());
role.setPermissions(permissions);
}
}
use of org.apache.shiro.authz.SimpleRole in project neo4j by neo4j.
the class PredefinedRolesBuilder method staticBuildRoles.
private static Map<String, SimpleRole> staticBuildRoles() {
Map<String, SimpleRole> roles = new ConcurrentHashMap<>(4);
SimpleRole admin = new SimpleRole(ADMIN);
admin.add(FULL);
roles.put(ADMIN, admin);
SimpleRole architect = new SimpleRole(ARCHITECT);
architect.add(SCHEMA);
architect.add(WRITE);
architect.add(TOKEN);
roles.put(ARCHITECT, architect);
SimpleRole publisher = new SimpleRole(PUBLISHER);
publisher.add(WRITE);
roles.put(PUBLISHER, publisher);
SimpleRole reader = new SimpleRole(READER);
reader.add(READ);
roles.put(READER, reader);
return roles;
}
use of org.apache.shiro.authz.SimpleRole in project shiro by apache.
the class TextConfigurationRealm method processUserDefinitions.
protected void processUserDefinitions(Map<String, String> userDefs) {
if (userDefs == null || userDefs.isEmpty()) {
return;
}
for (String username : userDefs.keySet()) {
String value = userDefs.get(username);
String[] passwordAndRolesArray = StringUtils.split(value);
String password = passwordAndRolesArray[0];
SimpleAccount account = getUser(username);
if (account == null) {
account = new SimpleAccount(username, password, getName());
add(account);
}
account.setCredentials(password);
if (passwordAndRolesArray.length > 1) {
for (int i = 1; i < passwordAndRolesArray.length; i++) {
String rolename = passwordAndRolesArray[i];
account.addRole(rolename);
SimpleRole role = getRole(rolename);
if (role != null) {
account.addObjectPermissions(role.getPermissions());
}
}
} else {
account.setRoles(null);
}
}
}
Aggregations