Search in sources :

Example 1 with Authenticator

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

the class DefaultSecurityManager method logout.

public void logout(Subject subject) {
    if (subject == null) {
        throw new IllegalArgumentException("Subject method argument cannot be null.");
    }
    beforeLogout(subject);
    PrincipalCollection principals = subject.getPrincipals();
    if (principals != null && !principals.isEmpty()) {
        if (log.isDebugEnabled()) {
            log.debug("Logging out subject with primary principal {}", principals.getPrimaryPrincipal());
        }
        Authenticator authc = getAuthenticator();
        if (authc instanceof LogoutAware) {
            ((LogoutAware) authc).onLogout(principals);
        }
    }
    try {
        delete(subject);
    } catch (Exception e) {
        if (log.isDebugEnabled()) {
            String msg = "Unable to cleanly unbind Subject.  Ignoring (logging out).";
            log.debug(msg, e);
        }
    } finally {
        try {
            stopSession(subject);
        } catch (Exception e) {
            if (log.isDebugEnabled()) {
                String msg = "Unable to cleanly stop Session for Subject [" + subject.getPrincipal() + "] " + "Ignoring (logging out).";
                log.debug(msg, e);
            }
        }
    }
}
Also used : PrincipalCollection(org.apache.shiro.subject.PrincipalCollection) LogoutAware(org.apache.shiro.authc.LogoutAware) Authenticator(org.apache.shiro.authc.Authenticator) InvalidSessionException(org.apache.shiro.session.InvalidSessionException) AuthenticationException(org.apache.shiro.authc.AuthenticationException)

Aggregations

AuthenticationException (org.apache.shiro.authc.AuthenticationException)1 Authenticator (org.apache.shiro.authc.Authenticator)1 LogoutAware (org.apache.shiro.authc.LogoutAware)1 InvalidSessionException (org.apache.shiro.session.InvalidSessionException)1 PrincipalCollection (org.apache.shiro.subject.PrincipalCollection)1