我必须在哪里放置@DeclareRoles?

问题描述 投票:5回答:1

我基本上了解@DeclareRoles@RolesAllowed的功能,但是我不确定在哪里正确添加@DeclareRoles。我用一个vaadin应用程序进行了测试,该应用程序在玻璃鱼4中使用了ejb会话bean和cdi。

  • [no类上的[@DeclareRoles:显然没有任何效果。 HttpServletRequest.isUserInRole()SessionContext.isCallerInRole()始终返回false。 @RolesAllowed始终拒绝访问。@DeclareRoles在Servlet上:@RolesAllowedHttpServletRequest.isUserInRole()正常工作。 SessionContext.isCallerInRole()总是返回false。
  • @DeclareRoles在会话bean上:@RolesAllowedHttpServletRequest.isUserInRole()SessionContext.isCallerInRole()正常工作。即使在与SessionContext.isCallerInRole()
  • 的会话bean之外的会话bean中调用了@DeclareRoles
  • 我的问题是:

    放置@DeclareRoles的正确位置在哪里?
  1. 可以只设置一次,还是应该为每个使用SessionContext.isCallerInRole()@RolesAllowed的bean注释?
  • 我基本上了解@DeclareRoles和@RolesAllowed的功能,但是我不确定在哪里正确添加@DeclareRoles。我用一个带有ejb会话bean和cdi的vaadin应用程序进行测试...
  • java security jakarta-ee
    1个回答
    0
    投票
    可以在类,类的业务方法或两者上指定方法权限。可以在bean类的方法上指定方法许可权,以覆盖在整个bean类上指定的方法许可权值。以下注释用于指定方法权限:
    © www.soinside.com 2019 - 2024. All rights reserved.