@Override
  public Map<String, CredentialStoreType> listCredentials(String clusterName) throws AmbariException {
    if (!isInitialized()) {
      throw new AmbariException("This CredentialStoreService has not yet been initialized");
    }

    Collection<String> persistedAliases = isInitialized(CredentialStoreType.PERSISTED)
        ? persistedCredentialStore.listCredentials()
        : null;

    Collection<String> temporaryAliases = isInitialized(CredentialStoreType.TEMPORARY)
        ? temporaryCredentialStore.listCredentials()
        : null;

    Map<String, CredentialStoreType> map = new HashMap<>();

    if (persistedAliases != null) {
      for (String alias : persistedAliases) {
        if (isAliasRequested(clusterName, alias)) {
          map.put(decanonicalizeAlias(clusterName, alias), CredentialStoreType.PERSISTED);
        }
      }
    }

    if (temporaryAliases != null) {
      for (String alias : temporaryAliases) {
        if (isAliasRequested(clusterName, alias)) {
          map.put(decanonicalizeAlias(clusterName, alias), CredentialStoreType.TEMPORARY);
        }
      }
    }

    return map;
  }
Adds a new credential to either the persistent or the temporary CredentialStore
<p/>
The supplied key will be converted into UTF-8 bytes before being stored.
<p/>
The alias name will be canonicalized as follows:
<ul>
<li>if a cluster name is supplied, then "cluster.name." will be prepended to it</li>
<li>the characters will converted to all lowercase</li>
</ul>
Only a single instance of the named credential will be stored, therefore if a credential with
alias ALIAS1 is stored in the persisted CredentialStore and a call is made to store a credentials
with alias ALIAS1 into the temporary CredentialStore, the instance in the persisted CredentialStore
will be removed.

@param clusterName         the name of the cluster this credential is related to
@param alias               a string declaring the alias (or name) of the credential
@param credential          the credential value to store
@param credentialStoreType a CredentialStoreType indicating which credential store facility to use
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/security/encryption/CredentialStoreServiceImpl.java