use of javax.security.enterprise.authentication.mechanism.http.HttpMessageContext in project tomee by apache.
the class RememberMeInterceptor method cleanSubject.
private void cleanSubject(final InvocationContext invocationContext) throws Exception {
final HttpMessageContext httpMessageContext = (HttpMessageContext) invocationContext.getParameters()[2];
final RememberMe rememberMe = TomEEELInvocationHandler.of(RememberMe.class, getRememberMe(), getElProcessor(invocationContext, httpMessageContext));
final Optional<Cookie> cookie = getCookie(httpMessageContext.getRequest(), rememberMe.cookieName());
if (cookie.isPresent() && !isEmpty(cookie.get().getValue())) {
// remove the cookie
cookie.get().setValue(null);
cookie.get().setMaxAge(0);
cookie.get().setPath(isEmpty(httpMessageContext.getRequest().getContextPath()) ? "/" : httpMessageContext.getRequest().getContextPath());
httpMessageContext.getResponse().addCookie(cookie.get());
// remove the token from the store
rememberMeIdentityStore.get().removeLoginToken(cookie.get().getValue());
}
invocationContext.proceed();
}
use of javax.security.enterprise.authentication.mechanism.http.HttpMessageContext 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);
}
Aggregations