protected Pair < Boolean , Set < Throwable > > evaluateAuthenticationPolicies ( final Authentication authentication , final AuthenticationTransaction transaction , final Set < AuthenticationHandler > authenticationHandlers ) { val failures = new LinkedHashSet < Throwable > ( ) ; val policies = authenticationEventExecutionPlan . getAuthenticationPolicies ( transaction ) ; policies . forEach ( p -> { try { val simpleName = p . getClass ( ) . getSimpleName ( ) ; LOGGER . debug ( "Executing authentication policy [{}]" , simpleName ) ; val supportingHandlers = authenticationHandlers . stream ( ) . filter ( handler -> transaction . getCredentials ( ) . stream ( ) . anyMatch ( handler :: supports ) ) . collect ( Collectors . toCollection ( LinkedHashSet :: new ) ) ; if ( ! p . isSatisfiedBy ( authentication , supportingHandlers ) ) { failures . add ( new AuthenticationException ( "Unable to satisfy authentication policy " + simpleName ) ) ; } } catch ( final GeneralSecurityException e ) { LOGGER . debug ( e . getMessage ( ) , e ) ; failures . add ( e . getCause ( ) ) ; } catch ( final Exception e ) { LOGGER . debug ( e . getMessage ( ) , e ) ; failures . add ( e ) ; } } ) ; return Pair . of ( failures . isEmpty ( ) , failures ) ; }
Evaluate authentication policies .