I'm using Wildfly in version 8.1.0.Final. I'm doing authentication using HttpServletRequest through rest service in the way like below.
@Context
HttpServletRequest request;
...
request.login(user, password);
So then, I'm able to obtain logged user principal using request.getUserPrincipal();
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":
@Stateless
@SecurityDomain("other")
@PermitAll
public class FooBean implements Foo {
@Resource
private EJBContext ejbContext;
public void someMethod() {
String name = ejbContext.getCallerPrincipal().getName();
}
}
Is there any method to pass logged user principal from web layer into ejb context?