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();
}
Aggregations