code: private WSCredential getWSCredentialFromSubject(Subject subject) {
          if (subject != null) {
              java.util.Collection<Object> publicCreds = subject.getPublicCredentials();
  
              if (publicCreds != null && publicCreds.size() > 0) {
                  java.util.Iterator<Object> publicCredIterator = publicCreds.iterator();
  
                  while (publicCredIterator.hasNext()) {
                      Object cred = publicCredIterator.next();
  
                      if (cred instanceof WSCredential) {
                          return (WSCredential) cred;
                      }
                  }
              }
          }
          return null;
      }
docs: Get the WSCredential from the given Subject
  
  @param subject
  the subject to parse, must not be null
  @return the WSCredential, or null if the Subject does not have one