code: protected WSPrincipal getWSPrincipal(Subject subject) throws IOException {
          WSPrincipal wsPrincipal = null;
          Set<WSPrincipal> principals = (subject != null) ? subject.getPrincipals(WSPrincipal.class) : null;
          if (principals != null && !principals.isEmpty()) {
              if (principals.size() > 1) {
                  // Error - too many principals
                  String principalNames = null;
                  for (WSPrincipal principal : principals) {
                      if (principalNames == null)
                          principalNames = principal.getName();
                      else
                          principalNames = principalNames + ", " + principal.getName();
                  }
                  throw new IOException(Tr.formatMessage(tc, "SEC_CONTEXT_DESERIALIZE_TOO_MANY_PRINCIPALS", principalNames));
              } else {
                  wsPrincipal = principals.iterator().next();
              }
          }
          return wsPrincipal;
      }
docs: Get the WSPrincipal from the subject
  
  @param subject
  @return the WSPrincipal of the subject
  @throws IOException if there is more than one WSPrincipal in the subject