Class FirstSuccessfulStrategy

    • Method Detail

      • beforeAttempt

        public AuthenticationInfo beforeAttempt​(Realm realm,
                                                AuthenticationToken token,
                                                AuthenticationInfo aggregate)
                                         throws AuthenticationException
        Throws ShortCircuitIterationException if stopAfterFirstSuccess is set and authentication is successful with a previously consulted realm. Returns the aggregate method argument, without modification otherwise.
        Specified by:
        beforeAttempt in interface AuthenticationStrategy
        beforeAttempt in class AbstractAuthenticationStrategy
        realm - the realm that will be consulted for AuthenticationInfo for the specified token.
        token - the AuthenticationToken submitted for the subject attempting system log-in.
        aggregate - the aggregated AuthenticationInfo object being used across the multi-realm authentication attempt
        the AuthenticationInfo object that will be presented to further realms in the authentication process - returning the aggregate method argument is the normal case if no special action needs to be taken.
        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)
        Returns the specified 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 info argument is returned instead.

        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.

        merge in class AbstractAuthenticationStrategy