繁体   English   中英

如果使用 EJB,我可以在 Rest API 资源的方法中使用 JAX-RS @RoleAllowed

[英]Can I use JAX-RS @RoleAllowed in the Rest API resource's method, if EJB is used

根据 JBoss 7.1 Enterprise Edition,如果 RESTful 服务使用 EJB,则不建议在 Resource 的方法中使用 @RolesAllowed。

如果应用程序使用 EJB,请不要激活基于角色的安全性。 EJB 容器将提供功能,而不是 RESTEasy。

参考: https ://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.1/html/developing_web_services_applications/developing_jax_rs_web_services#Enable_Role-Based_Security_RESTEasy_JAX-RS_Web_Service

我对上述说法感到困惑。 我的应用程序是由 JAX-RS 层和 EJB 层构建的。 我正在解析 SecurityContext isUserInRole(String role) 方法的实现中的角色。 我的 web.xml 是空的。 这是否意味着我不能在资源的方法上使用@RolesAllowed,因为我的 REST 服务在后台使用 EJB?

否,@RoleAllowed 不调用 SecurityContext isUserInRole(String role) 方法。

因此,创建基于 @Namebinding 注释的过滤器来处理 SecurityContext isUserInRole(String role) 的权限是最好的方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM