@Override public void setAuthenticatedAccount(Account account){ if ( getCurrentSession() != null ) { getCurrentSession().setAuthenticatedAccount(account); notifySecurityEvent( PROFILE_UPDATED ); } }
private Account performAuthentication() { final Iterator<AuthenticationMechanism> iterator = rule.mechanisms().iterator(); Account account = getCurrentSession().getAuthenticatedAccount(); while ( account == null && iterator.hasNext() ) { currentAuthMechanism = iterator.next(); account = currentAuthMechanism.authenticate( exchange, rule.identityManagers(), getCurrentSession() ); } return account; }
void notifySecurityEvent(SecurityEventListener.SecurityEventType eventType) { for ( SecurityEventListener eventListener : configuration.getEventListeners() ) { eventListener.onEvent( eventType, exchange, getCurrentSession() ); } } }
@Override public boolean authenticate() { authenticated = true; final Account account = performAuthentication(); if ( account == null ){ authenticated = false; getCurrentSession().setAuthenticatedAccount( account ); configuration.getAuthenticationFailureListener().onAuthenticationFailure( exchange, getCurrentSession(), currentAuthMechanism ); } else { getCurrentSession().setAuthenticatedAccount( account ); configuration.getAuthenticationSuccessListener().onAuthenticationSuccess(exchange, getCurrentSession(), currentAuthMechanism); notifySecurityEvent( LOGIN ); } updateCurrentSession(); return authenticated; }
@Override public void logout() { final Session currentSession = getCurrentSession(); if ( currentSession != null ) { configuration.getSessionStore().invalidateSession( currentSession ); configuration.getSessionIdManager().expiresSessionId( exchange ); notifySecurityEvent( LOGOUT ); } }