DataStore implements DataCacheProvider, RolesProvider { public String getPublicKey(String domain, String service, String keyId) { String publicKeyName = generateServiceKeyName(domain, service, keyId); String publicKey; try { pkeyRLock.lock(); publicKey = publicKeyCache.get(publicKeyName); } finally { pkeyRLock.unlock(); } if (publicKey == null && LOGGER.isDebugEnabled()) { LOGGER.debug("Public key: " + publicKeyName + " not available"); } return publicKey; } DataStore(ChangeLogStore clogStore, CloudStore cloudStore); JWKList getZtsJWKList(Boolean rfc); void init(); boolean processDomain(SignedDomain signedDomain, boolean saveInStore); boolean processDomainDeletes(); void processDomainChecks(); boolean processDomainUpdates(); DomainData getDomainData(String name); void addDomainToCache(String name, DataCache dataCache); @Override DataCache getDataCache(String domainName); List<GroupMember> getGroupMembers(final String groupName); void getAccessibleRoles(DataCache data, String domainName, String identity,
            String[] requestedRoleList, Set<String> accessibleRoles, boolean keepFullName); String getPublicKey(String domain, String service, String keyId); HostServices getHostServices(String host); CloudStore getCloudStore(); void setCloudStore(CloudStore cloudStore); Cache<String, DataCache> getCacheStore(); Map<String, String> getPublicKeyCache(); @Override List<Role> getRolesByDomain(String domain);  }
@Test public void testGetPublicKey() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); store.publicKeyCache.put("coretech.storage_0", "PublicKey0"); store.publicKeyCache.put("sports.storage_0", "PublicKey0"); store.publicKeyCache.put("sports.storage_1", "PublicKey1"); Map<String, String> addKeys = new HashMap<>(); addKeys.put("sports.storage_1", "PublicKey1"); addKeys.put("sports.storage_2", "PublicKey2"); store.addPublicKeys(addKeys); assertEquals(store.getPublicKey("coretech", "storage", "0"), "PublicKey0"); assertEquals(store.getPublicKey("sports", "storage", "0"), "PublicKey0"); assertEquals(store.getPublicKey("sports", "storage", "1"), "PublicKey1"); assertEquals(store.getPublicKey("sports", "storage", "2"), "PublicKey2"); }