Example usage for org.apache.commons.httpclient.protocol Protocol getSocketFactory

List of usage examples for org.apache.commons.httpclient.protocol Protocol getSocketFactory

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.protocol Protocol getSocketFactory.

Prototype

public ProtocolSocketFactory getSocketFactory() 

Source Link

Usage

From source file:com.springsource.hq.plugin.tcserver.serverconfig.web.support.UntrustedSSLProtocolSocketFactory.java

private static boolean isRegistered() {
    Protocol https = Protocol.getProtocol("https");
    boolean isRegistered = https.getSocketFactory() instanceof UntrustedSSLProtocolSocketFactory;
    if (!isRegistered) {
        defaultSSL = https;/* ww w  . j av a2 s  .c o  m*/
    }
    return isRegistered;
}

From source file:com.owncloud.android.utils.OwnCloudClientUtils.java

/**
 * Allows or disallows self-signed certificates in ownCloud servers to reach
 * /*from  www .  j av  a2  s.c  om*/
 * @param allow     'True' to allow, 'false' to disallow
 */
public static void allowSelfsignedCertificates(boolean allow) {
    Protocol pr = null;
    try {
        pr = Protocol.getProtocol("https");
    } catch (IllegalStateException e) {
        // nothing to do here; really
    }
    boolean isAllowed = (pr != null && pr.getSocketFactory() instanceof EasySSLSocketFactory);
    if (allow && !isAllowed) {
        Protocol.registerProtocol("https", new Protocol("https", new EasySSLSocketFactory(), 443));
    } else if (!allow && isAllowed) {
        // TODO - a more strict SocketFactory object should be provided here
    }
}

From source file:com.owncloud.android.oc_framework.network.NetworkUtils.java

/**
 * Registers or unregisters the proper components for advanced SSL handling.
 * @throws IOException //from   w w  w .j  av  a2s .  c  om
 */
public static void registerAdvancedSslContext(boolean register, Context context)
        throws GeneralSecurityException, IOException {
    Protocol pr = null;
    try {
        pr = Protocol.getProtocol("https");
        if (pr != null && mDefaultHttpsProtocol == null) {
            mDefaultHttpsProtocol = pr;
        }
    } catch (IllegalStateException e) {
        // nothing to do here; really
    }
    boolean isRegistered = (pr != null && pr.getSocketFactory() instanceof AdvancedSslSocketFactory);
    if (register && !isRegistered) {
        Protocol.registerProtocol("https", new Protocol("https", getAdvancedSslSocketFactory(context), 443));

    } else if (!register && isRegistered) {
        if (mDefaultHttpsProtocol != null) {
            Protocol.registerProtocol("https", mDefaultHttpsProtocol);
        }
    }
}

From source file:com.cerema.cloud2.lib.common.network.NetworkUtils.java

/**
 * Registers or unregisters the proper components for advanced SSL handling.
 * @throws IOException //w w w .ja v  a  2s  .  c  o m
 */
@SuppressWarnings("deprecation")
public static void registerAdvancedSslContext(boolean register, Context context)
        throws GeneralSecurityException, IOException {
    Protocol pr = null;
    try {
        pr = Protocol.getProtocol("https");
        if (pr != null && mDefaultHttpsProtocol == null) {
            mDefaultHttpsProtocol = pr;
        }
    } catch (IllegalStateException e) {
        // nothing to do here; really
    }
    boolean isRegistered = (pr != null && pr.getSocketFactory() instanceof AdvancedSslSocketFactory);
    if (register && !isRegistered) {
        Protocol.registerProtocol("https", new Protocol("https", getAdvancedSslSocketFactory(context), 443));

    } else if (!register && isRegistered) {
        if (mDefaultHttpsProtocol != null) {
            Protocol.registerProtocol("https", mDefaultHttpsProtocol);
        }
    }
}

From source file:com.owncloud.android.network.OwnCloudClientUtils.java

/**
 * Registers or unregisters the proper components for advanced SSL handling.
 * @throws IOException /*from   w w w.j a v  a  2s .c  om*/
 */
