DataCache { void processServiceIdentityPublicKey(String serviceName, String keyId, String publicKey) { if (publicKey == null) { return; } String keyValue = null; try { keyValue = Crypto.ybase64DecodeString(publicKey); } catch (CryptoException ex) { LOGGER.error("Invalid public key for {} with id {} with value '{}': {}", serviceName, keyId, publicKey, ex.getMessage()); } if (keyValue != null) { publicKeyCache.put(generateServiceKeyName(serviceName, keyId), keyValue); } } DataCache(); void setDomainData(DomainData domainData); DomainData getDomainData(); void processRole(Role role); void processPolicy(String domainName, Policy policy, Map<String, Role> roles); void processServiceIdentity(com.yahoo.athenz.zms.ServiceIdentity service); Set<MemberRole> getMemberRoleSet(final String member); List<String> getProviderDnsSuffixList(final String provider); List<String> getProviderHostnameAllowedSuffixList(final String provider); List<String> getProviderHostnameDeniedSuffixList(final String provider); Set<MemberRole> getAllMemberRoleSet(); Map<String, Set<MemberRole>> getPrefixMemberRoleSetMap(); int getMemberCount(); Set<String> getAWSResourceRoleSet(String role); RoleMeta getRoleMeta(String role); Map<String, Set<String>> getTrustMap(); Map<String, Set<String>> getHostMap(); Map<String, String> getPublicKeyMap(); Map<String, List<String>> getProviderDnsSuffixCache(); Map<String, List<String>> getProviderHostnameAllowedSuffixCache(); Map<String, List<String>> getProviderHostnameDeniedSuffixCache(); static final String ACTION_ASSUME_ROLE; static final String ACTION_ASSUME_AWS_ROLE; static final String ACTION_LAUNCH; static final String RESOURCE_DNS_PREFIX; static final String RESOURCE_HOSTNAME_PREFIX; }
@Test public void testProcessServiceIdentityPublicKey() { DataCache cache = new DataCache(); cache.processServiceIdentityPublicKey("service1", "id1", null); assertNull(cache.getPublicKeyMap().get("service1_id1")); cache.processServiceIdentityPublicKey("service1", "id1", "invalid-data"); assertNull(cache.getPublicKeyMap().get("service1_id1")); cache.processServiceIdentityPublicKey("service1", "id1", ZTS_Y64_CERT0); assertEquals(cache.getPublicKeyMap().get("service1_id1"), ZTS_PEM_CERT0); }