Search in sources :

Example 21 with Fault

use of org.apache.cxf.interceptor.Fault in project tesb-rt-se by Talend.

the class CompressionInInterceptor method handleMessage.

public void handleMessage(Message message) throws Fault {
    try {
        // Perform compression
        decompressMessage(message);
        // Confirm policy processing
        confirmPolicyProcessing(message);
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new Fault(e);
    }
}
Also used : Fault(org.apache.cxf.interceptor.Fault) IOException(java.io.IOException) XMLStreamException(javax.xml.stream.XMLStreamException)

Example 22 with Fault

use of org.apache.cxf.interceptor.Fault in project tesb-rt-se by Talend.

the class CompressionOutInterceptor method handleMessage.

public void handleMessage(Message message) throws Fault {
    try {
        // Load threshold value from policy assertion
        AssertionInfo ai = CompressionPolicyBuilder.getAssertion(message);
        if (ai != null) {
            Assertion a = ai.getAssertion();
            if (a instanceof CompressionAssertion) {
                this.setThreshold(((CompressionAssertion) a).getThreshold());
            }
        }
        wrapOriginalOutputStream(message);
        // Confirm policy processing
        if (ai != null) {
            ai.setAsserted(true);
        }
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new Fault(e);
    }
}
Also used : AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) Assertion(org.apache.neethi.Assertion) Fault(org.apache.cxf.interceptor.Fault) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException)

Example 23 with Fault

use of org.apache.cxf.interceptor.Fault in project fuse-karaf by jboss-fuse.

the class EnableCORSInterceptor method handleMessage.

@Override
public void handleMessage(Message message) throws Fault {
    Map<String, List<String>> headers = Headers.getSetProtocolHeaders(message);
    try {
        // Access-Control-Allow-Origin:* Access-Control-Allow-Methods:POST,GET
        headers.put("Access-Control-Allow-Origin", Arrays.asList("*"));
        headers.put("Access-Control-Allow-Methods", Arrays.asList("POST", "GET"));
    } catch (Exception ce) {
        throw new Fault(ce);
    }
}
Also used : List(java.util.List) Fault(org.apache.cxf.interceptor.Fault)

Example 24 with Fault

use of org.apache.cxf.interceptor.Fault in project jbossws-cxf by jbossws.

the class GracefulShutdownInterceptor method createFault.

private Fault createFault() {
    Fault f = new Fault(new org.apache.cxf.common.i18n.Message("Server is suspended", LOG));
    f.setStatusCode(503);
    return f;
}
Also used : Fault(org.apache.cxf.interceptor.Fault)

Example 25 with Fault

use of org.apache.cxf.interceptor.Fault in project testcases by coheigea.

the class SyncopeBasicAuthInterceptor method handleMessage.

public void handleMessage(Message message) throws Fault {
    AuthorizationPolicy policy = message.get(AuthorizationPolicy.class);
    if (policy == null || policy.getUserName() == null || policy.getPassword() == null) {
        String name = null;
        if (policy != null) {
            name = policy.getUserName();
        }
        String error = "No user credentials are available";
        LOG.warning(error + " " + "for name: " + name);
        throw new SecurityException(error);
    }
    try {
        UsernameToken token = convertPolicyToToken(policy);
        Credential credential = new Credential();
        credential.setUsernametoken(token);
        RequestData data = new RequestData();
        data.setMsgContext(message);
        credential = validator.validate(credential, data);
        // Create a Principal/SecurityContext
        Principal p = null;
        if (credential != null && credential.getPrincipal() != null) {
            p = credential.getPrincipal();
        } else {
            p = new WSUsernameTokenPrincipalImpl(policy.getUserName(), false);
            ((WSUsernameTokenPrincipalImpl) p).setPassword(policy.getPassword());
        }
        message.put(SecurityContext.class, createSecurityContext(p));
    } catch (Exception ex) {
        throw new Fault(ex);
    }
}
Also used : AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) Credential(org.apache.wss4j.dom.validate.Credential) RequestData(org.apache.wss4j.dom.handler.RequestData) UsernameToken(org.apache.wss4j.dom.message.token.UsernameToken) Fault(org.apache.cxf.interceptor.Fault) Principal(java.security.Principal) WSUsernameTokenPrincipalImpl(org.apache.wss4j.common.principal.WSUsernameTokenPrincipalImpl)

Aggregations

Fault (org.apache.cxf.interceptor.Fault)283 IOException (java.io.IOException)74 QName (javax.xml.namespace.QName)56 Message (org.apache.cxf.message.Message)52 XMLStreamException (javax.xml.stream.XMLStreamException)50 Element (org.w3c.dom.Element)42 Message (org.apache.cxf.common.i18n.Message)34 Exchange (org.apache.cxf.message.Exchange)30 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)30 SOAPException (javax.xml.soap.SOAPException)28 InputStream (java.io.InputStream)27 ArrayList (java.util.ArrayList)27 XMLStreamReader (javax.xml.stream.XMLStreamReader)26 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)26 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)25 Test (org.junit.Test)24 SecurityToken (org.apache.cxf.ws.security.tokenstore.SecurityToken)23 List (java.util.List)21 SOAPMessage (javax.xml.soap.SOAPMessage)21 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)21