public AuthResult login(String username, String password, Request request) throws ServletException {
PasswordValidationCallback passwordValidationCallback = new PasswordValidationCallback(new Subject(), username, password.toCharArray());
try {
callbackHandler.handle(new Callback[] {passwordValidationCallback});
if (passwordValidationCallback.getResult()) {
UserIdentity userIdentity = passwordValidationCallback.getSubject().getPrivateCredentials(UserIdentity.class).iterator().next();
return new AuthResult(TomcatAuthStatus.SUCCESS, userIdentity, containerCaching);
}
return new AuthResult(TomcatAuthStatus.FAILURE, null, false);
} catch (UnsupportedCallbackException e) {
throw new ServletException("internal server error");