标签:
jboss-as-7.1.1.Final\standalone\configuration:
1, standalone.xml中 <security-domains>标签里面添加:
<security-domain name="myRealm" cache-type="default">
<authentication>
<login-module code="Remoting" flag="required">
<module-option name="usersProperties" value="${jboss.server.config.dir}/application-users.properties"/>
<module-option name="rolesProperties" value="${jboss.server.config.dir}/application-roles.properties"/>
<module-option name="realm" value="ApplicationRealm"/>
<module-option name="password-stacking" value="useFirstPass"/>
</login-module>
</authentication>
</security-domain>
使用application-users.properties,application-roles.properties中定义的用户和角色。
2,在war中 WEB-INF 中加入文件 jboss-web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<security-domain>java:/jaas/myRealm</security-domain>
</jboss-web>
3,在 web.xml中加入:
<security-constraint>
<display-name>Example Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>guest</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>myRealm</realm-name>
</login-config>
<security-role>
<description> A user </description>
<role-name>guest</role-name>
</security-role>
参考:
http://blog.sina.com.cn/s/blog_7253d65401018syh.html
http://www.cnblogs.com/davidwang456/p/3897684.html
标签:
原文地址:http://www.cnblogs.com/bigben0123/p/4776474.html