public static String canonicalizeAlias(String clusterName, String alias) {
    String canonicaizedAlias;

    if ((clusterName == null) || clusterName.isEmpty() || (alias == null) || alias.isEmpty()) {
      canonicaizedAlias = alias;
    } else {
      String prefix = createAliasPrefix(clusterName);

      if (alias.toLowerCase().startsWith(prefix)) {
        canonicaizedAlias = alias;
      } else {
        canonicaizedAlias = prefix + alias;
      }
    }

    return (canonicaizedAlias == null)
        ? null
        : canonicaizedAlias.toLowerCase();
  }
Canonicalizes an alias name by making sure that is contains the prefix indicating what cluster it belongs to.
This helps to reduce collisions of alias between clusters pointing to the same keystore files.
<p/>
Each alias is expected to have a prefix of <code>cluster.:clusterName.</code>, and the
combination is to be converted to have all lowercase characters.  For example if the alias was
"external.DB" and the cluster name is "c1", then the canonicalized alias name would be
"cluster.c1.external.db".

@param clusterName the name of the cluster
@param alias       a string declaring the alias (or name) of the credential
@return a ccanonicalized alias name
ambari-server/src/main/java/org/apache/ambari/server/security/encryption/CredentialStoreServiceImpl.java