title: How to propagate user principal from HttpServletRequest into EJBContext?
body: <p>I'm using Wildfly in version 8.1.0.Final. I'm doing authentication using HttpServletRequest through rest service in the way like below.</p>
  
  <pre><code>@Context
  HttpServletRequest request;
  ...
  request.login(user, password);
  </code></pre>
  
  <p>So then, I'm able to obtain logged user principal using request.getUserPrincipal();</p>
  
  <p>But the login identities from web layer are not propagated into ejb layer. If I'm trying to obtain user principal from ejb bean, user principal is always "anonymous":</p>
  
  <pre><code>@Stateless
  @SecurityDomain("other")
  @PermitAll
  public class FooBean implements Foo {
  
      @Resource
      private EJBContext ejbContext;
  
      public void someMethod() {
          String name = ejbContext.getCallerPrincipal().getName();
      }
  }
  </code></pre>
  
  <p>Is there any method to pass logged user principal from web layer into ejb context?</p>