}
List<IdentityAuthenticator> authenticators =
authenticatorMap.get(credentials.getCredentialsType());
if (authenticators == null) {
throw new CredentialException("Unsupported credentials type: " +
credentials.getCredentialsType());
}
for (IdentityAuthenticator authenticator : authenticators) {
try {
return authenticator.authenticateIdentity(credentials);
} catch (LoginException le) {
// NOTE: because there could be multiple authenticators, it's
// not possible to return all errors, and besides it's not
// generally meaningful to return errors from different
// authenticators since some of them might be expected
// behavior. So, for now, these errors are being ignored
if (logger.isLoggable(Level.FINEST)) {
logger.logThrow(Level.FINEST, le, "Could not " +
"authenticate credentials with " +
"authenticator {0}",
authenticator.getClass().getName());
}
}
}
// no authenticators worked
throw new CredentialException("Could not authenticate identity");
}