Search in sources :

Example 1 with LoggingInInterceptor

use of org.apache.cxf.interceptor.LoggingInInterceptor in project midpoint by Evolveum.

the class Action method createModelPort.

protected ModelPortType createModelPort() {
    ModelService modelService = new ModelService();
    ModelPortType port = modelService.getModelPort();
    BindingProvider bp = (BindingProvider) port;
    Client client = ClientProxy.getClient(port);
    Endpoint endpoint = client.getEndpoint();
    HTTPConduit http = (HTTPConduit) client.getConduit();
    HTTPClientPolicy httpClientPolicy = http.getClient();
    if (httpClientPolicy == null) {
        httpClientPolicy = new HTTPClientPolicy();
        http.setClient(httpClientPolicy);
    }
    httpClientPolicy.setConnectionTimeout(10000);
    Map<String, Object> requestContext = bp.getRequestContext();
    requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, params.getUrl().toString());
    requestContext.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
    requestContext.put(WSHandlerConstants.USER, params.getUsername());
    requestContext.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
    ClientPasswordHandler handler = new ClientPasswordHandler();
    handler.setPassword(params.getInsertedPassword());
    requestContext.put(WSHandlerConstants.PW_CALLBACK_REF, handler);
    WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(requestContext);
    endpoint.getOutInterceptors().add(wssOut);
    if (params.isVerbose()) {
        endpoint.getOutInterceptors().add(new LoggingOutInterceptor());
        endpoint.getInInterceptors().add(new LoggingInInterceptor());
    }
    return port;
}
Also used : ModelPortType(com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType) BindingProvider(javax.xml.ws.BindingProvider) ModelService(com.evolveum.midpoint.xml.ns._public.model.model_3.ModelService) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) Endpoint(org.apache.cxf.endpoint.Endpoint) ClientPasswordHandler(com.evolveum.midpoint.cli.ninja.util.ClientPasswordHandler) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor) Client(org.apache.cxf.endpoint.Client)

Example 2 with LoggingInInterceptor

use of org.apache.cxf.interceptor.LoggingInInterceptor in project OpenAM by OpenRock.

the class SoapSTSConsumer method getSTSClient.

private STSClient getSTSClient(String wsdlAddress, QName serviceQName, QName portQName) throws SoapSTSConsumerException {
    STSClient stsClient = new STSClient(bus);
    if (logMessages) {
        stsClient.getInInterceptors().add(new LoggingInInterceptor());
        stsClient.getOutInterceptors().add(new LoggingOutInterceptor());
    }
    stsClient.setWsdlLocation(wsdlAddress);
    stsClient.setServiceName(serviceQName.toString());
    stsClient.setEndpointName(portQName.toString());
    Map<String, Object> properties = new HashMap<>();
    properties.put(SecurityConstants.USERNAME, usernameTokenSupportingTokenUsername);
    properties.put(SecurityConstants.CALLBACK_HANDLER, callbackHander);
    /*
        In a asymmetric binding, the client encrypt messages with with the sts' public key.
        Note that this trust (Public Key) keystore entry is not protected by a password, so the SoapSTSConsumerCallbackHandler is
        not asked to provide the password corresponding to this entry.
         */
    properties.put(SecurityConstants.ENCRYPT_USERNAME, stsPublicKeyAlias);
    Crypto crypto;
    try {
        crypto = CryptoFactory.getInstance(getEncryptionProperties());
    } catch (WSSecurityException e) {
        throw new SoapSTSConsumerException(e.getMessage(), e);
    }
    /*
        if the requested key is Public the STS_TOKEN_CRYPTO is used by the STSClient 'to send/process any
        RSA/DSAKeyValue tokens' - from javadocs
         */
    properties.put(SecurityConstants.STS_TOKEN_CRYPTO, crypto);
    properties.put(SecurityConstants.ENCRYPT_CRYPTO, crypto);
    properties.put(SecurityConstants.SIGNATURE_CRYPTO, crypto);
    stsClient.setProperties(properties);
    return stsClient;
}
Also used : STSClient(org.apache.cxf.ws.security.trust.STSClient) Crypto(org.apache.ws.security.components.crypto.Crypto) HashMap(java.util.HashMap) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) WSSecurityException(org.apache.ws.security.WSSecurityException)

Example 3 with LoggingInInterceptor

use of org.apache.cxf.interceptor.LoggingInInterceptor in project Activiti by Activiti.

