private static Map<String, KerberosConfigurationDescriptor> processConfigurations(Map<String, KerberosConfigurationDescriptor> previousStackConfigurations,
                                                                                    Map<String, KerberosConfigurationDescriptor> newStackConfigurations,
                                                                                    Map<String, KerberosConfigurationDescriptor> userConfigurations) {

    if ((userConfigurations == null) || ((previousStackConfigurations == null) && (newStackConfigurations == null))) {
      return userConfigurations;
    }

    Map<String, KerberosConfigurationDescriptor> updatedConfigurations = new TreeMap<>();

    if (previousStackConfigurations == null) {
      previousStackConfigurations = Collections.emptyMap();
    }

    if (newStackConfigurations == null) {
      newStackConfigurations = Collections.emptyMap();
    }

    // Find configurations to modify or remove
    for (Map.Entry<String, KerberosConfigurationDescriptor> entry : userConfigurations.entrySet()) {
      String name = entry.getKey();
      KerberosConfigurationDescriptor userValue = entry.getValue();

      if (userValue != null) {
        if (newStackConfigurations.containsKey(name)) {
          KerberosConfigurationDescriptor oldValue = previousStackConfigurations.get(name);
          KerberosConfigurationDescriptor newValue = newStackConfigurations.get(name);

          LOG.debug("Processing configuration type {} for modifications", name);
          updatedConfigurations.put(name, processConfiguration(oldValue, newValue, userValue));
        } else if (previousStackConfigurations.containsKey(name)) {
          LOG.debug("Removing configuration type {} from user-specified Kerberos Descriptor", name);
          // Nothing to do here, just don't add it to the updated configurations map...
        } else {
          LOG.debug("Leaving configuration type {} in user-specified Kerberos Descriptor unchanged since it was user-defined.", name);
          updatedConfigurations.put(name, userValue);
        }
      }
    }

    // Note: there is no need to add configuration definitions that do not exist in the user-specified
    // descriptor since they will get added dynamically when merged with the stack default value.

    return updatedConfigurations;
  }
Processes the configuration-level Kerberos descriptors to add, remove, or update data in the user-specified
Kerberos descriptor.

@param previousStackConfigurations a map of {@link KerberosConfigurationDescriptor}s from the previous stack version's Kerberos descriptor
@param newStackConfigurations      a map of {@link KerberosConfigurationDescriptor}s from the new stack version's Kerberos descriptor
@param userConfigurations          a map of {@link KerberosConfigurationDescriptor}s from the user-supplied Kerberos descriptor
@return a map of updated {@link KerberosConfigurationDescriptor}s
ambari-server/src/main/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelper.java