Search code examples
jakarta-eejaassecurity-roles

RolesAllowed non constant value


I'm using@RolesAllowed. It seems to only work with a constant value. But does a solution exist to use a non constant role in @RolesAllowed in Java EE?

Thanks


Solution

  • No, it is not possible to use non-constant names with standard Java EE declarative security. Instead, use @DeclareRoles with either HttpServletRequest.isUserInRole or EJBContext.isCallerInRole.