the class AbstractWebServiceTaskTest method initializeProcessEngine.

@Override
protected void initializeProcessEngine() {
    super.initializeProcessEngine();
    webServiceMock = new WebServiceMockImpl();
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setServiceClass(WebServiceMock.class);
    svrFactory.setAddress("http://localhost:63081/webservicemock");
    svrFactory.setServiceBean(webServiceMock);
    svrFactory.getInInterceptors().add(new LoggingInInterceptor());
    svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
    server = svrFactory.create();
    server.start();
}
Also used : LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) WebServiceMockImpl(org.activiti.engine.impl.webservice.WebServiceMockImpl) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 4 with LoggingInInterceptor

use of org.apache.cxf.interceptor.LoggingInInterceptor in project camel by apache.

the class CXFWsdlOnlyPayloadModeNoSpringTest method testRoutes.

@Test
public void testRoutes() throws Exception {
    URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
    PersonService ss = new PersonService(wsdlURL, QName.valueOf(getServiceName()));
    Person client = ss.getSoap();
    Client c = ClientProxy.getClient(client);
    ((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + port1 + "/" + getClass().getSimpleName() + "/PersonService");
    c.getInInterceptors().add(new LoggingInInterceptor());
    c.getOutInterceptors().add(new LoggingOutInterceptor());
    Holder<String> personId = new Holder<String>();
    personId.value = "hello";
    Holder<String> ssn = new Holder<String>();
    Holder<String> name = new Holder<String>();
    client.getPerson(personId, ssn, name);
    assertEquals("Bonjour", name.value);
}
Also used : LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) PersonService(org.apache.camel.wsdl_first.PersonService) Holder(javax.xml.ws.Holder) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) Client(org.apache.cxf.endpoint.Client) Person(org.apache.camel.wsdl_first.Person) URL(java.net.URL) Test(org.junit.Test)

Example 5 with LoggingInInterceptor

use of org.apache.cxf.interceptor.LoggingInInterceptor in project camel by apache.

the class CxfConsumerPayloadFaultCauseEnabledTest method testInvokingFromCxfClient.

@Test
public void testInvokingFromCxfClient() throws Exception {
    this.getCamelContextService();
    URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
    PersonService ss = new PersonService(wsdlURL, SERVICE_QNAME);
    Person client = ss.getSoap();
    Client c = ClientProxy.getClient(client);
    c.getInInterceptors().add(new LoggingInInterceptor());
    c.getOutInterceptors().add(new LoggingOutInterceptor());
    ((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceAddress);
    Holder<String> personId = new Holder<String>();
    personId.value = "";
    Holder<String> ssn = new Holder<String>();
    Holder<String> name = new Holder<String>();
    try {
        client.getPerson(personId, ssn, name);
        fail("SOAPFault expected!");
    } catch (Exception e) {
        assertTrue(e instanceof SOAPFaultException);
        SOAPFault fault = ((SOAPFaultException) e).getFault();
        assertEquals("Someone messed up the service. Caused by: Homer", fault.getFaultString());
    }
}
Also used : LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) PersonService(org.apache.camel.wsdl_first.PersonService) Holder(javax.xml.ws.Holder) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) SOAPFault(javax.xml.soap.SOAPFault) Client(org.apache.cxf.endpoint.Client) Person(org.apache.camel.wsdl_first.Person) URL(java.net.URL) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.junit.Test)

Aggregations

LoggingInInterceptor (org.apache.cxf.interceptor.LoggingInInterceptor)30 LoggingOutInterceptor (org.apache.cxf.interceptor.LoggingOutInterceptor)25 Test (org.junit.Test)12 URL (java.net.URL)9 Bus (org.apache.cxf.Bus)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 PrintWriter (java.io.PrintWriter)6 Service (javax.xml.ws.Service)6 Client (org.apache.cxf.endpoint.Client)6 UseThreadBusFeature (org.jboss.wsf.stack.cxf.client.UseThreadBusFeature)6 QName (javax.xml.namespace.QName)5 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)5 JBossWSTest (org.jboss.wsf.test.JBossWSTest)5 BindingProvider (javax.xml.ws.BindingProvider)4 Holder (javax.xml.ws.Holder)4 Person (org.apache.camel.wsdl_first.Person)4 PersonService (org.apache.camel.wsdl_first.PersonService)4 WSS4JOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)4 ModelPortType (com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType)3 ModelService (com.evolveum.midpoint.xml.ns._public.model.model_3.ModelService)3