use of org.apache.commons.httpclient.contrib.ssl.AuthSSLProtocolSocketFactory in project ddf by codice.
the class HttpProxyServiceImpl method start.
public String start(final String endpointName, final String targetUri, final Integer timeout, final boolean matchOnPrefix, final Object bean) throws Exception {
// Enable proxy settings for the external target
enableProxySettings();
// Fetch location of trust store and trust store password
fetchTrustStoreLocation();
// Create SSL connection Camel protocol for https
Protocol authhttps = null;
File certStore = new File(trustStore);
try {
authhttps = new Protocol("https", new AuthSSLProtocolSocketFactory(certStore.toURI().toURL(), trustStorePassword, certStore.toURI().toURL(), trustStorePassword), 443);
} catch (MalformedURLException e) {
LOGGER.debug(e.getMessage());
}
if (authhttps != null) {
Protocol.registerProtocol("https", authhttps);
}
final String matchPrefix = (matchOnPrefix) ? "?matchOnUriPrefix=true" : "";
final String protocolDelimiter = (routeEndpointType.equals(SERVLET)) ? ":///" : "://";
// Create Camel route
RouteBuilder routeBuilder;
if (bean == null) {
routeBuilder = new RouteBuilder() {
@Override
public void configure() throws Exception {
from(routeEndpointType + protocolDelimiter + endpointName + matchPrefix).removeHeader("Authorization").removeHeader("Cookie").to(targetUri + "?bridgeEndpoint=true&throwExceptionOnFailure=false&httpClient.soTimeout=" + timeout + "&httpClient.connectionManagerTimeout=" + timeout).routeId(endpointName);
}
};
} else {
routeBuilder = new RouteBuilder() {
@Override
public void configure() throws Exception {
from(routeEndpointType + protocolDelimiter + endpointName + matchPrefix).removeHeader("Authorization").removeHeader("Cookie").to(targetUri + "?bridgeEndpoint=true&throwExceptionOnFailure=false&httpClient.soTimeout=" + timeout + "&httpClient.connectionManagerTimeout=" + timeout).routeId(endpointName).bean(bean);
}
};
}
camelContext.addRoutes(routeBuilder);
camelContext.start();
LOGGER.debug("Started proxy route at servlet endpoint: {}, routing to: {}", endpointName, targetUri);
endpointIds.add(endpointName);
return endpointName;
}
Aggregations