public static Principal getSubjectUserPrincipal(Subject s) {
      if (s != null) {
         for (Principal p : s.getPrincipals()) {
            if (!(p instanceof Group)) {
               return p;
            }
         }
      }
      return null;
   }
public static Principal getSubjectUserPrincipal ( Subject s ) { if ( s != null ) { for ( Principal p : s . getPrincipals ( ) ) { if ( ! ( p instanceof Group ) ) { return p ; } } } return null ; }
Returns the first principal of a subject which is not of type {@link java.security.acl.Group}