Shiro and SessionContext CDI => "anonymous"

456 Views Asked by At

I want to get my current loggin User in my EJB Container. I built an CDI - EJB Webapplication with Shiro for Security.

My problem is now, in my EJB Class the sessionContext is everytime "anonymous"

@Resource
private SessionContext sessionContext;

String userEmail = sessionContext.getCallerPrincipal().getName();

I don´t know, set Shiro this automaticly or should I set sessionContext? Can anybody help me?

The problem is the connection from CDI ---> EJB or why is it "anonymous"

1

There are 1 best solutions below

3
Sym-Sym On

@Resource is not context-aware. You want to use @Inject instead.