private void fixIdentityReferences(Cluster cluster, AbstractKerberosDescriptorContainer container)
      throws AmbariException {
    List<KerberosIdentityDescriptor> identities = container.getIdentities();
    if (identities != null) {
      for (KerberosIdentityDescriptor identity : identities) {
        String name = identity.getName();

        if (!StringUtils.isEmpty(name) && (name.startsWith("/") || name.startsWith("./"))) {
          String[] parts = name.split("/");
          String newName = buildName(identity.getParent(), parts[parts.length - 1]);

          identity.setName(newName);
          identity.setReference(name);
        }

        String identityReference = identity.getReference();
        if (!StringUtils.isEmpty(identityReference)) {
          // If this identity references another identity:
          //  * The principal name needs to be the same as the referenced identity
          //    - ensure that no principal name is being set for this identity
          //  * Any configuration set to contain the reference principal name needs to be fixed to
          //    be the correct principal name
          KerberosPrincipalDescriptor principal = identity.getPrincipalDescriptor();
          if (principal != null) {
            // Fix the value
            principal.setValue(null);

            // Fix the relative configuration
            if (!StringUtils.isEmpty(principal.getConfiguration())) {
              String referencedPrincipalName = getConfiguredPrincipalNameFromReference(cluster, container, identityReference);

              if(!StringUtils.isEmpty(referencedPrincipalName)) {
                String[] parts = principal.getConfiguration().split("/");
                if (parts.length == 2) {
                  String type = parts[0];
                  String property = parts[1];

                  updateConfigurationPropertiesForCluster(cluster,
                      type,
                      Collections.singletonMap(property, referencedPrincipalName),
                      true,
                      false);
                }
              }
            }
          }
        }
      }
    }

    if (container instanceof KerberosDescriptor) {
      Map<String, KerberosServiceDescriptor> services = ((KerberosDescriptor) container).getServices();
      if (services != null) {
        for (KerberosServiceDescriptor serviceDescriptor : services.values()) {
          fixIdentityReferences(cluster, serviceDescriptor);
        }
      }
    } else if (container instanceof KerberosServiceDescriptor) {
      Map<String, KerberosComponentDescriptor> components = ((KerberosServiceDescriptor) container).getComponents();
      if (components != null) {
        for (KerberosComponentDescriptor componentDescriptor : components.values()) {
          fixIdentityReferences(cluster, componentDescriptor);
        }
      }
    }
  }
Recursively traverses the Kerberos descriptor to find and fix the identity references.
<p>
Each found identity descriptor that indicates it is a reference by having a <code>name</code>
value that starts with a "/" or a "./" is fixed by clearing the <code>principal name</code>value,
setting the <code>reference</code> value to the <code>name</code> value and changing the
<code>name</code> value to a name with the following pattern:
<code>SERVICE_COMPONENT_IDENTITY</code>
<p>
For example, if the identity is for the "SERVICE1" service and is a reference to "HDFS/NAMENODE/hdfs";
then the name is set to "<code>service1_hdfs</code>"
<p>
For example, if the identity is for the "COMPONENT21" component of the "SERVICE2" service and is a reference to "HDFS/NAMENODE/hdfs";
then the name is set to "<code>service2_component21_hdfs</code>"
<p>
Once the identity descriptor properties of the identity are fixed, the relevant configuration
value is fixed to match the value if the referenced identity. This may lead to a new version
of the relevant configuration type.

@param cluster   the cluster
@param container the current Kerberos descriptor container
@throws AmbariException if an error occurs
ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog260.java