Search in sources :

Example 1 with HTTPConduit

use of org.apache.cxf.transport.http.HTTPConduit 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 HTTPConduit

use of org.apache.cxf.transport.http.HTTPConduit in project OpenAM by OpenRock.

the class SoapSTSConsumer method handleSTSServerCertCNDNSMismatch.

/**
     * This method must be called in case the CN in the Certificate presented by the container hosting the published sts
     * instance does not match the DNS name of this server. This check should not be relied-upon in production, and is
     * only present to facilitate testing.
     * @param stsClient The stsClient which will make the sts invocations
     */
private void handleSTSServerCertCNDNSMismatch(STSClient stsClient) throws SoapSTSConsumerException {
    javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(new javax.net.ssl.HostnameVerifier() {

        public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) {
            return true;
        }
    });
    /*
        CXF client also needs to have disabled the CN check in server-presented cert for TLS cases, if cert CN
        does not match DNS
         */
    TLSClientParameters tlsClientParameters = new TLSClientParameters();
    tlsClientParameters.setDisableCNCheck(true);
    try {
        ((HTTPConduit) stsClient.getClient().getConduit()).setTlsClientParameters(tlsClientParameters);
    } catch (BusException | EndpointException e) {
        throw new SoapSTSConsumerException(e.getMessage(), e);
    }
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) TLSClientParameters(org.apache.cxf.configuration.jsse.TLSClientParameters) EndpointException(org.apache.cxf.endpoint.EndpointException) BusException(org.apache.cxf.BusException)

Example 3 with HTTPConduit

use of org.apache.cxf.transport.http.HTTPConduit in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method createModelPort.

public 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);
    HTTPConduit http = (HTTPConduit) client.getConduit();
    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    httpClientPolicy.setReceiveTimeout(300000L);
    http.setClient(httpClientPolicy);
    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);
    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) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)

Example 4 with HTTPConduit

use of org.apache.cxf.transport.http.HTTPConduit in project camel by apache.

the class ServiceNowClient method configureTls.

private static void configureTls(CamelContext camelContext, ServiceNowConfiguration configuration, WebClient client) throws Exception {
    SSLContextParameters sslContextParams = configuration.getSslContextParameters();
    if (sslContextParams != null) {
        HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
        TLSClientParameters tlsClientParams = conduit.getTlsClientParameters();
        if (tlsClientParams == null) {
            tlsClientParams = new TLSClientParameters();
        }
        SSLContext sslContext = sslContextParams.createSSLContext(camelContext);
        tlsClientParams.setSSLSocketFactory(sslContext.getSocketFactory());
        conduit.setTlsClientParameters(tlsClientParams);
    }
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) TLSClientParameters(org.apache.cxf.configuration.jsse.TLSClientParameters) SSLContext(javax.net.ssl.SSLContext) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Example 5 with HTTPConduit

use of org.apache.cxf.transport.http.HTTPConduit in project camel by apache.

the class HostnameVerifierCxfRsEndpointConfigurer method configureClient.

@Override
public void configureClient(Client client) {
    HTTPConduit httpConduit = (HTTPConduit) WebClient.getConfig(client).getConduit();
    setupHttpConduit(httpConduit);
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit)

Aggregations

HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)158 Client (org.apache.cxf.endpoint.Client)65 Test (org.junit.Test)60 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)52 URL (java.net.URL)43 TLSClientParameters (org.apache.cxf.configuration.jsse.TLSClientParameters)43 Bus (org.apache.cxf.Bus)36 QName (javax.xml.namespace.QName)24 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)23 KeyStore (java.security.KeyStore)21 Greeter (org.apache.hello_world.Greeter)21 SOAPService (org.apache.hello_world.services.SOAPService)21 Service (javax.xml.ws.Service)18 TrustManagerFactory (javax.net.ssl.TrustManagerFactory)17 InputStream (java.io.InputStream)15 AuthorizationPolicy (org.apache.cxf.configuration.security.AuthorizationPolicy)15 IOException (java.io.IOException)13 ExecutionException (java.util.concurrent.ExecutionException)13 TrustManager (javax.net.ssl.TrustManager)13 WebClient (org.apache.cxf.jaxrs.client.WebClient)11