我有一个工作(基于 web.xml)的容器身份验证和授权。由于<url-pattern>
我需要switch to javax.annotation.security
注释的限制。我发现我需要在 web.xml 中进行额外配置才能打开基于角色的安全注释。在 RESTEasy 用户指南中描述
但这对我不起作用:我收到错误 404(找不到相关资源:/services/customers/1),具体取决于是否
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
在 web.xml 中定义或不在<context-param>
and之后<listener>
这是我的旧(现有)web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Store_Service</display-name>
<session-config>
<session-timeout>10</session-timeout>
</session-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>SSL Secured WebService</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Authenticated customers only</web-resource-name>
<url-pattern>/services/customers/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>CUST</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Authentication-REALM</realm-name>
</login-config>
<security-role>
<role-name>CUST</role-name>
</security-role>
<security-role>
<role-name>ADMIN</role-name>
</security-role>
<welcome-file-list>
<welcome-file>/index.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
</web-app>
哪些配置项仍然需要,哪些需要添加才能@RolesAllowed("CUST")
正常工作。