CredentialStoreServiceImpl implements CredentialStoreService { public synchronized void initializeTemporaryCredentialStore(long retentionDuration, TimeUnit units, boolean activelyPurge) throws AmbariException { if (isInitialized(CredentialStoreType.TEMPORARY)) { throw new AmbariException("This temporary CredentialStore has already been initialized"); } temporaryCredentialStore = new InMemoryCredentialStore(retentionDuration, units, activelyPurge); temporaryCredentialStore.setMasterKeyService(new MasterKeyServiceImpl(securePasswordHelper.createSecurePassword())); } @Inject  CredentialStoreServiceImpl(Configuration configuration, SecurePasswordHelper securePasswordHelper); synchronized void initializeTemporaryCredentialStore(long retentionDuration, TimeUnit units, boolean activelyPurge); synchronized void initializePersistedCredentialStore(File credentialStoreLocation, MasterKeyService masterKeyService); @Override void setCredential(String clusterName, String alias, Credential credential, CredentialStoreType credentialStoreType); @Override Credential getCredential(String clusterName, String alias); @Override Credential getCredential(String clusterName, String alias, CredentialStoreType credentialStoreType); @Override void removeCredential(String clusterName, String alias); @Override void removeCredential(String clusterName, String alias, CredentialStoreType credentialStoreType); @Override boolean containsCredential(String clusterName, String alias); @Override boolean containsCredential(String clusterName, String alias, CredentialStoreType credentialStoreType); @Override CredentialStoreType getCredentialStoreType(String clusterName, String alias); @Override Map<String, CredentialStoreType> listCredentials(String clusterName); @Override synchronized boolean isInitialized(); @Override synchronized boolean isInitialized(CredentialStoreType credentialStoreType); static String canonicalizeAlias(String clusterName, String alias); static String decanonicalizeAlias(String clusterName, String canonicaizedAlias);  }
@Test(expected = AmbariException.class) public void testFailToReinitialize_Temporary() throws Exception { credentialStoreService.initializeTemporaryCredentialStore(1, TimeUnit.MINUTES, false); }