Search in sources :

Example 46 with AuthException

use of javax.security.auth.message.AuthException 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)

Example 47 with AuthException

use of javax.security.auth.message.AuthException in project Payara by payara.

the class AdminConsoleAuthModule method forwardToErrorPage.

private AuthStatus forwardToErrorPage(RestResponse validationResult, HttpServletRequest request, HttpServletResponse response) throws AuthException {
    if (validationResult.getResponseCode() == 403) {
        request.setAttribute("errorText", GuiUtil.getMessage("alert.ConfigurationError"));
        request.setAttribute("messageText", GuiUtil.getMessage("alert.EnableSecureAdmin"));
    }
    try {
        request.getRequestDispatcher(loginErrorPage).forward(request, response);
        return SEND_FAILURE;
    } catch (Exception ex) {
        throw (AuthException) new AuthException().initCause(ex);
    }
}
Also used : AuthException(javax.security.auth.message.AuthException) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) AuthException(javax.security.auth.message.AuthException)

Example 48 with AuthException

use of javax.security.auth.message.AuthException in project Payara by payara.

the class JAASAuthContextHelper method loadConstructors.

private <M> void loadConstructors(M[] template, String authContextID) throws AuthException {
    if (constructors == null) {
        try {
            final Class moduleType = template.getClass().getComponentType();
            constructors = (Constructor[]) AccessController.doPrivileged(new java.security.PrivilegedExceptionAction() {

                @Override
                public Object run() throws java.lang.ClassNotFoundException, java.lang.NoSuchMethodException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException {
                    Constructor[] ctor = new Constructor[entry.length];
                    ClassLoader loader = Thread.currentThread().getContextClassLoader();
                    for (int i = 0; i < entry.length; i++) {
                        ctor[i] = null;
                        String clazz = entry[i].getLoginModuleName();
                        try {
                            Class c = Class.forName(clazz, true, loader);
                            if (moduleType.isAssignableFrom(c)) {
                                ctor[i] = c.getConstructor(PARAMS);
                            }
                        } catch (Throwable t) {
                            logIfLevel(Level.WARNING, null, "skipping unloadable class: ", clazz, " of appCOntext: ", appContext);
                        }
                    }
                    return ctor;
                }
            });
        } catch (java.security.PrivilegedActionException pae) {
            AuthException ae = new AuthException();
            ae.initCause(pae.getCause());
            throw ae;
        }
    }
}
Also used : PrivilegedActionException(java.security.PrivilegedActionException) Constructor(java.lang.reflect.Constructor) AuthException(javax.security.auth.message.AuthException) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

AuthException (javax.security.auth.message.AuthException)48 IOException (java.io.IOException)27 HttpServletRequest (javax.servlet.http.HttpServletRequest)24 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)21 CallerPrincipalCallback (javax.security.auth.message.callback.CallerPrincipalCallback)16 Principal (java.security.Principal)14 GroupPrincipalCallback (javax.security.auth.message.callback.GroupPrincipalCallback)14 HttpServletResponse (javax.servlet.http.HttpServletResponse)13 MessageInfo (javax.security.auth.message.MessageInfo)11 Callback (javax.security.auth.callback.Callback)10 AuthStatus (javax.security.auth.message.AuthStatus)9 Subject (javax.security.auth.Subject)8 ServerAuthContext (javax.security.auth.message.config.ServerAuthContext)7 PrivilegedActionException (java.security.PrivilegedActionException)4 ClientAuthModule (javax.security.auth.message.module.ClientAuthModule)4 ServerAuthModule (javax.security.auth.message.module.ServerAuthModule)4 MalformedURLException (java.net.MalformedURLException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3