Example usage for org.apache.http.conn.scheme SchemeRegistry get

List of usage examples for org.apache.http.conn.scheme SchemeRegistry get

Introduction

In this page you can find the example usage for org.apache.http.conn.scheme SchemeRegistry get.

Prototype

public final Scheme get(final String name) 

Source Link

Document

Obtains a scheme by name, if registered.

Usage

From source file:com.android.emailcommon.utility.EmailClientConnectionManager.java

/**
 * Unregisters a custom connection type that uses a client certificate on the connection
 * manager./*w ww.jav  a2  s. c  om*/
 * @see #registerClientCert(Context, String, boolean)
 */
public synchronized void unregisterClientCert(String clientCertAlias, boolean trustAllServerCerts) {
    SchemeRegistry registry = getSchemeRegistry();
    String schemeName = makeSchemeForClientCert(clientCertAlias, trustAllServerCerts);
    Scheme existing = registry.get(schemeName);
    if (existing != null) {
        registry.unregister(schemeName);
    }
}

From source file:com.chen.emailcommon.utility.EmailClientConnectionManager.java

/**
 * Ensures that a client SSL certificate is known to be used for the specified connection
 * manager.//from  ww  w  .  jav a2s .  co  m
 * A {@link SchemeRegistry} is used to denote which client certificates to use for a given
 * connection, so clients of this connection manager should use
 * {@link #makeSchemeForClientCert(String, boolean)}.
 */
public synchronized void registerClientCert(Context context, HostAuth hostAuth) throws CertificateException {
    SchemeRegistry registry = getSchemeRegistry();
    String schemeName = makeSchemeForClientCert(hostAuth.mClientCertAlias,
            hostAuth.shouldTrustAllServerCerts());
    Scheme existing = registry.get(schemeName);
    if (existing == null) {
        if (LOG_ENABLED) {
            LogUtils.i(Logging.LOG_TAG,
                    "Registering socket factory for certificate alias [" + hostAuth.mClientCertAlias + "]");
        }
        KeyManager keyManager = SSLUtils.KeyChainKeyManager.fromAlias(context, hostAuth.mClientCertAlias);
        boolean insecure = hostAuth.shouldTrustAllServerCerts();
        SSLSocketFactory ssf = SSLUtils.getHttpSocketFactory(context, hostAuth, keyManager, insecure);
        registry.register(new Scheme(schemeName, ssf, hostAuth.mPort));
    }
}

From source file:com.android.emailcommon.utility.EmailClientConnectionManager.java

/**
 * Ensures that a client SSL certificate is known to be used for the specified connection
 * manager.//from w  ww .j  av  a2 s .  co m
 * A {@link SchemeRegistry} is used to denote which client certificates to use for a given
 * connection, so clients of this connection manager should use
 * {@link #makeSchemeForClientCert(String, boolean)}.
 */
public synchronized void registerClientCert(Context context, HostAuth hostAuth) throws CertificateException {
    if (TextUtils.isEmpty(hostAuth.mClientCertAlias)) {
        return;
    }
    SchemeRegistry registry = getSchemeRegistry();
    String schemeName = makeSchemeForClientCert(hostAuth.mClientCertAlias,
            hostAuth.shouldTrustAllServerCerts());
    Scheme existing = registry.get(schemeName);
    if (existing == null) {
        if (LOG_ENABLED) {
            LogUtils.i(Logging.LOG_TAG,
                    "Registering socket factory for certificate alias [" + hostAuth.mClientCertAlias + "]");
        }
        KeyManager keyManager = KeyChainKeyManager.fromAlias(context, hostAuth.mClientCertAlias);
        boolean insecure = hostAuth.shouldTrustAllServerCerts();
        SSLSocketFactory ssf = SSLUtils.getHttpSocketFactory(context, hostAuth, keyManager, insecure);
        registry.register(new Scheme(schemeName, ssf, hostAuth.mPort));
    }
}