private ResolvedKerberosPrincipal findPrincipal(Long hostId, String principal, String keytabPath) {
    for (ResolvedKerberosPrincipal rkp : principals) {
      boolean hostIdIsSame;
      if(hostId != null && rkp.getHostId() != null){
        hostIdIsSame = hostId.equals(rkp.getHostId());
      } else if(hostId == null && rkp.getHostId() == null) {
        hostIdIsSame = true;
      } else {
        hostIdIsSame = false;
      }
      if (hostIdIsSame && principal.equals(rkp.getPrincipal())&& keytabPath.equals(rkp.getKeytabPath())) {
        return rkp;
      }
    }
    return null;
  }
Merge principals from one keytab to given.

@param otherKeytab keytab to merge principals from
ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/stageutils/ResolvedKerberosKeytab.java