FirstSuccessfulStrategy

{@link AuthenticationStrategy} implementation that only accepts the account data from the first successfully consulted Realm and ignores all subsequent realms. This is slightly different behavior than {@link AtLeastOneSuccessfulStrategy}, so please review both to see which one meets your needs better.

@see AtLeastOneSuccessfulStrategy AtLeastOneSuccessfulAuthenticationStrategy

Members

Functions

beforeAllAttempts
AuthenticationInfo beforeAllAttempts(Realm[] realms, AuthenticationToken token)

Returns {@code null} immediately, relying on this class's {@link #merge merge} implementation to return only the first {@code info} object it encounters, ignoring all subsequent ones.

merge
AuthenticationInfo merge(AuthenticationInfo info, AuthenticationInfo aggregate)

Returns the specified {@code aggregate} instance if is non null and valid (that is, has principals and they are not empty) immediately, or, if it is null or not valid, the {@code info} argument is returned instead. <p/> This logic ensures that the first valid info encountered is the one retained and all subsequent ones are ignored, since this strategy mandates that only the info from the first successfully authenticated realm be used.

Inherited Members

From AbstractAuthenticationStrategy

beforeAllAttempts
AuthenticationInfo beforeAllAttempts(Realm[] realms, AuthenticationToken token)

Simply returns <code>new {@link hunt.shiro.authc.SimpleAuthenticationInfo SimpleAuthenticationInfo}();</code>, which supports aggregating account data across realms.

beforeAttempt
AuthenticationInfo beforeAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo aggregate)

Simply returns the <code>aggregate</code> method argument, without modification.

afterAttempt
AuthenticationInfo afterAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo singleRealmInfo, AuthenticationInfo aggregateInfo, Throwable t)

Base implementation that will aggregate the specified <code>singleRealmInfo</code> into the <code>aggregateInfo</code> and then returns the aggregate. Can be overridden by subclasses for custom behavior.

merge
AuthenticationInfo merge(AuthenticationInfo info, AuthenticationInfo aggregate)

Merges the specified <code>info</code> argument into the <code>aggregate</code> argument and then returns an aggregate for continued use throughout the login process. <p/> This implementation merely checks to see if the specified <code>aggregate</code> argument is an instance of {@link hunt.shiro.authc.MergableAuthenticationInfo MergableAuthenticationInfo}, and if so, calls <code>aggregate.merge(info)</code> If it is <em>not</em> an instance of <code>MergableAuthenticationInfo</code>, an {@link IllegalArgumentException IllegalArgumentException} is thrown. Can be overridden by subclasses for custom merging behavior if implementing the {@link hunt.shiro.authc.MergableAuthenticationInfo MergableAuthenticationInfo} is not desired for some reason.

afterAllAttempts
AuthenticationInfo afterAllAttempts(AuthenticationToken token, AuthenticationInfo aggregate)

Simply returns the <code>aggregate</code> argument without modification. Can be overridden for custom behavior.

Meta