Example usage for org.apache.shiro.authc SimpleAccount getObjectPermissions

List of usage examples for org.apache.shiro.authc SimpleAccount getObjectPermissions

Introduction

In this page you can find the example usage for org.apache.shiro.authc SimpleAccount getObjectPermissions.

Prototype

public Collection<Permission> getObjectPermissions() 

Source Link

Document

Returns all object-based permissions assigned directly to this Account (not any of its realms).

Usage

From source file:org.icgc.dcc.submission.shiro.DccWrappingRealm.java

License:Open Source License

/**
 * TODO: <code>{@link DccRealm#getPermissions(String)}</code>
 *//*from  w  ww . j a  va2s.c om*/
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
    log.debug("Putting together authorizations for user {}", principals.getPrimaryPrincipal());
    String username = super.getUsername(principals);
    SimpleAccount simpleAccount = super.getUser(username); // this gives access to implementation of
                                                           // AuthorizationInfo...

    Collection<String> iniRoles = simpleAccount.getRoles();
    Set<String> projectSpecificPermissions = buildProjectSpecificPermissions(username, iniRoles);
    log.debug(
            "Dynamically adding Project-specific permissions for user {}: {}, top of existing roles from INI: {} ({})",
            new Object[] { username, projectSpecificPermissions, iniRoles,
                    simpleAccount.getObjectPermissions() });
    simpleAccount.addStringPermissions(projectSpecificPermissions);

    return simpleAccount;
}