code: @Override
      public void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          Subject subject =
                  (Subject) request.getSession()
                          .getAttribute(SESSION_SUBJECT_KEY);
  
          java.security.Principal principal = request.getUserPrincipal();
          String userId = null;
          if (principal == null || principal.getName() == null
                  || principal.getName().isEmpty()) {
              userId = "anonymous";
          } else {
              userId = principal.getName();
          }
  
          DocumentBuilder documentBuilder = null;
          try {
              documentBuilder = XmlTransformUtility.borrowDocumentBuilder();
          } catch (Exception e) {
              throw new ServletException(e.getMessage(), e);
          }
          Document doc = documentBuilder.newDocument();
          if (documentBuilder != null) XmlTransformUtility.returnDocumentBuilder(documentBuilder);
          doc.setXmlVersion("1.0");
  
          Element root = doc.createElement("user");
          root.setAttribute("id", userId);
  
          doc.appendChild(root);
  
          Map<String, Set<String>> attributes =
                  SubjectUtils.getAttributes(subject);
  
          if (attributes != null && attributes.size() > 0) {
              for (String attr : attributes.keySet()) {
                  Element attribute = doc.createElement("attribute");
                  attribute.setAttribute("name", attr);
                  root.appendChild(attribute);
  
                  for (String value : attributes.get(attr)) {
                      Element v = doc.createElement("value");
                      v.appendChild(doc.createTextNode(value));
                      attribute.appendChild(v);
                  }
              }
          }
  
          byte[] output = null;
          try {
              output = DataUtils.format(doc).getBytes();
          } catch (Exception e) {
              logger.error("Error obtaining user information: " + e.getMessage(), e);
          }
  
          response.setContentType("text/xml");
          response.setContentLength(output.length);
          OutputStream out = response.getOutputStream();
          out.write(output);
          out.flush();
          out.close();
      }
docs: /*
  (non-Javadoc)
  @see
  javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest
  , javax.servlet.http.HttpServletResponse)