} else {
unauthenticated = true;
}
UserRealm realm = getRealm();
Authenticator authenticator = getAuthenticator();
Principal user = null;
if (!unauthenticated && !forbidden) {
if (realm == null) {
log.warn("Realm Not Configured");
throw new HttpException(HttpResponse.__500_Internal_Server_Error, "Realm Not Configured");
}
// Handle pre-authenticated request
if (authenticator != null) {
// User authenticator.
user = authenticator.authenticate(realm, pathInContext, request, response);
} else {
// don't know how authenticate
log.warn("Mis-configured Authenticator for " + request.getPath());
throw new HttpException(HttpResponse.__500_Internal_Server_Error, "Mis-configured Authenticator for " + request.getPath());
}
return user;
} else if (authenticator instanceof FormAuthenticator && pathInContext.endsWith(FormAuthenticator.__J_SECURITY_CHECK)) {
/**
* This could be a post request to __J_SECURITY_CHECK.
*/
if (realm == null) {
log.warn("Realm Not Configured");
throw new HttpException(HttpResponse.__500_Internal_Server_Error, "Realm Not Configured");
}
return authenticator.authenticate(realm, pathInContext, request, response);
}
/**
* No authentication is required. Return the defaultPrincipal.
*/