use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy 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.transports.http.configuration.HTTPClientPolicy 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.transports.http.configuration.HTTPClientPolicy in project camel by apache.
the class ServiceNowClient method configureHttpClientPolicy.
private static void configureHttpClientPolicy(CamelContext context, ServiceNowConfiguration configuration, WebClient client) throws Exception {
HTTPClientPolicy httpPolicy = configuration.getHttpClientPolicy();
if (httpPolicy == null) {
String host = configuration.getProxyHost();
Integer port = configuration.getProxyPort();
if (host != null && port != null) {
httpPolicy = new HTTPClientPolicy();
httpPolicy.setProxyServer(host);
httpPolicy.setProxyServerPort(port);
}
}
if (httpPolicy != null) {
WebClient.getConfig(client).getHttpConduit().setClient(httpPolicy);
}
}
use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project uavstack by uavorg.
the class DoTestJaxWSHook method main.
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void main(String[] args) {
ConsoleLogger cl = new ConsoleLogger("test");
cl.setDebugable(true);
UAVServer.instance().setLog(cl);
UAVServer.instance().putServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR, ServerVendor.TOMCAT);
Map config = new HashMap();
Map adapts = JSONHelper.toObject("{\"org.apache.cxf.frontend.ClientProxy\":{\"getClient\":{args:[\"java.lang.Object\"],target:0}}}", Map.class);
config.put("adapts", adapts);
JaxWSHookProxy jp = new JaxWSHookProxy("test", config);
jp.doInstallDProxy(null, "test");
TestService_Service s = new TestService_Service();
TestService ts = s.getTestServicePort();
// 设置客户端的配置信息,超时等.
Client proxy = ClientProxy.getClient(ts);
HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
HTTPClientPolicy policy = new HTTPClientPolicy();
// 连接服务器超时时间
policy.setConnectionTimeout(30000);
// 等待服务器响应超时时间
policy.setReceiveTimeout(30000);
conduit.setClient(policy);
ts.echo();
try {
ts.echoFault();
} catch (Exception e) {
e.printStackTrace();
}
Dispatch<SOAPMessage> d = s.createDispatch(new QName("http://service.fat.monitorframework.creditease.com/", "TestServicePort"), SOAPMessage.class, Mode.MESSAGE);
try {
SOAPMessage msg = MessageFactory.newInstance().createMessage();
d.invoke(msg);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("--------------->CECXFClient");
CECXFClient client = new CECXFClient(TestService_Service.class, TestService.class, TestService_Service.TestServicePort);
client.setConnectTimeout(30000);
client.setReceiveTimeout(30000);
try {
client.invoke("echo", null);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project cxf by apache.
the class HTTPSConduitTest method verifyBethalClient.
// we just verify the configurations are loaded successfully
private void verifyBethalClient(Greeter bethal) {
Client client = ClientProxy.getClient(bethal);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = http.getClient();
assertEquals("the httpClientPolicy's autoRedirect should be true", true, httpClientPolicy.isAutoRedirect());
TLSClientParameters tlsParameters = http.getTlsClientParameters();
assertNotNull("the http conduit's tlsParameters should not be null", tlsParameters);
// If we set any name, but Edward, Mary, or George,
// and a password of "password" we will get through
// Bethal.
AuthorizationPolicy authPolicy = http.getAuthorization();
assertEquals("Set the wrong user name from the configuration", "Betty", authPolicy.getUserName());
assertEquals("Set the wrong pass word form the configuration", "password", authPolicy.getPassword());
configureProxy(ClientProxy.getClient(bethal));
String answer = bethal.sayHi();
answer = bethal.sayHi();
answer = bethal.sayHi();
answer = bethal.sayHi();
answer = bethal.sayHi();
assertTrue("Unexpected answer: " + answer, "Bonjour from Bethal".equals(answer));
// With HTTPS, it will just be a CONNECT to the proxy and all the
// data is encrypted. Thus, the proxy cannot distinquish the requests
assertProxyRequestCount(0);
}
Aggregations