testsuite/testsuite-ee-security-jaxrs/src/main/java/org/wildfly/swarm/ee/security/SimpleAuthenticationMechanism.java [33:58]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ApplicationScoped
public class SimpleAuthenticationMechanism implements HttpAuthenticationMechanism {

    @Inject
    private IdentityStoreHandler identityStoreHandler;

    @Override
    public AuthenticationStatus validateRequest(HttpServletRequest request, HttpServletResponse response, HttpMessageContext httpMessageContext) throws AuthenticationException {

        String name = request.getParameter("name");
        Password password = new Password(request.getParameter("password"));

        // Delegate the {credentials in -> identity data out} function to
        // the Identity Store
        CredentialValidationResult result = identityStoreHandler.validate(
            new UsernamePasswordCredential(name, password));

        if (result.getStatus() == VALID) {
            // Communicate the details of the authenticated user to the
            // container. In many cases the underlying handler will just store the details
            // and the container will actually handle the login after we return from
            // this method.
            return httpMessageContext.notifyContainerAboutLogin(
                result.getCallerPrincipal(), result.getCallerGroups());
        }
        return httpMessageContext.responseUnauthorized();
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



testsuite/testsuite-ee-security/src/main/java/org/wildfly/swarm/ee/security/SimpleAuthenticationMechanism.java [33:58]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ApplicationScoped
public class SimpleAuthenticationMechanism implements HttpAuthenticationMechanism {

    @Inject
    private IdentityStoreHandler identityStoreHandler;

    @Override
    public AuthenticationStatus validateRequest(HttpServletRequest request, HttpServletResponse response, HttpMessageContext httpMessageContext) throws AuthenticationException {

        String name = request.getParameter("name");
        Password password = new Password(request.getParameter("password"));

        // Delegate the {credentials in -> identity data out} function to
        // the Identity Store
        CredentialValidationResult result = identityStoreHandler.validate(
            new UsernamePasswordCredential(name, password));

        if (result.getStatus() == VALID) {
            // Communicate the details of the authenticated user to the
            // container. In many cases the underlying handler will just store the details
            // and the container will actually handle the login after we return from
            // this method.
            return httpMessageContext.notifyContainerAboutLogin(
                result.getCallerPrincipal(), result.getCallerGroups());
        }
        return httpMessageContext.responseUnauthorized();
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



