code: private String getSubjectString(Subject subject) {
  
          String returnVal = null;
  
          if (subject != null) {
  
              if (System.getSecurityManager() != null) {
  
                  // Java 2 Security enabled
                  final Subject newSubject = subject;
                  PrivilegedExceptionAction privExAction = new PrivilegedExceptionAction() {
                      @Override
                      public Object run() throws Exception {
                          return newSubject.toString();
                      }
                  };
  
                  try {
                      returnVal = (String) AccessController.doPrivileged(privExAction);
                  } catch (PrivilegedActionException pae) {
                      if (tc.isDebugEnabled()) {
                          Tr.debug(tc, "Exception received in getSubjectString:", pae);
                      }
                      returnVal = "Subject cannot be traced due to a PrivilegedActionException";
                  }
  
              } // end security manager != null
  
              else {
                  returnVal = subject.toString();
              }
  
          } // end subject != null
  
          return returnVal;
  
      }
docs: The getSubjectString() method uses a doPrivileged wrapper
  to call toString() on a Subject passed as an argument, and
  the result is returned. This method is designed to be
  called in cases where the Subject needs to be traced, but
  the calling classes are not required to have permission to
  access the subject. PrivilegedActionExceptions received
  while calling toString() on the Subject are not rethrown
  so as not to interrupt the flow of the calling method. If
  a null Subject is passed as an argument, a value of null
  is returned.
  
  @param Subject subject
  @return String