Search in sources :

Example 1 with ECFHttpClientSecureProtocolSocketFactory

use of org.eclipse.ecf.internal.provider.filetransfer.httpclient4.ECFHttpClientSecureProtocolSocketFactory in project ecf by eclipse.

the class HttpClientRetrieveFileTransfer method registerSchemes.

private synchronized void registerSchemes(ISocketEventSource source, ISocketListener socketListener) {
    SchemeRegistry schemeRegistry = this.httpClient.getConnectionManager().getSchemeRegistry();
    Scheme http = new Scheme(HttpClientRetrieveFileTransfer.HTTP, HTTP_PORT, new ECFHttpClientProtocolSocketFactory(SocketFactory.getDefault(), source, socketListener));
    // $NON-NLS-1$
    Trace.trace(Activator.PLUGIN_ID, "registering http scheme");
    schemeRegistry.register(http);
    ISSLSocketFactoryModifier sslSocketFactoryModifier = Activator.getDefault().getSSLSocketFactoryModifier();
    if (sslSocketFactoryModifier == null) {
        sslSocketFactoryModifier = new HttpClientDefaultSSLSocketFactoryModifier();
    }
    SSLSocketFactory sslSocketFactory = null;
    try {
        sslSocketFactory = sslSocketFactoryModifier.getSSLSocketFactory();
    } catch (IOException e) {
        // $NON-NLS-1$
        Trace.catching(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_CATCHING, ISSLSocketFactoryModifier.class, "getSSLSocketFactory()", e);
        // $NON-NLS-1$
        Trace.throwing(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_THROWING, HttpClientRetrieveFileTransfer.class, "registerSchemes()", e);
        // $NON-NLS-1$
        throw new ECFRuntimeException("Unable to instantiate schemes for HttpClient.", e);
    }
    Scheme https = new Scheme(HttpClientRetrieveFileTransfer.HTTPS, HTTPS_PORT, new ECFHttpClientSecureProtocolSocketFactory(sslSocketFactory, source, socketListener));
    // $NON-NLS-1$
    Trace.trace(Activator.PLUGIN_ID, "registering https scheme; modifier=" + sslSocketFactoryModifier);
    schemeRegistry.register(https);
    // SPNEGO is not supported, so remove it from the list
    List authpref = new ArrayList(3);
    authpref.add(AuthPolicy.NTLM);
    authpref.add(AuthPolicy.DIGEST);
    authpref.add(AuthPolicy.BASIC);
    httpClient.getParams().setParameter(AuthPNames.PROXY_AUTH_PREF, authpref);
    httpClient.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF, authpref);
}
Also used : Scheme(org.apache.http.conn.scheme.Scheme) SchemeRegistry(org.apache.http.conn.scheme.SchemeRegistry) ArrayList(java.util.ArrayList) ECFHttpClientProtocolSocketFactory(org.eclipse.ecf.internal.provider.filetransfer.httpclient4.ECFHttpClientProtocolSocketFactory) ISSLSocketFactoryModifier(org.eclipse.ecf.internal.provider.filetransfer.httpclient4.ISSLSocketFactoryModifier) ECFHttpClientSecureProtocolSocketFactory(org.eclipse.ecf.internal.provider.filetransfer.httpclient4.ECFHttpClientSecureProtocolSocketFactory) List(java.util.List) ArrayList(java.util.ArrayList) IOException(java.io.IOException) SSLSocketFactory(javax.net.ssl.SSLSocketFactory) ECFRuntimeException(org.eclipse.ecf.core.util.ECFRuntimeException)

Aggregations

IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)1 Scheme (org.apache.http.conn.scheme.Scheme)1 SchemeRegistry (org.apache.http.conn.scheme.SchemeRegistry)1 ECFRuntimeException (org.eclipse.ecf.core.util.ECFRuntimeException)1 ECFHttpClientProtocolSocketFactory (org.eclipse.ecf.internal.provider.filetransfer.httpclient4.ECFHttpClientProtocolSocketFactory)1 ECFHttpClientSecureProtocolSocketFactory (org.eclipse.ecf.internal.provider.filetransfer.httpclient4.ECFHttpClientSecureProtocolSocketFactory)1 ISSLSocketFactoryModifier (org.eclipse.ecf.internal.provider.filetransfer.httpclient4.ISSLSocketFactoryModifier)1