public static UsedIdentities populate(Cluster cluster, ServiceExclude serviceExclude, ComponentExclude componentExclude, KerberosHelper kerberosHelper) throws AmbariException {
    List<KerberosIdentityDescriptor> result = new ArrayList<>();
    KerberosDescriptor root = kerberosHelper.getKerberosDescriptor(cluster, false);
    result.addAll(nullToEmpty(root.getIdentities()));
    for (Service service : cluster.getServices().values()) {
      if (serviceExclude.shouldExclude(service.getName())) {
        continue;
      }
      KerberosServiceDescriptor serviceDescriptor = root.getService(service.getName());
      if (serviceDescriptor != null) {
        result.addAll(nullToEmpty(serviceDescriptor.getIdentities()));
        result.addAll(nullToEmpty(componentIdentities(serviceDescriptor, service, componentExclude)));
      }
    }
    return new UsedIdentities(result);
  }
Get all identities of the installed services and components. Skip service or component that is excluded.
ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/UsedIdentities.java