实现声明性安全性时的HTTP状态403

时间:2013-03-11 12:46:13

标签: tomcat struts2 security

我做了以下更改,以在tomcat中实现声明性安全性(在struts2应用程序中)

我在tomcat-users.xml中添加了以下内容

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="Manager"/>
  <user username="manager1" password ="password1" roles="Manager"/>
</tomcat-users>

在我的web.xml中,我进行了以下更改

<security-role>
  <role-name>Manager</role-name>
</security-role>
<login-config>
  <auth-method>BASIC</auth-method>
</login-config>  

<security-constraint>
  <web-resource-collection>     
    <web-resource-name>MANAGER Access</web-resource-name>    
    <url-pattern>/manager/*</url-pattern>   
    <http-method>DELETE</http-method>    
    <http-method>PUT</http-method>    
    <http-method>HEAD</http-method>   
    <http-method>OPTIONS</http-method>   
    <http-method>TRACE</http-method>     
    <http-method>GET</http-method>    
    <http-method>POST</http-method>  
  </web-resource-collection>  

  <auth-constraint>
    <role-name>Manager</role-name>
  </auth-constraint>
</security-constraint>

当我访问URL appcontextname / manager / something.action时,它会提示输入用户名和密码,在我提供详细信息后,它会给我以下错误

HTTP状态403 - 拒绝访问所请求的资源

0 个答案:

没有答案