在TOMCAT中,在webapps下的应用程序下的WEB-INF目录下的web.xml中的
节中,配置如下信息:
- <!-- Define a security constraint on this application -->
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>Entire Application</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <!-- This role is not in the default user directory -->
- <role-name>manager</role-name>
- </auth-constraint>
- </security-constraint>
- <!-- Define the login configuration for this application -->
- <!--
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>Tomcat Manager Application</realm-name>
- </login-config>
- -->
- <!-- Security roles referenced by this web application -->
- <security-role>
- <description>
- The role that is required to log in to the Manager Application
- </description>
- <role-name>manager</role-name>
- </security-role>
后,每次在IE中输入TOMCAT的地址后,将会弹出HTTP Authentication窗口,要求输入用户名和密码,而这个用户名和密码配置在tomcat-users.xml中,需要配置一个manager角色和具有这个角色的用户。如:
- <?xml version='1.0' encoding='utf-8'?>
- <tomcat-users>
- <role rolename="tomcat"/>
- <role rolename="role1"/>
- <role rolename="manager"/>
- <user username="both" password="tomcat" roles="tomcat,role1"/>
- <user username="tomcat" password="tomcat" roles="tomcat,manager"/>
- <user username="role1" password="tomcat" roles="role1"/>
- </tomcat-users>
阅读(4709) | 评论(0) | 转发(0) |