Search in sources :

Example 16 with Realm

use of org.apache.shiro.realm.Realm in project ddf by codice.

the class SecurityManagerImpl method createPrincipalFromToken.

/**
     * Creates a new principal object from an incoming security token.
     *
     * @param token SecurityToken that contains the principals.
     * @return new SimplePrincipalCollection
     */
private SimplePrincipalCollection createPrincipalFromToken(SecurityToken token) {
    SimplePrincipalCollection principals = new SimplePrincipalCollection();
    for (Realm curRealm : realms) {
        LOGGER.debug("Configuring settings for realm name: {} type: {}", curRealm.getName(), curRealm.getClass().toString());
        LOGGER.debug("Is authorizer: {}, is AuthorizingRealm: {}", curRealm instanceof Authorizer, curRealm instanceof AuthorizingRealm);
        SecurityAssertion securityAssertion = null;
        try {
            securityAssertion = new SecurityAssertionImpl(token, usernameAttributeList);
            Principal principal = securityAssertion.getPrincipal();
            if (principal != null) {
                principals.add(principal.getName(), curRealm.getName());
            }
        } catch (Exception e) {
            LOGGER.warn("Encountered error while trying to get the Principal for the SecurityToken. Security functions may not work properly.", e);
        }
        if (securityAssertion != null) {
            principals.add(securityAssertion, curRealm.getName());
        }
    }
    return principals;
}
Also used : Authorizer(org.apache.shiro.authz.Authorizer) SimplePrincipalCollection(org.apache.shiro.subject.SimplePrincipalCollection) SecurityAssertion(ddf.security.assertion.SecurityAssertion) Realm(org.apache.shiro.realm.Realm) AuthorizingRealm(org.apache.shiro.realm.AuthorizingRealm) AuthorizingRealm(org.apache.shiro.realm.AuthorizingRealm) Principal(java.security.Principal) SecurityServiceException(ddf.security.service.SecurityServiceException) SecurityAssertionImpl(ddf.security.assertion.impl.SecurityAssertionImpl)

Aggregations

Realm (org.apache.shiro.realm.Realm)16 SimplePrincipalCollection (org.apache.shiro.subject.SimplePrincipalCollection)6 DefaultSecurityManager (org.apache.shiro.mgt.DefaultSecurityManager)5 IniRealm (org.apache.shiro.realm.text.IniRealm)4 Principal (java.security.Principal)3 ArrayList (java.util.ArrayList)3 AuthenticationInfo (org.apache.shiro.authc.AuthenticationInfo)3 AuthorizingRealm (org.apache.shiro.realm.AuthorizingRealm)3 LdapRealm (org.apache.zeppelin.realm.LdapRealm)3 Subject (ddf.security.Subject)2 HashSet (java.util.HashSet)2 SecurityToken (org.apache.cxf.ws.security.tokenstore.SecurityToken)2 AuthenticationToken (org.apache.shiro.authc.AuthenticationToken)2 Permission (org.apache.shiro.authz.Permission)2 PrincipalCollection (org.apache.shiro.subject.PrincipalCollection)2 DefaultWebSecurityManager (org.apache.shiro.web.mgt.DefaultWebSecurityManager)2 Before (org.junit.Before)2 Test (org.junit.Test)2 JobScheduler (org.neo4j.kernel.impl.util.JobScheduler)2 BasicPasswordPolicy (org.neo4j.server.security.auth.BasicPasswordPolicy)2