@Override public AuthenticationResultBuilder handleAuthenticationTransaction(final Service service, final AuthenticationResultBuilder authenticationResultBuilder, final Credential... credential) throws AuthenticationException { val transaction = DefaultAuthenticationTransaction.of(service, credential); this.authenticationTransactionManager.handle(transaction, authenticationResultBuilder); return authenticationResultBuilder; }
@Override public void configureAuthenticationServiceSelectionStrategy(final AuthenticationServiceSelectionPlan plan) { plan.registerStrategy(new DefaultAuthenticationServiceSelectionStrategy()); } }
/** * Method will set the bypass into the authentication. * * @param authentication - the authentication * @param provider - the provider */ default void updateAuthenticationToRememberBypass(final Authentication authentication, final MultifactorAuthenticationProvider provider) { authentication.addAttribute(AUTHENTICATION_ATTRIBUTE_BYPASS_MFA, Boolean.TRUE); authentication.addAttribute(AUTHENTICATION_ATTRIBUTE_BYPASS_MFA_PROVIDER, provider.getId()); }
/** * Creates a new builder initialized with data from the given authentication source. * * @param source Authentication source. * @return New builder instance initialized with all fields in the given authentication source. */ public static AuthenticationBuilder newInstance(final Authentication source) { val builder = new DefaultAuthenticationBuilder(source.getPrincipal()); builder.setAuthenticationDate(source.getAuthenticationDate()); builder.setCredentials(source.getCredentials()); builder.setSuccesses(source.getSuccesses()); builder.setFailures(source.getFailures()); builder.setAttributes(source.getAttributes()); return builder; }
@Override public Set<Event> resolveEventViaAuthenticationAttribute(final Authentication authentication, final Collection<String> attributeNames, final RegisteredService service, final Optional<RequestContext> context, final Collection<MultifactorAuthenticationProvider> providers, final Predicate<String> predicate) { return resolveEventViaAttribute(authentication.getPrincipal(), authentication.getAttributes(), attributeNames, service, context, providers, predicate); }
/** * Resolve service from authentication request. * * @param service the service * @return the service */ protected Service resolveServiceFromAuthenticationRequest(final Service service) { return this.authenticationRequestServiceSelectionStrategies.resolveService(service); }
@Override public AuthenticationResultBuilder establishAuthenticationContextFromInitial(final Authentication authentication, final Credential credentials) { return new DefaultAuthenticationResultBuilder().collect(authentication).collect(credentials); }
/** * Add authentication method attribute. * * @param builder the builder * @param authentication the authentication */ protected void addAuthenticationMethodAttribute(final AuthenticationBuilder builder, final Authentication authentication) { authentication.getSuccesses().values().forEach(result -> builder.addAttribute(AUTHENTICATION_METHOD_ATTRIBUTE, result.getHandlerName())); }
@Override public AuthenticationResult finalizeAllAuthenticationTransactions(final AuthenticationResultBuilder authenticationResultBuilder, final Service service) { return authenticationResultBuilder.build(principalElectionStrategy, service); }
/** * Creates a new instance from an authentication event that was successful prior to principal resolution. * * @param authentication Authentication event. */ public UnresolvedPrincipalException(final Authentication authentication) { super(UNRESOLVED_PRINCIPAL, authentication.getFailures(), authentication.getSuccesses()); }
public CasAuthenticationPolicyFailureEvent(final Object source, final Map<String, Throwable> failures, final AuthenticationTransaction transaction, final Authentication authentication) { super(source, failures, transaction.getCredentials()); this.authentication = authentication; } }
@Override public AuthenticationResult handleAndFinalizeSingleAuthenticationTransaction(final Service service, final Credential... credential) throws AuthenticationException { return finalizeAllAuthenticationTransactions(handleInitialAuthenticationTransaction(service, credential), service); } }
/** * Gets authentication metadata populators for transaction. * * @param transaction the transaction * @return the authentication metadata populators for transaction */ protected Collection<AuthenticationMetaDataPopulator> getAuthenticationMetadataPopulatorsForTransaction( final AuthenticationTransaction transaction) { return this.authenticationEventExecutionPlan.getAuthenticationMetadataPopulators(transaction); }
/** * Locate matching attribute value boolean. * * @param attrName the attr name * @param attrValue the attr value * @param attributes the attributes * @return true/false */ protected boolean locateMatchingAttributeValue(final String attrName, final String attrValue, final Map<String, Object> attributes) { return locateMatchingAttributeValue(attrName, attrValue, attributes, true); }
/** * Gets principal resolver linked to the handler if any. * * @param handler the handler * @param transaction the transaction * @return the principal resolver linked to handler if any, or null. */ protected PrincipalResolver getPrincipalResolverLinkedToHandlerIfAny(final AuthenticationHandler handler, final AuthenticationTransaction transaction) { return this.authenticationEventExecutionPlan.getPrincipalResolverForAuthenticationTransaction(handler, transaction); }
/** * Method will remove any previous bypass set in the authentication. * * @param authentication - the authentication */ default void updateAuthenticationToForgetBypass(final Authentication authentication) { authentication.addAttribute(AUTHENTICATION_ATTRIBUTE_BYPASS_MFA, Boolean.FALSE); }
@Override public void registerAuthenticationHandler(final AuthenticationHandler handler) { registerAuthenticationHandlerWithPrincipalResolver(handler, null); }
/** * Creates a new builder. * * @return New builder instance */ public static AuthenticationBuilder newInstance() { return new DefaultAuthenticationBuilder(); }
@Override public Authentication build() { return new DefaultAuthentication(this.authenticationDate, this.credentials, this.principal, this.attributes, this.successes, this.failures); } }
@Override public boolean supports(final Credential credential) { return this.authenticationHandler.supports(credential); } }