Search in sources :

Example 11 with Protocol

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());
}
Also used : EasyCASSLProtocolSocketFactory(org.gluu.oxtrust.util.EasyCASSLProtocolSocketFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Protocol(org.apache.commons.httpclient.protocol.Protocol) FileUploadWrapper(org.xdi.util.io.FileUploadWrapper)

Example 12 with Protocol

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;
}
Also used : MalformedURLException(java.net.MalformedURLException) RouteBuilder(org.apache.camel.builder.RouteBuilder) AuthSSLProtocolSocketFactory(org.apache.commons.httpclient.contrib.ssl.AuthSSLProtocolSocketFactory) Protocol(org.apache.commons.httpclient.protocol.Protocol) File(java.io.File) MalformedURLException(java.net.MalformedURLException)

Aggregations

Protocol (org.apache.commons.httpclient.protocol.Protocol)12 ProtocolSocketFactory (org.apache.commons.httpclient.protocol.ProtocolSocketFactory)6 IOException (java.io.IOException)2 RouteBuilder (org.apache.camel.builder.RouteBuilder)2 HttpClient (org.apache.commons.httpclient.HttpClient)2 URI (org.apache.commons.httpclient.URI)2 URIException (org.apache.commons.httpclient.URIException)2 SecureProtocolSocketFactory (org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory)2 Client (org.codehaus.xfire.client.Client)2 XFireProxy (org.codehaus.xfire.client.XFireProxy)2 XFireProxyFactory (org.codehaus.xfire.client.XFireProxyFactory)2 Service (org.codehaus.xfire.service.Service)2 ObjectServiceFactory (org.codehaus.xfire.service.binding.ObjectServiceFactory)2 EasySSLProtocolSocketFactory (org.codehaus.xfire.transport.http.EasySSLProtocolSocketFactory)2 DOMOutHandler (org.codehaus.xfire.util.dom.DOMOutHandler)2 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)1 BufferedInputStream (java.io.BufferedInputStream)1 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1