Search in sources :

Example 6 with LoggingOutInterceptor

use of org.apache.cxf.interceptor.LoggingOutInterceptor 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 7 with LoggingOutInterceptor

use of org.apache.cxf.interceptor.LoggingOutInterceptor in project opennms by OpenNMS.

the class TsrmTicketerPlugin method getService.

private SHSIMPINCPortType getService() {
    final SHSIMPINC service = new SHSIMPINC();
    port = service.getSHSIMPINCSOAP12Port();
    final Client cxfClient = ClientProxy.getClient(port);
    try {
        cxfClient.getRequestContext().put(Message.ENDPOINT_ADDRESS, getProperties().getProperty("tsrm.url"));
        final HTTPConduit http = (HTTPConduit) cxfClient.getConduit();
        String stictSSL = getProperties().getProperty("tsrm.ssl.strict");
        if (!Boolean.parseBoolean(stictSSL)) {
            LOG.debug("Disabling strict SSL checking.");
            // Accept all certificates
            final TrustManager[] simpleTrustManager = new TrustManager[] { new AnyServerX509TrustManager() };
            final TLSClientParameters tlsParams = new TLSClientParameters();
            tlsParams.setTrustManagers(simpleTrustManager);
            tlsParams.setDisableCNCheck(true);
            http.setTlsClientParameters(tlsParams);
        }
    } catch (IOException e) {
        LOG.error("Unable to load tsrm properties ", e);
    }
    // Log incoming and outgoing requests
    LoggingInInterceptor loggingInInterceptor = new LoggingInInterceptor();
    loggingInInterceptor.setPrettyLogging(true);
    cxfClient.getInInterceptors().add(loggingInInterceptor);
    LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
    loggingOutInterceptor.setPrettyLogging(true);
    cxfClient.getOutInterceptors().add(loggingOutInterceptor);
    return port;
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) TLSClientParameters(org.apache.cxf.configuration.jsse.TLSClientParameters) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) AnyServerX509TrustManager(org.opennms.core.utils.AnyServerX509TrustManager) IOException(java.io.IOException) Client(org.apache.cxf.endpoint.Client) SHSIMPINC(com.ibm.maximo.wsdl.shsimpinc.SHSIMPINC) AnyServerX509TrustManager(org.opennms.core.utils.AnyServerX509TrustManager) TrustManager(javax.net.ssl.TrustManager) X509TrustManager(javax.net.ssl.X509TrustManager)

Example 8 with LoggingOutInterceptor

use of org.apache.cxf.interceptor.LoggingOutInterceptor 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 9 with LoggingOutInterceptor

use of org.apache.cxf.interceptor.LoggingOutInterceptor 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 10 with LoggingOutInterceptor

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

the class Main method createModelPort.

public static ModelPortType createModelPort(String[] args) {
    String endpointUrl = DEFAULT_ENDPOINT_URL;
    if (args.length > 0) {
        endpointUrl = args[0];
    }
    System.out.println("Endpoint URL: " + endpointUrl);
    // uncomment this if you want to use Fiddler or any other proxy
    //ProxySelector.setDefault(new MyProxySelector("127.0.0.1", 8888));
    ModelService modelService = new ModelService();
    ModelPortType modelPort = modelService.getModelPort();
    BindingProvider bp = (BindingProvider) modelPort;
    Map<String, Object> requestContext = bp.getRequestContext();
    requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointUrl);
    org.apache.cxf.endpoint.Client client = ClientProxy.getClient(modelPort);
    org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();
    Map<String, Object> outProps = new HashMap<String, Object>();
    outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
    outProps.put(WSHandlerConstants.USER, ADM_USERNAME);
    outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
    outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordHandler.class.getName());
    WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
    cxfEndpoint.getOutInterceptors().add(wssOut);
    // enable the following to get client-side logging of outgoing requests and incoming responses
    cxfEndpoint.getOutInterceptors().add(new LoggingOutInterceptor());
    cxfEndpoint.getInInterceptors().add(new LoggingInInterceptor());
    return modelPort;
}
Also used : HashMap(java.util.HashMap) 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) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)

Aggregations

LoggingOutInterceptor (org.apache.cxf.interceptor.LoggingOutInterceptor)18 LoggingInInterceptor (org.apache.cxf.interceptor.LoggingInInterceptor)17 Client (org.apache.cxf.endpoint.Client)6 Test (org.junit.Test)6 URL (java.net.URL)4 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 HashMap (java.util.HashMap)3 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)3 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)3 UnknownPersonFault (org.apache.camel.wsdl_first.UnknownPersonFault)2 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)2 ClientPasswordHandler (com.evolveum.midpoint.cli.ninja.util.ClientPasswordHandler)1 SHSIMPINC (com.ibm.maximo.wsdl.shsimpinc.SHSIMPINC)1 IOException (java.io.IOException)1