private static void collectFromIdentities(String service, String component, Collection<KerberosIdentityDescriptor> identities, Map<String, String> result) {
    for (KerberosIdentityDescriptor each : identities) {
      if (each.getPrincipalDescriptor() != null && !each.getReferencedServiceName().isPresent() &&
          !each.getName().startsWith("/")) {
        String path = StringUtils.isBlank(component)
            ? String.format("%s/%s", service, each.getName())
            : String.format("%s/%s/%s", service, component, each.getName());
        result.put(path, each.getPrincipalDescriptor().getName());
      }
    }
  }
Get a map of principals, where the key is the principal path (SERVICE/COMPONENT/principal_name or SERVICE/principal_name) and the value is the principal.
<p>
For example if the kerberos principal of the HISTORYSERVER is defined in the kerberos.json:
"name": "history_server_jhs",
"principal": {
"value": "jhs/_HOST@${realm}",
"type" : "service",
},
Then "jhs/_HOST@EXAMPLE.COM" will be put into the map under the "MAPREDUCE2/HISTORYSERVER/history_server_jhs" key.
ambari-server/src/main/java/org/apache/ambari/server/state/kerberos/KerberosDescriptor.java