code: private String getClientPrincipalName() {
      final Set<Principal> principalSet = loginContext.getSubject().getPrincipals();
      if (principalSet.size() != 1)
        throw new IllegalStateException(
            "Only one principal is expected. Found 0 or more than one principals :" + principalSet);
      return principalSet.iterator().next().getName();
    }
docs: This method is responsible for getting the client principal name from the
  subject's principal set
  
  @return String the Kerberos principal name populated in the subject
  @throws IllegalStateException if there is more than 0 or more than 1
  principal is present