我正在从事由以下人员编写的项目纯jsps(脚本)不使用任何框架。
jboss版本:jboss-as-7.1.0.Final
我现在正在尝试在其上添加简单的身份验证。因此,当用户尝试浏览 jsp 时,比如说,http://localhost/myContextPath/hello.jsp
,它需要先登录。
web.xml
<security-constraint>
<web-resource-collection>
<web-resource-name>All Access</web-resource-name>
<url-pattern>/*</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>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
jboss-web.xml
<jboss-web>
<security-domain>other</security-domain>
</jboss-web>
standalone.xml([jboss_home]\standalone\configuration 文件夹)
<subsystem xmlns="urn:jboss:domain:security:1.1">
<security-domains>
<security-domain name="other" cache-type="default">
<authentication>
<login-module code="UsersRoles" flag="required">
<module-option name="usersProperties" value="users.properties"/>
<module-option name="rolesProperties" value="roles.properties"/>
</login-module>
</authentication>
</security-domain>
<security-domain name="form-auth">
<authentication>
<login-module code="UsersRoles" flag="required">
<module-option name="usersProperties" value="users.properties"/>
<module-option name="rolesProperties" value="roles.properties"/>
</login-module>
</authentication>
</security-domain>
</security-domains>
</subsystem>
users.properties(放在webapp的classes文件夹下)
user1=jboss7
Roles.properties(放在webapp的classes文件夹下)
user1=Admin
完成所有这些修改后,我尝试浏览我的 hello jsp。我像往常一样工作。没有认证,也不例外。
我不确定我是否朝着正确的方向前进,或者安全约束是完全不同的事情。
请帮忙,谢谢!!!