Search in sources :

Example 1 with SAAJOutInterceptor

use of org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor in project camel by apache.

the class CXFMessageDataFormatFeature method setupEndpoint.

protected void setupEndpoint(Endpoint ep) {
    resetPartTypes(ep.getBinding());
    Class<?> fmt = Source.class;
    if (ep.getBinding() instanceof SoapBinding) {
        ep.getInInterceptors().add(new SAAJInInterceptor());
        SAAJOutInterceptor out = new SAAJOutInterceptor();
        ep.getOutInterceptors().add(out);
        ep.getOutInterceptors().add(new CxfMessageSoapHeaderOutInterceptor());
        ep.getOutInterceptors().add(new MessageModeOutInterceptor(out, ep.getBinding().getBindingInfo().getName()));
        fmt = SOAPMessage.class;
    } else {
        ep.getOutInterceptors().add(new MessageModeOutInterceptor(Source.class, ep.getBinding().getBindingInfo().getName()));
    }
    ep.getInInterceptors().add(new MessageModeInInterceptor(fmt, ep.getBinding().getBindingInfo().getName()));
    ep.put(AbstractInDatabindingInterceptor.NO_VALIDATE_PARTS, Boolean.TRUE);
    // need to remove the wrapper class and holder interceptor
    removeInterceptors(ep.getInInterceptors(), REMOVING_IN_INTERCEPTORS);
    removeInterceptors(ep.getOutInterceptors(), REMOVING_OUT_INTERCEPTORS);
}
Also used : SAAJInInterceptor(org.apache.cxf.binding.soap.saaj.SAAJInInterceptor) SAAJOutInterceptor(org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor) MessageModeInInterceptor(org.apache.cxf.jaxws.interceptors.MessageModeInInterceptor) CxfMessageSoapHeaderOutInterceptor(org.apache.camel.component.cxf.interceptors.CxfMessageSoapHeaderOutInterceptor) MessageModeOutInterceptor(org.apache.cxf.jaxws.interceptors.MessageModeOutInterceptor) Source(javax.xml.transform.Source) SoapBinding(org.apache.cxf.binding.soap.SoapBinding)

Example 2 with SAAJOutInterceptor

use of org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor in project tomee by apache.

the class CalculatorTest method testCalculatorViaWsInterfaceWithUsernameTokenPlainPassword.

public void testCalculatorViaWsInterfaceWithUsernameTokenPlainPassword() throws Exception {
    final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplUsernameTokenPlainPassword?wsdl"), new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
    assertNotNull(calcService);
    // for debugging (ie. TCPMon)
    calcService.addPort(new QName("http://superbiz.org/wsdl", "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING, "http://127.0.0.1:8204/CalculatorImplUsernameTokenPlainPassword");
    //        CalculatorWs calc = calcService.getPort(
    //        	new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
    //        	CalculatorWs.class);
    final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
    final Client client = ClientProxy.getClient(calc);
    final Endpoint endpoint = client.getEndpoint();
    endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
    final Map<String, Object> outProps = new HashMap<String, Object>();
    outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
    outProps.put(WSHandlerConstants.USER, "jane");
    outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
    outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {

        @Override
        public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException {
            final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
            pc.setPassword("waterfall");
        }
    });
    final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
    endpoint.getOutInterceptors().add(wssOut);
    assertEquals(10, calc.sum(4, 6));
}
Also used : SAAJOutInterceptor(org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor) CallbackHandler(javax.security.auth.callback.CallbackHandler) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) IOException(java.io.IOException) URL(java.net.URL) WSPasswordCallback(org.apache.wss4j.common.ext.WSPasswordCallback) Callback(javax.security.auth.callback.Callback) Endpoint(org.apache.cxf.endpoint.Endpoint) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor) Client(org.apache.cxf.endpoint.Client) WSPasswordCallback(org.apache.wss4j.common.ext.WSPasswordCallback)

Example 3 with SAAJOutInterceptor

use of org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor in project tomee by apache.

the class CalculatorTest method testCalculatorViaWsInterfaceWithUsernameTokenHashedPassword.

public void testCalculatorViaWsInterfaceWithUsernameTokenHashedPassword() throws Exception {
    final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplUsernameTokenHashedPassword?wsdl"), new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
    assertNotNull(calcService);
    // for debugging (ie. TCPMon)
    calcService.addPort(new QName("http://superbiz.org/wsdl", "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING, "http://127.0.0.1:8204/CalculatorImplUsernameTokenHashedPassword");
    //        CalculatorWs calc = calcService.getPort(
    //        	new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
    //        	CalculatorWs.class);
    final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
    final Client client = ClientProxy.getClient(calc);
    final Endpoint endpoint = client.getEndpoint();
    endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
    final Map<String, Object> outProps = new HashMap<String, Object>();
    outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
    outProps.put(WSHandlerConstants.USER, "jane");
    outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
    outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {

        @Override
        public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException {
            final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
            pc.setPassword("waterfall");
        }
    });
    final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
    endpoint.getOutInterceptors().add(wssOut);
    assertEquals(10, calc.sum(4, 6));
}
Also used : SAAJOutInterceptor(org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor) CallbackHandler(javax.security.auth.callback.CallbackHandler) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) IOException(java.io.IOException) URL(java.net.URL) WSPasswordCallback(org.apache.wss4j.common.ext.WSPasswordCallback) Callback(javax.security.auth.callback.Callback) Endpoint(org.apache.cxf.endpoint.Endpoint) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor) Client(org.apache.cxf.endpoint.Client) WSPasswordCallback(org.apache.wss4j.common.ext.WSPasswordCallback)

