Package org.apache.shiro.authc.pam
Class AbstractAuthenticationStrategy
- java.lang.Object
-
- org.apache.shiro.authc.pam.AbstractAuthenticationStrategy
-
- All Implemented Interfaces:
AuthenticationStrategy
- Direct Known Subclasses:
AllSuccessfulStrategy,AtLeastOneSuccessfulStrategy,FirstSuccessfulStrategy
public abstract class AbstractAuthenticationStrategy extends Object implements AuthenticationStrategy
Abstract base implementation for Shiro's concreteAuthenticationStrategyimplementations.- Since:
- 0.9
-
-
Constructor Summary
Constructors Constructor Description AbstractAuthenticationStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AuthenticationInfoafterAllAttempts(AuthenticationToken token, AuthenticationInfo aggregate)Simply returns theaggregateargument without modification.AuthenticationInfoafterAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo singleRealmInfo, AuthenticationInfo aggregateInfo, Throwable t)Base implementation that will aggregate the specifiedsingleRealmInfointo theaggregateInfoand then returns the aggregate.AuthenticationInfobeforeAllAttempts(Collection<? extends Realm> realms, AuthenticationToken token)Simply returnsnew, which supports aggregating account data across realms.SimpleAuthenticationInfo();AuthenticationInfobeforeAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo aggregate)Simply returns theaggregatemethod argument, without modification.protected AuthenticationInfomerge(AuthenticationInfo info, AuthenticationInfo aggregate)Merges the specifiedinfoargument into theaggregateargument and then returns an aggregate for continued use throughout the login process.
-
-
-
Method Detail
-
beforeAllAttempts
public AuthenticationInfo beforeAllAttempts(Collection<? extends Realm> realms, AuthenticationToken token) throws AuthenticationException
Simply returnsnew, which supports aggregating account data across realms.SimpleAuthenticationInfo();- Specified by:
beforeAllAttemptsin interfaceAuthenticationStrategy- Parameters:
realms- the Realms that will be consulted during the authentication process for the specified token.token- the Principal/Credential representation to be used during authentication for a corresponding subject.- Returns:
- an empty AuthenticationInfo object that will populated with data from multiple realms.
- Throws:
AuthenticationException- if the strategy implementation does not wish the Authentication attempt to execute.
-
beforeAttempt
public AuthenticationInfo beforeAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo aggregate) throws AuthenticationException
Simply returns theaggregatemethod argument, without modification.- Specified by:
beforeAttemptin interfaceAuthenticationStrategy- Parameters:
realm- the realm that will be consulted forAuthenticationInfofor the specifiedtoken.token- theAuthenticationTokensubmitted for the subject attempting system log-in.aggregate- the aggregated AuthenticationInfo object being used across the multi-realm authentication attempt- Returns:
- the AuthenticationInfo object that will be presented to further realms in the authentication process - returning
the
aggregatemethod argument is the normal case if no special action needs to be taken. - Throws:
AuthenticationException- an exception thrown by the Strategy implementation if it wishes the login process for the associated subject (user) to stop immediately.
-
afterAttempt
public AuthenticationInfo afterAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo singleRealmInfo, AuthenticationInfo aggregateInfo, Throwable t) throws AuthenticationException
Base implementation that will aggregate the specifiedsingleRealmInfointo theaggregateInfoand then returns the aggregate. Can be overridden by subclasses for custom behavior.- Specified by:
afterAttemptin interfaceAuthenticationStrategy- Parameters:
realm- the realm that was just consulted forAuthenticationInfofor the giventoken.token- theAuthenticationTokensubmitted for the subject attempting system log-in.singleRealmInfo- the info returned from a single realm.aggregateInfo- the aggregate info representing all realms in a multi-realm environment.t- the Throwable thrown by the Realm during the attempt, ornullif the method returned normally.- Returns:
- the AuthenticationInfo object that will be presented to further realms in the authentication process - returning
the
aggregateAccountmethod argument is the normal case if no special action needs to be taken. - Throws:
AuthenticationException- an exception thrown by the Strategy implementation if it wishes the login process for the associated subject (user) to stop immediately.
-
merge
protected AuthenticationInfo merge(AuthenticationInfo info, AuthenticationInfo aggregate)
Merges the specifiedinfoargument into theaggregateargument and then returns an aggregate for continued use throughout the login process. This implementation merely checks to see if the specifiedaggregateargument is an instance ofMergableAuthenticationInfo, and if so, callsaggregate.merge(info)If it is not an instance ofMergableAuthenticationInfo, anIllegalArgumentExceptionis thrown. Can be overridden by subclasses for custom merging behavior if implementing theMergableAuthenticationInfois not desired for some reason.
-
afterAllAttempts
public AuthenticationInfo afterAllAttempts(AuthenticationToken token, AuthenticationInfo aggregate) throws AuthenticationException
Simply returns theaggregateargument without modification. Can be overridden for custom behavior.- Specified by:
afterAllAttemptsin interfaceAuthenticationStrategy- Parameters:
token- theAuthenticationTokensubmitted for the subject attempting system log-in.aggregate- the aggregateAuthenticationInfoinstance populated by all realms during the log-in attempt.- Returns:
- the final
AuthenticationInfoobject to return to the Authenticator.authenticate() caller. - Throws:
AuthenticationException- if the Strategy implementation wishes to fail the authentication attempt.
-
-