Search in sources :

Example 1 with FilePrivateKeyStore

use of com.yahoo.athenz.auth.impl.FilePrivateKeyStore in project athenz by yahoo.

the class SSLUtilsTest method testClientSSLContextBuilder.

@Test
public void testClientSSLContextBuilder() {
    String protocol = DEFAULT_SSL_PROTOCOL;
    SSLContext sslContext = new SSLUtils.ClientSSLContextBuilder(protocol).keyStorePath(DEFAULT_SERVER_KEY_STORE).keyManagerPassword(DEFAULT_CERT_PWD.toCharArray()).keyStorePassword(DEFAULT_CERT_PWD.toCharArray()).keyStoreType(DEFAULT_KEY_STORE_TYPE).trustStoreType(DEFAULT_TRUST_STORE_TYPE).keyStorePasswordAppName(KEYSTORE_PASSWORD_APP_NAME).keyManagerPasswordAppName(KEY_MANAGER_PASSWORD_APP_NAME).trustStorePasswordAppName(TRUSTSTORE_PASSWORD_APP_NAME).privateKeyStore(new FilePrivateKeyStore()).build();
    assertEquals(sslContext.getProtocol(), protocol);
    sslContext = new SSLUtils.ClientSSLContextBuilder(protocol).build();
    Assert.assertNull(sslContext);
    // key manager password is null
    assertThrows(RuntimeException.class, () -> new ClientSSLContextBuilder(protocol).keyStorePath(DEFAULT_SERVER_KEY_STORE).keyManagerPassword(null).keyStorePassword(DEFAULT_CERT_PWD.toCharArray()).keyStoreType(DEFAULT_KEY_STORE_TYPE).trustStoreType(DEFAULT_TRUST_STORE_TYPE).keyStorePasswordAppName(KEYSTORE_PASSWORD_APP_NAME).keyManagerPasswordAppName(KEY_MANAGER_PASSWORD_APP_NAME).trustStorePasswordAppName(TRUSTSTORE_PASSWORD_APP_NAME).privateKeyStore(new FilePrivateKeyStore()).build());
    // trust store password is null
    new SSLUtils.ClientSSLContextBuilder(protocol).keyStorePath(DEFAULT_SERVER_KEY_STORE).keyManagerPassword(DEFAULT_CERT_PWD.toCharArray()).keyStorePassword(DEFAULT_CERT_PWD.toCharArray()).keyStoreType(DEFAULT_KEY_STORE_TYPE).trustStoreType(DEFAULT_TRUST_STORE_TYPE).keyStorePasswordAppName(KEYSTORE_PASSWORD_APP_NAME).keyManagerPasswordAppName(KEY_MANAGER_PASSWORD_APP_NAME).trustStorePasswordAppName(TRUSTSTORE_PASSWORD_APP_NAME).trustStorePassword(null).trustStorePath(TRUSTSTORE_PATH).privateKeyStore(new FilePrivateKeyStore()).build();
    new SSLUtils.ClientSSLContextBuilder(protocol).keyStorePath("").keyManagerPassword(DEFAULT_CERT_PWD.toCharArray()).keyStorePassword(DEFAULT_CERT_PWD.toCharArray()).keyStoreType(DEFAULT_KEY_STORE_TYPE).trustStoreType(DEFAULT_TRUST_STORE_TYPE).keyStorePasswordAppName(KEYSTORE_PASSWORD_APP_NAME).keyManagerPasswordAppName(KEY_MANAGER_PASSWORD_APP_NAME).trustStorePasswordAppName(TRUSTSTORE_PASSWORD_APP_NAME).trustStorePassword(null).trustStorePath(TRUSTSTORE_PATH).privateKeyStore(new FilePrivateKeyStore()).build();
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) SSLContext(javax.net.ssl.SSLContext) ClientSSLContextBuilder(com.yahoo.athenz.common.utils.SSLUtils.ClientSSLContextBuilder) FilePrivateKeyStore(com.yahoo.athenz.auth.impl.FilePrivateKeyStore) Test(org.testng.annotations.Test)

Aggregations

FilePrivateKeyStore (com.yahoo.athenz.auth.impl.FilePrivateKeyStore)1 ClientSSLContextBuilder (com.yahoo.athenz.common.utils.SSLUtils.ClientSSLContextBuilder)1 SSLContext (javax.net.ssl.SSLContext)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 Test (org.testng.annotations.Test)1