use of org.apache.commons.httpclient.protocol.Protocol in project oxTrust by GluuFederation.
the class Shibboleth3ConfService method saveSpMetadataFile.
public String saveSpMetadataFile(String uri, String spMetadataFileName) {
if (StringHelper.isEmpty(uri)) {
return null;
}
HTTPFileDownloader.setEasyhttps(new Protocol("https", new EasyCASSLProtocolSocketFactory(), 443));
String spMetadataFileContent = HTTPFileDownloader.getResource(uri, "application/xml, text/xml", null, null);
if (StringHelper.isEmpty(spMetadataFileContent)) {
return null;
}
// Save new file
ByteArrayInputStream is;
try {
byte[] spMetadataFileContentBytes = spMetadataFileContent.getBytes("UTF-8");
is = new ByteArrayInputStream(spMetadataFileContentBytes);
} catch (UnsupportedEncodingException ex) {
ex.printStackTrace();
return null;
}
FileUploadWrapper tmpfileWrapper = new FileUploadWrapper();
tmpfileWrapper.setStream(is);
return saveSpMetadataFile(spMetadataFileName, tmpfileWrapper.getStream());
}
use of org.apache.commons.httpclient.protocol.Protocol 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