Search in sources :

Example 1 with AuthenticationException

use of javax.security.enterprise.AuthenticationException in project tomee by apache.

the class TomEESecurityServerAuthModule method validateRequest.

@Override
public AuthStatus validateRequest(final MessageInfo messageInfo, final Subject clientSubject, final Subject serviceSubject) throws AuthException {
    final HttpMessageContext httpMessageContext = httpMessageContext(handler, messageInfo, clientSubject, serviceSubject);
    final HttpAuthenticationMechanism authenticationMechanism = CDI.current().select(TomEESecurityServletAuthenticationMechanismMapper.class).get().getCurrentAuthenticationMechanism(httpMessageContext);
    final AuthenticationStatus authenticationStatus;
    try {
        authenticationStatus = authenticationMechanism.validateRequest(httpMessageContext.getRequest(), httpMessageContext.getResponse(), httpMessageContext);
    } catch (final AuthenticationException e) {
        final AuthException authException = new AuthException(e.getMessage());
        authException.initCause(e);
        throw authException;
    }
    return mapToAuthStatus(authenticationStatus);
}
Also used : AuthenticationStatus(javax.security.enterprise.AuthenticationStatus) AuthenticationException(javax.security.enterprise.AuthenticationException) HttpAuthenticationMechanism(javax.security.enterprise.authentication.mechanism.http.HttpAuthenticationMechanism) AuthException(javax.security.auth.message.AuthException) HttpMessageContext(javax.security.enterprise.authentication.mechanism.http.HttpMessageContext)

Example 2 with AuthenticationException

use of javax.security.enterprise.AuthenticationException in project tomee by apache.

the class TomEESecurityServerAuthModule method secureResponse.

@Override
public AuthStatus secureResponse(final MessageInfo messageInfo, final Subject subject) throws AuthException {
    final HttpMessageContext httpMessageContext = httpMessageContext(handler, messageInfo, subject, null);
    final HttpAuthenticationMechanism authenticationMechanism = CDI.current().select(TomEESecurityServletAuthenticationMechanismMapper.class).get().getCurrentAuthenticationMechanism(httpMessageContext);
    final AuthenticationStatus authenticationStatus;
    try {
        authenticationStatus = authenticationMechanism.secureResponse(httpMessageContext.getRequest(), httpMessageContext.getResponse(), httpMessageContext);
    } catch (final AuthenticationException e) {
        final AuthException authException = new AuthException(e.getMessage());
        authException.initCause(e);
        throw authException;
    }
    return mapToAuthStatus(authenticationStatus);
}
Also used : AuthenticationStatus(javax.security.enterprise.AuthenticationStatus) AuthenticationException(javax.security.enterprise.AuthenticationException) HttpAuthenticationMechanism(javax.security.enterprise.authentication.mechanism.http.HttpAuthenticationMechanism) AuthException(javax.security.auth.message.AuthException) HttpMessageContext(javax.security.enterprise.authentication.mechanism.http.HttpMessageContext)

Aggregations

AuthException (javax.security.auth.message.AuthException)2 AuthenticationException (javax.security.enterprise.AuthenticationException)2 AuthenticationStatus (javax.security.enterprise.AuthenticationStatus)2 HttpAuthenticationMechanism (javax.security.enterprise.authentication.mechanism.http.HttpAuthenticationMechanism)2 HttpMessageContext (javax.security.enterprise.authentication.mechanism.http.HttpMessageContext)2