Search in sources :

Example 21 with PublicKeyEntry

use of com.yahoo.athenz.zms.PublicKeyEntry in project athenz by yahoo.

the class JDBCConnectionTest method testGetPublicKeyEntryInvalidKeyId.

@Test
public void testGetPublicKeyEntryInvalidKeyId() throws Exception {
    JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
    Mockito.when(mockResultSet.getInt(1)).thenReturn(// domain id
    5).thenReturn(// service id
    7);
    Mockito.when(mockResultSet.next()).thenReturn(// this one is for domain id
    true).thenReturn(// this one is for service id
    true).thenReturn(// for key
    false);
    PublicKeyEntry publicKey = jdbcConn.getPublicKeyEntry("my-domain", "service1", "zone1", false);
    assertNull(publicKey);
    jdbcConn.close();
}
Also used : PublicKeyEntry(com.yahoo.athenz.zms.PublicKeyEntry) JDBCConnection(com.yahoo.athenz.zms.store.jdbc.JDBCConnection) Test(org.testng.annotations.Test)

Example 22 with PublicKeyEntry

use of com.yahoo.athenz.zms.PublicKeyEntry in project athenz by yahoo.

the class PolicyUpdaterConfiguration method init.

public void init(String pathToAthenzConfigFile, String pathToZPUConfigFile) throws Exception {
    AthenzConfig athenzConfFile = null;
    if (pathToAthenzConfigFile == null) {
        athenzConfFile = readAthenzConfiguration(defaultAthenzConfigFile);
    } else {
        athenzConfFile = readAthenzConfiguration(pathToAthenzConfigFile);
    }
    LOG.info("Policy Updater configuration is set to:");
    LOG.info("policyFileDir: " + policyFileDir);
    List<PublicKeyEntry> publicKeys = athenzConfFile.getZtsPublicKeys();
    if (publicKeys != null) {
        for (PublicKeyEntry publicKey : publicKeys) {
            String keyId = publicKey.getId();
            String key = publicKey.getKey();
            if (key == null || keyId == null) {
                continue;
            }
            addZtsPublicKey(keyId, Crypto.loadPublicKey(Crypto.ybase64DecodeString(key)));
            LOG.info("Loaded ztsPublicKey keyId: " + keyId + " key: " + key);
        }
    }
    publicKeys = athenzConfFile.getZmsPublicKeys();
    if (publicKeys != null) {
        for (PublicKeyEntry publicKey : publicKeys) {
            String keyId = publicKey.getId();
            String key = publicKey.getKey();
            if (key == null || keyId == null) {
                continue;
            }
            addZmsPublicKey(keyId, Crypto.loadPublicKey(Crypto.ybase64DecodeString(key)));
            LOG.info("Loaded zmsPublicKey keyId: " + keyId + " key: " + key);
        }
    }
    Struct zpuConfFile = null;
    if (pathToZPUConfigFile == null) {
        zpuConfFile = readZpuConfiguration(defaultZPUConfigFile);
    } else {
        zpuConfFile = readZpuConfiguration(pathToZPUConfigFile);
    }
    String domains = zpuConfFile.getString(ZPU_CONFIG_DOMAINS);
    if (domains != null && !domains.isEmpty()) {
        domainList = Arrays.asList(domains.split(","));
    }
    zpuDirOwner = zpuConfFile.getString(ZPU_CONFIG_USER);
    if (zpuDirOwner == null || zpuDirOwner.isEmpty()) {
        zpuDirOwner = ZPU_USER_DEFAULT;
    }
    if (isDebugMode()) {
        LOG.debug("config-init: user: " + zpuDirOwner + " file=" + pathToZPUConfigFile);
    }
}
Also used : PublicKeyEntry(com.yahoo.athenz.zms.PublicKeyEntry) AthenzConfig(com.yahoo.athenz.common.config.AthenzConfig) Struct(com.yahoo.rdl.Struct)

Aggregations

PublicKeyEntry (com.yahoo.athenz.zms.PublicKeyEntry)22 Test (org.testng.annotations.Test)13 JDBCConnection (com.yahoo.athenz.zms.store.jdbc.JDBCConnection)11 SQLException (java.sql.SQLException)9 ResourceException (com.yahoo.athenz.zms.ResourceException)6 ServiceIdentity (com.yahoo.athenz.zms.ServiceIdentity)5 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 ArrayList (java.util.ArrayList)3 Struct (com.yahoo.rdl.Struct)2 AthenzConfig (com.yahoo.athenz.common.config.AthenzConfig)1 Role (com.yahoo.athenz.zms.Role)1 SignedPolicies (com.yahoo.athenz.zms.SignedPolicies)1 Array (com.yahoo.rdl.Array)1 File (java.io.File)1 PublicKey (java.security.PublicKey)1 HashMap (java.util.HashMap)1