-- Ray Bon Programmer analyst Development Services, University Systems 2507218831 | CLE 019 | rb...@uvic.ca
protected AuthenticationBuilder authenticateInternal(final AuthenticationTransaction transaction) throws AuthenticationException {
final Collection<Credential> credentials = transaction.getCredentials();
final AuthenticationBuilder builder = new DefaultAuthenticationBuilder(NullPrincipal.getInstance());
credentials.stream().forEach(cred -> builder.addCredential(new BasicCredentialMetaData(cred)));
final Set<AuthenticationHandler> handlerSet = getAuthenticationHandlersForThisTransaction(transaction);
Assert.notNull(handlerSet, "Resolved authentication handlers for this transaction cannot be null");
if (handlerSet.isEmpty()) {
LOGGER.warn("Resolved authentication handlers for this transaction are empty");
}
final boolean success = credentials
.stream()
.anyMatch(credential -> {
final boolean isSatisfied = handlerSet
.stream()
.filter(handler -> handler.supports(credential))
.anyMatch(handler -> {
try {
final PrincipalResolver resolver = getPrincipalResolverLinkedToHandlerIfAny(handler, transaction);
authenticateAndResolvePrincipal(builder, credential, resolver, handler);
final Pair<Boolean, Set<Throwable>> failures = evaluateAuthenticationPolicies(builder.build());
return failures.getKey();
} catch (final Exception e) {
handleAuthenticationException(e, handler.getName(), builder);
}
return false;
});
if (!isSatisfied) {
LOGGER.error("Authentication has failed. Credentials may be incorrect or CAS cannot "
+ "find authentication handler that supports [{}] of type [{}]. Examine the configuration to "
+ "ensure a method of authentication is defined and analyze CAS logs at DEBUG level to trace "
+ "the authentication event.", credential, credential.getClass().getSimpleName());
}
return isSatisfied;
});
if (!success) {
evaluateFinalAuthentication(builder, transaction);
}
return builder;
}
@Bean
public AuthenticationHandler proxyAuthenticationHandler() {
return new HttpBasedServiceCredentialsAuthenticationHandler(null, servicesManager,
proxyPrincipalFactory(), Integer.MIN_VALUE,
supportsTrustStoreSslSocketFactoryHttpClient);
}
Thanks
Rao