Example usage for org.apache.shiro.util PermissionUtils resolveDelimitedPermissions

List of usage examples for org.apache.shiro.util PermissionUtils resolveDelimitedPermissions

Introduction

In this page you can find the example usage for org.apache.shiro.util PermissionUtils resolveDelimitedPermissions.

Prototype

public static Set<Permission> resolveDelimitedPermissions(String s, PermissionResolver permissionResolver) 

Source Link

Usage

From source file:com.caricah.iotracah.bootstrap.security.realm.impl.IOTTextConfiguredRealm.java

License:Apache License

protected void processRoleDefinitions(Map<String, String> roleDefs) {
    if (roleDefs == null || roleDefs.isEmpty()) {
        return;//from   w  w  w  .java  2  s  .  c om
    }
    for (String rolename : roleDefs.keySet()) {

        String value = roleDefs.get(rolename);

        //Parse the rolename for partition.
        String partition;

        Matcher matcher = rolePartitionPattern.matcher(rolename);
        if (matcher.matches()) {
            partition = matcher.group("partition");
            rolename = matcher.group("rolename");
        } else {
            partition = getDefaultPartitionName();
        }

        IOTRole role = getIOTRole(partition, rolename);
        if (role == null) {
            role = addIOTRole(partition, rolename);

        }

        Set<Permission> permissions = PermissionUtils.resolveDelimitedPermissions(value,
                getPermissionResolver());

        for (Permission permission : permissions) {
            role.add((IOTPermission) permission);
        }

        saveIOTRole(role);
    }
}