use of javax.security.enterprise.credential.UsernamePasswordCredential in project Payara by payara.
the class SampleAuthenticationMechanism method validateRequest.
@Override
public AuthenticationStatus validateRequest(HttpServletRequest request, HttpServletResponse response, HttpMessageContext httpMessageContext) throws AuthenticationException {
String name = request.getHeader("username");
String password = request.getHeader("password");
if (name == null && password == null) {
return httpMessageContext.doNothing();
} else {
CredentialValidationResult loginResult = identityStoreTest.validate(new UsernamePasswordCredential(name, password));
if (loginResult.getStatus() == VALID) {
return httpMessageContext.notifyContainerAboutLogin(loginResult.getCallerPrincipal(), loginResult.getCallerGroups());
} else {
return httpMessageContext.responseUnauthorized();
}
}
}
Aggregations