Search in sources :

Example 1 with HttpsClient

use of com.adaptris.http.HttpsClient in project interlok by adaptris.

the class HttpsProduceConnection method initialiseClient.

/**
 * @see HttpClientConnection#initialiseClient(java.lang.String)
 */
@Override
public HttpClientTransport initialiseClient(String url) throws HttpException {
    HttpsClient client = new HttpsClient(url);
    try {
        if (keystore != null) {
            KeystoreFactory ksf = KeystoreFactory.getDefault();
            KeystoreLocation ksl = null;
            if (keystorePassword != null) {
                ksl = ksf.create(keystore, Password.decode(keystorePassword).toCharArray());
            } else {
                ksl = ksf.create(keystore);
            }
            char[] pkpw = PasswordOverride.discoverPrivateKeyPassword(ksl, getPrivateKeyPasswordProvider());
            if (pkpw != null) {
                client.registerPrivateKeyPassword(pkpw);
            }
            client.registerKeystore(ksf.create(ksl));
        }
    } catch (AdaptrisSecurityException e) {
        throw new HttpException(e);
    }
    client.setAlwaysTrust(alwaysTrust);
    return client;
}
Also used : KeystoreLocation(com.adaptris.security.keystore.KeystoreLocation) HttpsClient(com.adaptris.http.HttpsClient) AdaptrisSecurityException(com.adaptris.security.exc.AdaptrisSecurityException) KeystoreFactory(com.adaptris.security.keystore.KeystoreFactory) HttpException(com.adaptris.http.HttpException)

Example 2 with HttpsClient

use of com.adaptris.http.HttpsClient in project interlok by adaptris.

the class VersionedHttpsProduceConnection method initialiseClient.

/**
 * @see HttpClientConnection#initialiseClient(java.lang.String)
 */
@Override
public HttpClientTransport initialiseClient(String url) throws HttpException {
    HttpsClient client = new HttpsClient(new URLString(url), protocolVersion);
    try {
        if (getKeystore() != null) {
            KeystoreFactory ksf = KeystoreFactory.getDefault();
            KeystoreLocation ksl = null;
            if (getKeystorePassword() != null) {
                ksl = ksf.create(getKeystore(), Password.decode(getKeystorePassword()).toCharArray());
            } else {
                ksl = ksf.create(getKeystore());
            }
            char[] pkpw = PasswordOverride.discoverPrivateKeyPassword(ksl, getPrivateKeyPasswordProvider());
            if (pkpw != null) {
                client.registerPrivateKeyPassword(pkpw);
            }
            client.registerKeystore(ksf.create(ksl));
        }
    } catch (AdaptrisSecurityException e) {
        throw new HttpException(e);
    }
    client.setAlwaysTrust(getAlwaysTrust());
    return client;
}
Also used : KeystoreLocation(com.adaptris.security.keystore.KeystoreLocation) HttpsClient(com.adaptris.http.HttpsClient) AdaptrisSecurityException(com.adaptris.security.exc.AdaptrisSecurityException) KeystoreFactory(com.adaptris.security.keystore.KeystoreFactory) HttpException(com.adaptris.http.HttpException) URLString(com.adaptris.util.URLString)

Aggregations

HttpException (com.adaptris.http.HttpException)2 HttpsClient (com.adaptris.http.HttpsClient)2 AdaptrisSecurityException (com.adaptris.security.exc.AdaptrisSecurityException)2 KeystoreFactory (com.adaptris.security.keystore.KeystoreFactory)2 KeystoreLocation (com.adaptris.security.keystore.KeystoreLocation)2 URLString (com.adaptris.util.URLString)1