开发者

Spring Security with EJBs

开发者 https://www.devze.com 2022-12-19 15:51 出处:网络
Since EJB authorization is too limited for my needs I want to use Spring Security together with EJB开发者_C百科s. For authentication I want to use Spring Security too. The question is, if I can use th

Since EJB authorization is too limited for my needs I want to use Spring Security together with EJB开发者_C百科s. For authentication I want to use Spring Security too. The question is, if I can use the Spring Security context within an EJB.

The scenario:

  • user communicates with a servlet
  • authentication through Spring Security
  • servlet communicates with an EJB
  • the EJB may communicate with other EJBs
  • security check with an EJB interceptor or directly in the EJB method

Will the security context, usually hold in a thread local object, be propagated through the servlet and ejb layer so that I can use it for security checks?


If you are operating in a cluster, or EJB's on different servers, then each server (of course) will be running it's own thread so propogation will not occur.

If they are all on the same server, then they may, but I think it is vendor dependent, unless you are using local instead of remote interfaces.


You will be able to access the Spring Security context, provided there are no remote calls involved, but you will not be able to directly use any of Spring Security's declarative security features which require proxying of the object.

You could potentially use Spring beans from your servlet layer (implementing the same interfaces as the EJBs, and delegating to them), and apply security to these. This would also allow you to migrate away from EJBs if you wished to do so.

Another alternative would be to consider Spring Security's AspectJ support, which should work with EJBs.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号