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;
}
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);
}
}
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;
}
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);
}
}
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);
}
Aggregations