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);
}
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);
}
}
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;
}
}
}
Aggregations