private static void registerAdvancedSslContext(boolean register, Context context)
        throws GeneralSecurityException, IOException {
    Protocol pr = null;
    try {
        pr = Protocol.getProtocol("https");
        if (pr != null && mDefaultHttpsProtocol == null) {
            mDefaultHttpsProtocol = pr;
        }
    } catch (IllegalStateException e) {
        // nothing to do here; really
    }
    boolean isRegistered = (pr != null && pr.getSocketFactory() instanceof AdvancedSslSocketFactory);
    if (register && !isRegistered) {
        Protocol.registerProtocol("https", new Protocol("https", getAdvancedSslSocketFactory(context), 443));

    } else if (!register && isRegistered) {
        if (mDefaultHttpsProtocol != null) {
            Protocol.registerProtocol("https", mDefaultHttpsProtocol);
        }
    }
}

From source file:com.owncloud.android.lib.test_project.test.SingleSessionManagerTest.java

public SingleSessionManagerTest() {
    super();//from  w  ww  . j  av  a2 s.c  om

    Protocol pr = Protocol.getProtocol("https");
    if (pr == null || !(pr.getSocketFactory() instanceof SelfSignedConfidentSslSocketFactory)) {
        try {
            ProtocolSocketFactory psf = new SelfSignedConfidentSslSocketFactory();
            Protocol.registerProtocol("https", new Protocol("https", psf, 443));

        } catch (GeneralSecurityException e) {
            throw new AssertionFailedError("Self-signed confident SSL context could not be loaded");
        }
    }
}

From source file:com.owncloud.android.lib.test_project.test.SimpleFactoryManagerTest.java

public SimpleFactoryManagerTest() {
    super();// w  ww  . ja  va  2s.c  o  m

    Protocol pr = Protocol.getProtocol("https");
    if (pr == null || !(pr.getSocketFactory() instanceof SelfSignedConfidentSslSocketFactory)) {
        try {
            ProtocolSocketFactory psf = new SelfSignedConfidentSslSocketFactory();
            Protocol.registerProtocol("https", new Protocol("https", psf, 443));

        } catch (GeneralSecurityException e) {
            throw new AssertionFailedError("Self-signed confident SSL context could not be loaded");
        }
    }
}

From source file:com.owncloud.android.lib.test_project.test.GetCapabilitiesTest.java

public GetCapabilitiesTest() {
    super();//from  w ww.j  ava  2 s .  com

    Protocol pr = Protocol.getProtocol("https");
    if (pr == null || !(pr.getSocketFactory() instanceof SelfSignedConfidentSslSocketFactory)) {
        try {
            ProtocolSocketFactory psf = new SelfSignedConfidentSslSocketFactory();
            Protocol.registerProtocol("https", new Protocol("https", psf, 443));

        } catch (GeneralSecurityException e) {
            throw new AssertionFailedError("Self-signed confident SSL context could not be loaded");
        }
    }

}

From source file:com.thoughtworks.go.agent.service.SslInfrastructureServiceTest.java

private void shouldCreateSslInfrastucture() throws Exception {
    sslInfrastructureService.createSslInfrastructure();
    Protocol protocol = Protocol.getProtocol("https");
    assertThat(protocol.getSocketFactory(), instanceOf(AuthSSLProtocolSocketFactory.class));
}

From source file:com.owncloud.android.lib.test_project.test.UpdateShareTest.java

public UpdateShareTest() {
    super();//from ww  w.j  av a2 s  .  co  m

    Protocol pr = Protocol.getProtocol("https");
    if (pr == null || !(pr.getSocketFactory() instanceof SelfSignedConfidentSslSocketFactory)) {
        try {
            ProtocolSocketFactory psf = new SelfSignedConfidentSslSocketFactory();
            Protocol.registerProtocol("https", new Protocol("https", psf, 443));

        } catch (GeneralSecurityException e) {
            throw new AssertionFailedError("Self-signed confident SSL context could not be loaded");
        }
    }
}