@Test public void testFailNotInitialized() throws Exception { Configuration configuration = new Configuration(new Properties()); CredentialStoreService uninitializedCredentialStoreService = new CredentialStoreServiceImpl(configuration, new SecurePasswordHelper()); PrincipalKeyCredential credential1 = new PrincipalKeyCredential("username1", "password1"); uninitializedCredentialStoreService.setCredential(CLUSTER_NAME, "test1", credential1, CredentialStoreType.TEMPORARY); try { uninitializedCredentialStoreService.setCredential(CLUSTER_NAME, "test1", credential1, CredentialStoreType.PERSISTED); Assert.fail("AmbariException should have been thrown"); } catch (AmbariException e) { } }
@Override public void setCredential(String clusterName, String alias, Credential credential, CredentialStoreType credentialStoreType) throws AmbariException { validateInitialized(credentialStoreType); removeCredential(clusterName, alias); getCredentialStore(credentialStoreType).addCredential(canonicalizeAlias(clusterName, alias), credential); }
CredentialStoreServiceImpl implements CredentialStoreService { @Override public void setCredential(String clusterName, String alias, Credential credential, CredentialStoreType credentialStoreType) throws AmbariException { validateInitialized(credentialStoreType); removeCredential(clusterName, alias); getCredentialStore(credentialStoreType).addCredential(canonicalizeAlias(clusterName, alias), credential); } }
CredentialStoreServiceImpl implements CredentialStoreService { @Override public void setCredential(String clusterName, String alias, Credential credential, CredentialStoreType credentialStoreType) throws AmbariException { validateInitialized(credentialStoreType); removeCredential(clusterName, alias); getCredentialStore(credentialStoreType).addCredential(canonicalizeAlias(clusterName, alias), credential); } @Inject  CredentialStoreServiceImpl(Configuration configuration, SecurePasswordHelper securePasswordHelper); }
CredentialStoreServiceImpl implements CredentialStoreService { @Override public void setCredential(String clusterName, String alias, Credential credential, CredentialStoreType credentialStoreType) throws AmbariException { validateInitialized(credentialStoreType); removeCredential(clusterName, alias); getCredentialStore(credentialStoreType).addCredential(canonicalizeAlias(clusterName, alias), credential); } @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); }
CredentialStoreServiceImpl implements CredentialStoreService { @Override public void setCredential(String clusterName, String alias, Credential credential, CredentialStoreType credentialStoreType) throws AmbariException { validateInitialized(credentialStoreType); removeCredential(clusterName, alias); getCredentialStore(credentialStoreType).addCredential(canonicalizeAlias(clusterName, alias), credential); } @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);  }