Search in sources :

Example 11 with MessageContextImpl

use of org.apache.cxf.jaxrs.ext.MessageContextImpl in project cxf by apache.

the class SamlPostBindingFilter method filter.

@Override
public void filter(ContainerRequestContext context) {
    Message m = JAXRSUtils.getCurrentMessage();
    if (checkSecurityContext(m)) {
        return;
    }
    try {
        SamlRequestInfo info = createSamlRequestInfo(m);
        info.setIdpServiceAddress(getIdpServiceAddress());
        // This depends on RequestDispatcherProvider linking
        // SamlRequestInfo with the jsp page which will fill
        // in the XHTML form using SamlRequestInfo
        // in principle we could've built the XHTML form right here
        // but it will be cleaner to get that done in JSP
        String contextCookie = createCookie(SSOConstants.RELAY_STATE, info.getRelayState(), info.getWebAppContext(), info.getWebAppDomain());
        new MessageContextImpl(m).getHttpServletResponse().addHeader(HttpHeaders.SET_COOKIE, contextCookie);
        context.abortWith(Response.ok(info).type("text/html").header(HttpHeaders.CACHE_CONTROL, "no-cache, no-store").header("Pragma", "no-cache").build());
    } catch (Exception ex) {
        throw ExceptionUtils.toInternalServerErrorException(ex, null);
    }
}
Also used : Message(org.apache.cxf.message.Message) IOException(java.io.IOException) MessageContextImpl(org.apache.cxf.jaxrs.ext.MessageContextImpl)

Aggregations

MessageContextImpl (org.apache.cxf.jaxrs.ext.MessageContextImpl)11 Message (org.apache.cxf.message.Message)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 MessageContext (org.apache.cxf.jaxrs.ext.MessageContext)4 Test (org.junit.Test)4 StringReader (java.io.StringReader)3 MediaType (javax.ws.rs.core.MediaType)3 Unmarshaller (javax.xml.bind.Unmarshaller)3 Book (org.apache.cxf.jaxrs.resources.Book)3 SuperBook (org.apache.cxf.jaxrs.resources.SuperBook)3 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 Annotation (java.lang.annotation.Annotation)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1