title: How to get the user session using apache shiro with jersey RESTful
body: <p>Class A, I create a session using Shiro:</p>
  
  <pre><code>Subject currentUser = null;
  currentUser = SecurityUtils.getSubject();
  Session session = currentUser.getSession(true);
  session.setAttribute("currentUser", username);  
  </code></pre>
  
  <p>Class B, I have a restful web service method that is trying to get the username session:</p>
  
  <pre><code>HttpSession session = request.getSession();
  String currentUser = (String) session.getAttribute("currentUser");
  logger.debug("currently logged in user is: " + currentUser);
  </code></pre>
  
  <p>logger shows <code>currentUser</code> as <code>null</code></p>
  
  <p>Question: 
  How to get the currentUser session from my code? Is this correct? I am novice with Shiro.
  Can someone help?</p>
  
  <p>I have read about shiro DefaultWebSessionManager from shiro's site tutorial but cannot understand it. Can someone give me an example of how I can achieve this? </p>