Search in sources :

Example 16 with LoggingOutInterceptor

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

the class AbstractWebServiceClient method createPort.

protected P createPort() throws Exception {
    String password = getDefaultPassword();
    String username = getDefaultUsername();
    String endpointUrl = getDefaultEndpointUrl();
    if (commandLine.hasOption('p')) {
        password = commandLine.getOptionValue('p');
    }
    if (commandLine.hasOption('u')) {
        username = commandLine.getOptionValue('u');
    }
    if (commandLine.hasOption('e')) {
        endpointUrl = commandLine.getOptionValue('e');
    }
    if (verbose) {
        System.out.println("Username: " + username);
        System.out.println("Password: <not shown>");
        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));
    P modelPort = createService().getPort(getPortClass());
    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> wssProps = new HashMap<String, Object>();
    if (!commandLine.hasOption('a') || (commandLine.hasOption('a') && WSHandlerConstants.USERNAME_TOKEN.equals(commandLine.getOptionValue('a')))) {
        wssProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
        wssProps.put(WSHandlerConstants.USER, username);
        wssProps.put(WSHandlerConstants.PASSWORD_TYPE, getPasswordType());
        wssProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordHandler.class.getName());
        ClientPasswordHandler.setPassword(password);
        WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(wssProps);
        cxfEndpoint.getOutInterceptors().add(wssOut);
    } else if (commandLine.hasOption('a') && "none".equals(commandLine.getOptionValue('a'))) {
    // Nothing to do
    } else {
        throw new IllegalArgumentException("Unknown authentication mechanism '" + commandLine.getOptionValue('a') + "'");
    }
    if (commandLine.hasOption('m')) {
        cxfEndpoint.getInInterceptors().add(new LoggingInInterceptor());
        cxfEndpoint.getOutInterceptors().add(new LoggingOutInterceptor());
    }
    return modelPort;
}
Also used : HashMap(java.util.HashMap) BindingProvider(javax.xml.ws.BindingProvider) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)

Example 17 with LoggingOutInterceptor

use of org.apache.cxf.interceptor.LoggingOutInterceptor in project maven-plugins by apache.

the class RestJiraDownloader method setupWebClient.

private WebClient setupWebClient(String jiraUrl) {
    WebClient client = WebClient.create(jiraUrl);
    ClientConfiguration clientConfiguration = WebClient.getConfig(client);
    HTTPConduit http = clientConfiguration.getHttpConduit();
    // MCHANGES-324 - Maintain the client session
    clientConfiguration.getRequestContext().put(Message.MAINTAIN_SESSION, Boolean.TRUE);
    if (getLog().isDebugEnabled()) {
        clientConfiguration.getInInterceptors().add(new LoggingInInterceptor());
        clientConfiguration.getOutInterceptors().add(new LoggingOutInterceptor());
    }
    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    // MCHANGES-341 Externalize JIRA server timeout values to the configuration section
    getLog().debug("RestJiraDownloader: connectionTimeout: " + connectionTimeout);
    httpClientPolicy.setConnectionTimeout(connectionTimeout);
    httpClientPolicy.setAllowChunking(false);
    getLog().debug("RestJiraDownloader: receiveTimout: " + receiveTimout);
    httpClientPolicy.setReceiveTimeout(receiveTimout);
    // MCHANGES-334 RestJiraDownloader doesn't honor proxy settings
    getProxyInfo(jiraUrl);
    if (proxyHost != null) {
        getLog().debug("Using proxy: " + proxyHost + " at port " + proxyPort);
        httpClientPolicy.setProxyServer(proxyHost);
        httpClientPolicy.setProxyServerPort(proxyPort);
        httpClientPolicy.setProxyServerType(ProxyServerType.HTTP);
        if (proxyUser != null) {
            ProxyAuthorizationPolicy proxyAuthorizationPolicy = new ProxyAuthorizationPolicy();
            proxyAuthorizationPolicy.setAuthorizationType("Basic");
            proxyAuthorizationPolicy.setUserName(proxyUser);
            proxyAuthorizationPolicy.setPassword(proxyPass);
            http.setProxyAuthorization(proxyAuthorizationPolicy);
        }
    }
    if (webUser != null) {
        AuthorizationPolicy authPolicy = new AuthorizationPolicy();
        authPolicy.setAuthorizationType("Basic");
        authPolicy.setUserName(webUser);
        authPolicy.setPassword(webPassword);
        http.setAuthorization(authPolicy);
    }
    http.setClient(httpClientPolicy);
    return client;
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) ProxyAuthorizationPolicy(org.apache.cxf.configuration.security.ProxyAuthorizationPolicy) AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) ProxyAuthorizationPolicy(org.apache.cxf.configuration.security.ProxyAuthorizationPolicy) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) WebClient(org.apache.cxf.jaxrs.client.WebClient) ClientConfiguration(org.apache.cxf.jaxrs.client.ClientConfiguration)

Example 18 with LoggingOutInterceptor

use of org.apache.cxf.interceptor.LoggingOutInterceptor in project ddf by codice.

the class AttributeQueryClaimsHandler method createDispatcher.

/**
     * Creates a dispatcher for dispatching requests.
     */
protected Dispatch<StreamSource> createDispatcher(Service service) {
    Dispatch<StreamSource> dispatch = null;
    if (service != null) {
        dispatch = service.createDispatch(QName.valueOf(portName), StreamSource.class, Service.Mode.MESSAGE);
        dispatch.getRequestContext().put(Dispatch.ENDPOINT_ADDRESS_PROPERTY, externalAttributeStoreUrl);
        dispatch.getRequestContext().put("ws-security.signature.properties", signatureProperties);
        dispatch.getRequestContext().put("ws-security.encryption.properties", encryptionProperties);
        ((DispatchImpl) dispatch).getClient().getBus().getOutInterceptors().add(new LoggingInInterceptor());
        ((DispatchImpl) dispatch).getClient().getBus().getOutInterceptors().add(new LoggingOutInterceptor());
    }
    return dispatch;
}
Also used : LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) StreamSource(javax.xml.transform.stream.StreamSource) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor)

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