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