在tomcat上部署泽西服务后,基本身份验证无法正常工作

时间:2015-09-03 17:02:23

标签: java tomcat deployment basic-authentication

我已经为泽西服务添加了基本身份验证,并且工作正常,但在tomcat上部署此服务后,当我尝试在浏览器上访问它时,身份验证窗口弹出up,但它不接受用户名和密码。

我做错了什么吗?还是我忘记了什么?

web.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
>
<display-name>Restful Web Application</display-name>

<servlet>
    <servlet-name>jersey-serlvet</servlet-name>
    <servlet-class>
                 com.sun.jersey.spi.container.servlet.ServletContainer
    </servlet-class>
    <init-param>
         <param-name>com.sun.jersey.config.property.packages</param-name>
         <param-value>com.webservices.rest</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>jersey-serlvet</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<security-constraint>

<web-resource-collection>
  <web-resource-name>SEND</web-resource-name>
  <!-- <http-method>GET</http-method> -->
  <url-pattern>/rest/*</url-pattern>

</web-resource-collection>
<auth-constraint> 
<role-name>admin</role-name>
</auth-constraint>


</security-constraint>
<login-config> <auth-method>BASIC</auth-method></login-config> 

</web-app>

tomcat_users.xml文件

<tomcat-users>
<role rolename="admin"/>
<role rolename="member"/>
<user username="zakaria" password="zakaria" roles="admin,member"/>
<user username="jaadi" password="jaadi" roles="member"/>
</tomcat-users>

0 个答案:

没有答案