use of org.apache.cxf.transport.http.HTTPConduit in project tesb-rt-se by Talend.
the class MonitoringServiceFullTest method testSendEvents.
// @Before
// public void setUp() throws Exception {
// executeSqlScript("create.sql", true);
// }
@Test
public void testSendEvents() throws PutEventsFault, MalformedURLException, URISyntaxException {
Client client = ClientProxy.getClient(monitoringService);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy clientConfig = new HTTPClientPolicy();
clientConfig.setReceiveTimeout(100000);
conduit.setClient(clientConfig);
jdbcTemplate.update("delete from EVENTS");
List<EventType> events = new ArrayList<EventType>();
EventType eventType = new EventType();
eventType.setEventType(EventEnumType.REQ_OUT);
URL messageContentFile = this.getClass().getResource("/testmessage.xml").toURI().toURL();
eventType.setContent(new DataHandler(messageContentFile));
CustomInfoType ciType = new CustomInfoType();
CustomInfoType.Item prop1 = new CustomInfoType.Item();
prop1.setKey("mykey1");
prop1.setValue("myValue1");
ciType.getItem().add(prop1);
CustomInfoType.Item prop2 = new CustomInfoType.Item();
prop2.setKey("mykey2");
prop2.setValue("myValue2");
ciType.getItem().add(prop2);
eventType.setCustomInfo(ciType);
MessageInfoType mit = new MessageInfoType();
mit.setFlowId("uuid");
eventType.setMessageInfo(mit);
events.add(eventType);
String result = monitoringService.putEvents(events);
Assert.assertEquals("success", result);
long id = jdbcTemplate.queryForObject("select id from EVENTS", Long.class);
Event readEvent = eventRepository.readEvent(id);
Assert.assertEquals(EventTypeEnum.REQ_OUT, readEvent.getEventType());
Map<String, String> customInfo = readEvent.getCustomInfo();
Assert.assertEquals("myValue1", customInfo.get("mykey1"));
Assert.assertEquals("myValue2", customInfo.get("mykey2"));
}
use of org.apache.cxf.transport.http.HTTPConduit in project components by Talend.
the class NetSuiteClientService method setHttpClientPolicy.
protected void setHttpClientPolicy(PortT port, HTTPClientPolicy httpClientPolicy) {
Client proxy = ClientProxy.getClient(port);
HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
conduit.setClient(httpClientPolicy);
}
use of org.apache.cxf.transport.http.HTTPConduit in project components by Talend.
the class AmbariClientBuilder method build.
/**
* Build a client proxy, for a specific proxy type.
*
* @param proxyType proxy type class
* @return client proxy stub
*/
protected <T> T build(Class<T> proxyType) {
String address = generateAddress();
T rootResource;
// We want to ensure that the shared bean isn't set concurrently in multiple callers
synchronized (AmbariClientBuilder.class) {
JAXRSClientFactoryBean bean = cleanFactory(clientStaticResources.getUnchecked(proxyType));
bean.setAddress(address);
if (username != null) {
bean.setUsername(username);
bean.setPassword(password);
}
if (enableLogging) {
bean.setFeatures(Arrays.<AbstractFeature>asList(new LoggingFeature()));
}
rootResource = bean.create(proxyType);
}
boolean isTlsEnabled = address.startsWith("https://");
ClientConfiguration config = WebClient.getConfig(rootResource);
HTTPConduit conduit = (HTTPConduit) config.getConduit();
if (isTlsEnabled) {
TLSClientParameters tlsParams = new TLSClientParameters();
if (!validateCerts) {
tlsParams.setTrustManagers(new TrustManager[] { new AcceptAllTrustManager() });
} else if (trustManagers != null) {
tlsParams.setTrustManagers(trustManagers);
}
tlsParams.setDisableCNCheck(!validateCn);
conduit.setTlsClientParameters(tlsParams);
}
HTTPClientPolicy policy = conduit.getClient();
policy.setConnectionTimeout(connectionTimeoutUnits.toMillis(connectionTimeout));
policy.setReceiveTimeout(receiveTimeoutUnits.toMillis(receiveTimeout));
return rootResource;
}
use of org.apache.cxf.transport.http.HTTPConduit in project components by Talend.
the class AmbariClientBuilder method closeClient.
/**
* Closes the transport level conduit in the client. Reopening a new connection, requires creating a new client
* object using the build() method in this builder.
*
* @param root The resource returned by the build() method of this builder class
*/
public static void closeClient(ApiRootResource root) {
ClientConfiguration config = WebClient.getConfig(root);
HTTPConduit conduit = config.getHttpConduit();
if (conduit == null) {
throw new IllegalArgumentException("Client is not using the HTTP transport");
}
conduit.close();
}
use of org.apache.cxf.transport.http.HTTPConduit in project jbpm by kiegroup.
the class WebServiceCommand method applyAuthorization.
protected void applyAuthorization(String userName, String password, Client client) {
if (userName != null && password != null) {
HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
AuthorizationPolicy authorizationPolicy = new AuthorizationPolicy();
authorizationPolicy.setUserName(userName);
authorizationPolicy.setPassword(password);
authorizationPolicy.setAuthorizationType("Basic");
httpConduit.setAuthorization(authorizationPolicy);
} else {
logger.warn("UserName and Password must be provided to set the authorization policy.");
}
}
Aggregations