Example usage for org.apache.shiro.subject SimplePrincipalCollection addAll

List of usage examples for org.apache.shiro.subject SimplePrincipalCollection addAll

Introduction

In this page you can find the example usage for org.apache.shiro.subject SimplePrincipalCollection addAll.

Prototype

public void addAll(Collection principals, String realmName) 

Source Link

Usage

From source file:org.fcrepo.auth.common.ServletContainerAuthenticatingRealm.java

License:Apache License

@Override
protected AuthenticationInfo doGetAuthenticationInfo(final AuthenticationToken token)
        throws AuthenticationException {
    final ContainerAuthToken authToken = (ContainerAuthToken) token;
    final SimplePrincipalCollection principals = new SimplePrincipalCollection();
    log.debug("Creating principals from servlet container principal and roles");
    // container-managed auth username
    principals.add(authToken.getPrincipal(), getName());
    // container-managed auth roles
    final Set<ContainerRolesPrincipal> roles = authToken.getRoles();
    if (!roles.isEmpty()) {
        principals.addAll(roles, getName());
    }/*from   ww  w.j  av  a2 s  .  co m*/
    return new SimpleAuthenticationInfo(principals, ContainerAuthToken.AUTHORIZED);
}