访问EJB内的登录用户?

时间:2023-01-16 20:01:49

In a Java application, I need to obtain the logged-in user details inside an EJB3.

在Java应用程序中,我需要获取EJB3中的登录用户详细信息。

But sessionContext.getCallerPrincipal().getName() returns the value anonymous.

但sessionContext.getCallerPrincipal()。getName()返回匿名值。

I tried to use JAAS (weblogic.security.auth.login.UsernamePasswordLoginModule) but still the Subject, Principal values are available only initially but are not getting transferred into the Business layer. And has the value anonymous instead.

我尝试使用JAAS(weblogic.security.auth.login.UsernamePasswordLoginModule),但主题,主体值仍然只能在最初使用,但不会被转移到业务层。并且具有匿名的价值。

My environment is Java / JSF / EJB3 / Weblogic 11g.

我的环境是Java / JSF / EJB3 / Weblogic 11g。

Any idea?

1 个解决方案

#1


0  

I've had this problem many times. I put the user on a ThreadLocal and access it in the business layer. Either that or pass user as method parameter.

我有很多次这个问题。我将用户放在ThreadLocal上并在业务层中访问它。或者将用户作为方法参数传递。

#1


0  

I've had this problem many times. I put the user on a ThreadLocal and access it in the business layer. Either that or pass user as method parameter.

我有很多次这个问题。我将用户放在ThreadLocal上并在业务层中访问它。或者将用户作为方法参数传递。