Example 4 with SAAJOutInterceptor

use of org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor in project tomee by apache.

the class CalculatorTest method testCalculatorViaWsInterfaceWithSign.

public void testCalculatorViaWsInterfaceWithSign() throws Exception {
    final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplSign?wsdl"), new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
    assertNotNull(calcService);
    // for debugging (ie. TCPMon)
    calcService.addPort(new QName("http://superbiz.org/wsdl", "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING, "http://127.0.0.1:8204/CalculatorImplSign");
    //      CalculatorWs calc = calcService.getPort(
    //	new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
    //	CalculatorWs.class);
    final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
    final Client client = ClientProxy.getClient(calc);
    final Endpoint endpoint = client.getEndpoint();
    endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
    final Map<String, Object> outProps = new HashMap<String, Object>();
    outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
    outProps.put(WSHandlerConstants.USER, "clientalias");
    outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {

        @Override
        public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException {
            final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
            pc.setPassword("clientPassword");
        }
    });
    outProps.put(WSHandlerConstants.SIG_PROP_FILE, "META-INF/CalculatorImplSign-client.properties");
    outProps.put(WSHandlerConstants.SIG_KEY_ID, "IssuerSerial");
    final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
    endpoint.getOutInterceptors().add(wssOut);
    assertEquals(24, calc.multiply(4, 6));
}
Also used : SAAJOutInterceptor(org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor) CallbackHandler(javax.security.auth.callback.CallbackHandler) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) IOException(java.io.IOException) URL(java.net.URL) WSPasswordCallback(org.apache.wss4j.common.ext.WSPasswordCallback) Callback(javax.security.auth.callback.Callback) Endpoint(org.apache.cxf.endpoint.Endpoint) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor) Client(org.apache.cxf.endpoint.Client) WSPasswordCallback(org.apache.wss4j.common.ext.WSPasswordCallback)

Example 5 with SAAJOutInterceptor

use of org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor in project tomee by apache.

the class CalculatorTest method testCalculatorViaWsInterfaceWithTimestamp1way.

public void testCalculatorViaWsInterfaceWithTimestamp1way() throws Exception {
    final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplTimestamp1way?wsdl"), new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
    assertNotNull(calcService);
    // for debugging (ie. TCPMon)
    calcService.addPort(new QName("http://superbiz.org/wsdl", "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING, "http://127.0.0.1:8204/CalculatorImplTimestamp1way");
    //        CalculatorWs calc = calcService.getPort(
    //        	new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
    //		CalculatorWs.class);
    final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
    final Client client = ClientProxy.getClient(calc);
    final Endpoint endpoint = client.getEndpoint();
    endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
    final Map<String, Object> outProps = new HashMap<String, Object>();
    outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
    final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
    endpoint.getOutInterceptors().add(wssOut);
    assertEquals(12, calc.multiply(3, 4));
}
Also used : SAAJOutInterceptor(org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor) Endpoint(org.apache.cxf.endpoint.Endpoint) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor) Client(org.apache.cxf.endpoint.Client) URL(java.net.URL)

Aggregations

SAAJOutInterceptor (org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor)9 WSS4JOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)8 URL (java.net.URL)7 HashMap (java.util.HashMap)7 QName (javax.xml.namespace.QName)7 Service (javax.xml.ws.Service)7 Client (org.apache.cxf.endpoint.Client)7 Endpoint (org.apache.cxf.endpoint.Endpoint)7 IOException (java.io.IOException)5 Callback (javax.security.auth.callback.Callback)5 CallbackHandler (javax.security.auth.callback.CallbackHandler)5 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)5 WSPasswordCallback (org.apache.wss4j.common.ext.WSPasswordCallback)5 SAAJInInterceptor (org.apache.cxf.binding.soap.saaj.SAAJInInterceptor)3 WSS4JInInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor)2 Source (javax.xml.transform.Source)1 CxfMessageSoapHeaderOutInterceptor (org.apache.camel.component.cxf.interceptors.CxfMessageSoapHeaderOutInterceptor)1 SoapBinding (org.apache.cxf.binding.soap.SoapBinding)1 MessageModeInInterceptor (org.apache.cxf.jaxws.interceptors.MessageModeInInterceptor)1 MessageModeOutInterceptor (org.apache.cxf.jaxws.interceptors.MessageModeOutInterceptor)1