Search in sources :

Example 1 with HostAuthenticationToken

use of org.apache.shiro.authc.HostAuthenticationToken in project shiro by apache.

the class DelegatingSubject method login.

public void login(AuthenticationToken token) throws AuthenticationException {
    clearRunAsIdentitiesInternal();
    Subject subject = securityManager.login(this, token);
    PrincipalCollection principals;
    String host = null;
    if (subject instanceof DelegatingSubject) {
        DelegatingSubject delegating = (DelegatingSubject) subject;
        // we have to do this in case there are assumed identities - we don't want to lose the 'real' principals:
        principals = delegating.principals;
        host = delegating.host;
    } else {
        principals = subject.getPrincipals();
    }
    if (principals == null || principals.isEmpty()) {
        String msg = "Principals returned from securityManager.login( token ) returned a null or " + "empty value.  This value must be non null and populated with one or more elements.";
        throw new IllegalStateException(msg);
    }
    this.principals = principals;
    this.authenticated = true;
    if (token instanceof HostAuthenticationToken) {
        host = ((HostAuthenticationToken) token).getHost();
    }
    if (host != null) {
        this.host = host;
    }
    Session session = subject.getSession(false);
    if (session != null) {
        this.session = decorate(session);
    } else {
        this.session = null;
    }
}
Also used : HostAuthenticationToken(org.apache.shiro.authc.HostAuthenticationToken) PrincipalCollection(org.apache.shiro.subject.PrincipalCollection) Subject(org.apache.shiro.subject.Subject) ProxiedSession(org.apache.shiro.session.ProxiedSession) Session(org.apache.shiro.session.Session)

Aggregations

HostAuthenticationToken (org.apache.shiro.authc.HostAuthenticationToken)1 ProxiedSession (org.apache.shiro.session.ProxiedSession)1 Session (org.apache.shiro.session.Session)1 PrincipalCollection (org.apache.shiro.subject.PrincipalCollection)1 Subject (org.apache.shiro.subject.Subject)1