Search in sources :

Example 6 with PrivateKeyStore

use of com.yahoo.athenz.auth.PrivateKeyStore in project athenz by yahoo.

the class FilePrivateKeyStoreTest method testRetrievePrivateKeyValid.

@SuppressWarnings("deprecation")
@Test
public void testRetrievePrivateKeyValid() {
    FilePrivateKeyStoreFactory factory = new FilePrivateKeyStoreFactory();
    PrivateKeyStore store = factory.create();
    String saveProp = System.getProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_KEY);
    System.setProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_KEY, "src/test/resources/unit_test_zts_private_k0.key");
    StringBuilder keyId = new StringBuilder(256);
    PrivateKey privKey = store.getPrivateKey("zms", "localhost", keyId);
    assertNotNull(privKey);
    if (saveProp == null) {
        System.clearProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_KEY);
    } else {
        System.setProperty(FilePrivateKeyStore.ATHENZ_PROP_PRIVATE_KEY, saveProp);
    }
}
Also used : PrivateKey(java.security.PrivateKey) ServerPrivateKey(com.yahoo.athenz.auth.ServerPrivateKey) PrivateKeyStore(com.yahoo.athenz.auth.PrivateKeyStore) Test(org.testng.annotations.Test)

Example 7 with PrivateKeyStore

use of com.yahoo.athenz.auth.PrivateKeyStore in project athenz by yahoo.

the class ZMSFileChangeLogStoreFactoryTest method testCreateMTLSClientStoreWithKeyStoree.

@Test
public void testCreateMTLSClientStoreWithKeyStoree() {
    setupMTLSSettings();
    PrivateKeyStore privateKeyStore = new PrivateKeyStore() {

        @Override
        public String getApplicationSecret(String appName, String keyName) {
            return keyName;
        }
    };
    ZMSFileChangeLogStoreFactory factory = new ZMSFileChangeLogStoreFactory();
    factory.setPrivateKeyStore(privateKeyStore);
    ChangeLogStore store = factory.create(ZTS_DATA_STORE_PATH, null, null);
    assertNotNull(store);
    assertTrue(store instanceof ZMSFileMTLSChangeLogStore);
    clearMTLSSettings();
}
Also used : ChangeLogStore(com.yahoo.athenz.common.server.store.ChangeLogStore) PrivateKeyStore(com.yahoo.athenz.auth.PrivateKeyStore) Test(org.testng.annotations.Test)

Example 8 with PrivateKeyStore

use of com.yahoo.athenz.auth.PrivateKeyStore in project athenz by yahoo.

the class MsdStoreFactoryTest method createTest.

@Test
public void createTest() {
    MsdStore mockMsdStore = Mockito.mock(MsdStore.class);
    MsdStoreFactory factory = (PrivateKeyStore ks) -> mockMsdStore;
    PrivateKeyStore keyStore = new PrivateKeyStore() {
    };
    MsdStore msdStore = factory.create(keyStore);
    assertNotNull(msdStore);
}
Also used : PrivateKeyStore(com.yahoo.athenz.auth.PrivateKeyStore) Test(org.testng.annotations.Test)

Example 9 with PrivateKeyStore

use of com.yahoo.athenz.auth.PrivateKeyStore in project athenz by yahoo.

the class SSLUtilsTest method testLoadServicePrivateKey.

@Test
public void testLoadServicePrivateKey() {
    PrivateKeyStore keyStore = SSLUtils.loadServicePrivateKey("com.yahoo.athenz.auth.impl.FilePrivateKeyStoreFactory");
    Assert.assertNotNull(keyStore);
}
Also used : PrivateKeyStore(com.yahoo.athenz.auth.PrivateKeyStore) FilePrivateKeyStore(com.yahoo.athenz.auth.impl.FilePrivateKeyStore) Test(org.testng.annotations.Test)

Example 10 with PrivateKeyStore

use of com.yahoo.athenz.auth.PrivateKeyStore in project athenz by yahoo.

the class JDBCSSHRecordStoreFactoryTest method testCreate.

@Test
public void testCreate() {
    System.setProperty(ZTSConsts.ZTS_PROP_SSH_JDBC_STORE, "jdbc:mysql://localhost");
    System.setProperty(ZTSConsts.ZTS_PROP_SSH_JDBC_USER, "user");
    System.setProperty(ZTSConsts.ZTS_PROP_SSH_JDBC_PASSWORD, "password");
    PrivateKeyStore keyStore = Mockito.mock(PrivateKeyStore.class);
    Mockito.doReturn("password").when(keyStore).getApplicationSecret("jdbc", "password");
    JDBCSSHRecordStoreFactory factory = new JDBCSSHRecordStoreFactory();
    SSHRecordStore store = factory.create(keyStore);
    assertNotNull(store);
}
Also used : PrivateKeyStore(com.yahoo.athenz.auth.PrivateKeyStore) SSHRecordStore(com.yahoo.athenz.common.server.ssh.SSHRecordStore) Test(org.testng.annotations.Test)

Aggregations

PrivateKeyStore (com.yahoo.athenz.auth.PrivateKeyStore)36 Test (org.testng.annotations.Test)35 ResourceException (com.yahoo.athenz.zts.ResourceException)8 AmazonDynamoDB (com.amazonaws.services.dynamodbv2.AmazonDynamoDB)6 ServerPrivateKey (com.yahoo.athenz.auth.ServerPrivateKey)3 WorkloadRecordStore (com.yahoo.athenz.common.server.workload.WorkloadRecordStore)3 ZTSClientNotificationSender (com.yahoo.athenz.zts.ZTSClientNotificationSender)3 ZTSClientNotificationSenderImpl (com.yahoo.athenz.zts.notification.ZTSClientNotificationSenderImpl)3 CertRecordStore (com.yahoo.athenz.common.server.cert.CertRecordStore)2 SSHRecordStore (com.yahoo.athenz.common.server.ssh.SSHRecordStore)2 ObjectStore (com.yahoo.athenz.zms.store.ObjectStore)2 FilePrivateKeyStore (com.yahoo.athenz.auth.impl.FilePrivateKeyStore)1 ChangeLogStore (com.yahoo.athenz.common.server.store.ChangeLogStore)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 KeyStore (java.security.KeyStore)1 PrivateKey (java.security.PrivateKey)1 SecureRandom (java.security.SecureRandom)1 KeyManager (javax.net.ssl.KeyManager)1 KeyManagerFactory (javax.net.ssl.KeyManagerFactory)1