use of password.pwm.PwmHttpFilterAuthenticationProvider in project pwm by pwm-project.
the class AuthenticationFilter method attemptAuthenticationMethods.
private static ProcessStatus attemptAuthenticationMethods(final PwmRequest pwmRequest) throws IOException, ServletException {
if (pwmRequest.isAuthenticated()) {
return ProcessStatus.Continue;
}
for (final AuthenticationMethod authenticationMethod : AuthenticationMethod.values()) {
if (!IGNORED_AUTH_METHODS.contains(authenticationMethod)) {
PwmHttpFilterAuthenticationProvider filterAuthenticationProvider = null;
try {
final String className = authenticationMethod.getClassName();
final Class clazz = Class.forName(className);
final Object newInstance = clazz.newInstance();
filterAuthenticationProvider = (PwmHttpFilterAuthenticationProvider) newInstance;
} catch (Exception e) {
LOGGER.trace("could not load authentication class '" + authenticationMethod + "', will ignore");
IGNORED_AUTH_METHODS.add(authenticationMethod);
}
if (filterAuthenticationProvider != null) {
try {
filterAuthenticationProvider.attemptAuthentication(pwmRequest);
if (pwmRequest.isAuthenticated()) {
LOGGER.trace(pwmRequest, "authentication provided by method " + authenticationMethod.name());
}
if (filterAuthenticationProvider.hasRedirectedResponse()) {
LOGGER.trace(pwmRequest, "authentication provider " + authenticationMethod.name() + " has issued a redirect, halting authentication process");
return ProcessStatus.Halt;
}
} catch (Exception e) {
final ErrorInformation errorInformation;
if (e instanceof PwmException) {
final String errorMsg = "error during " + authenticationMethod + " authentication attempt: " + e.getMessage();
errorInformation = new ErrorInformation(((PwmException) e).getError(), errorMsg);
} else {
errorInformation = new ErrorInformation(PwmError.ERROR_UNKNOWN, e.getMessage());
}
LOGGER.error(pwmRequest, errorInformation);
pwmRequest.respondWithError(errorInformation);
return ProcessStatus.Halt;
}
}
}
}
return ProcessStatus.Continue;
}
Aggregations