use of org.javaee7.jaspic.wrapping.servlet.TestHttpServletResponseWrapper in project javaee7-samples by javaee-samples.
the class TestWrappingServerAuthModule method secureResponse.
@Override
public AuthStatus secureResponse(MessageInfo messageInfo, Subject serviceSubject) throws AuthException {
HttpServletRequest request = (HttpServletRequest) messageInfo.getRequestMessage();
// Unwrap the request
if (request instanceof TestHttpServletRequestWrapper) {
messageInfo.setRequestMessage(((TestHttpServletRequestWrapper) request).getRequest());
}
HttpServletResponse response = (HttpServletResponse) messageInfo.getResponseMessage();
if (response instanceof TestHttpServletResponseWrapper) {
messageInfo.setResponseMessage(((TestHttpServletResponseWrapper) response).getResponse());
}
return SEND_SUCCESS;
}
use of org.javaee7.jaspic.wrapping.servlet.TestHttpServletResponseWrapper in project javaee7-samples by javaee-samples.
the class TestWrappingServerAuthModule method validateRequest.
@Override
public AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject, Subject serviceSubject) throws AuthException {
try {
handler.handle(new Callback[] { new CallerPrincipalCallback(clientSubject, "test"), new GroupPrincipalCallback(clientSubject, new String[] { "architect" }) });
} catch (IOException | UnsupportedCallbackException e) {
throw (AuthException) new AuthException().initCause(e);
}
// Wrap the request - the resource to be invoked should get to see this
messageInfo.setRequestMessage(new TestHttpServletRequestWrapper((HttpServletRequest) messageInfo.getRequestMessage()));
// Wrap the response - the resource to be invoked should get to see this
messageInfo.setResponseMessage(new TestHttpServletResponseWrapper((HttpServletResponse) messageInfo.getResponseMessage()));
return SUCCESS;
}
Aggregations