`
damies
  • 浏览: 236455 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

JBOSS的安全配置

阅读更多

jboss默认配置了以下服务:
•  JMX Console
•  JBoss Web Console
为了安全起见,需要用户通过授权进行访问。
一、JMX安全配置
STEP 1:
    找到%JBOSS_HOME%/server/default/deploy/jmx-console.war/WEB-INF/jboss-web.xml文件,根据说明,去掉注释。

xml 代码
  1. <jboss-web>  
  2.    <security-domain>java:/jaas/jmx-console</security-domain>  
  3. </jboss-web>  


<jboss-web></jboss-web>STEP 2:
    与jboss-web.xml同级目录下还有一个文件web.xml,找到其中的<security-constraint></security-constraint>节点,根据说明,取消注释。

xml 代码
  1. <security-constraint>  
  2.      <web-resource-collection>  
  3.        <web-resource-name>HtmlAdaptor</web-resource-name>  
  4.        <description>An example security config that only allows users with the   
  5.          role JBossAdmin to access the HTML JMX console web application   
  6.        </description>  
  7.        <url-pattern>/*</url-pattern>  
  8.        <http-method>GET</http-method>  
  9.        <http-method>POST</http-method>  
  10.      </web-resource-collection>  
  11.      <auth-constraint>  
  12.        <role-name>JBossAdmin</role-name>  
  13.      </auth-constraint>  
  14. </security-constraint>  


STEP 3:
    在第一步中的jmx-console安全域和第二步中的运行角色JBossAdmin都是在login-config.xml中配置,我们在%

xml 代码
  1. <application-policy name = "jmx-console">  
  2.        <authentication>  
  3.           <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"  
  4.              flag = "required">  
  5.            <module-option name="usersProperties">props/jmx-console-users.properties</module-option>  
  6.            <module-option name="rolesProperties">props/jmx-console-roles.properties</module-option>  
  7.           </login-module>  
  8.        </authentication>  
  9.     </application-policy>  


文件props/jmx-console-users.properties定义了用户名、密码;props/jmx-console-roles.properties定义了用户所属角色,找

二、WEB-CONSOLE的安全配置
STEP 1:
找到%JBOSS_HOME%/server/default/deploy/ management/console-mgr.sar/web-console.war/WEB-INF/jboss-web.xml文件,根据说明,去掉注释。

  1. <jboss-web>  
  2.    <depends>jboss.admin:service=PluginManager</depends>  
  3. </jboss-web>  


STEP 2:
与jboss-web.xml同级目录下还有一个文件web.xml,找到其中的<security-constraint></security-constraint>节点,根据说明,取消注释。

xml 代码
  1. <security-constraint>  
  2.    <web-resource-collection>  
  3.    <web-resource-name>HtmlAdaptor</web-resource-name>  
  4.    <description>An example security config that only allows users with the   
  5.    role JBossAdmin to access the HTML JMX console web application   
  6.    </description>  
  7.    <url-pattern>/*</url-pattern>  
  8.    <http-method>GET</http-method>  
  9.    <http-method>POST</http-method>  
  10.    </web-resource-collection>  
  11.    <auth-constraint>  
  12.    <role-name>JBossAdmin</role-name>  
  13.    </auth-constraint>  
  14.    </security-constraint>  


STEP 3:
在本目录的classes文件夹下找到web-console-users.properties和web-console-roles.properties两个文件更名为:

xml 代码
  1. <application-policy name = "web-console">  
  2.        <authentication>  
  3.           <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"  
  4.              flag = "required">  
  5.              <module-option name="usersProperties">users.properties</module-option>  
  6.              <module-option name="rolesProperties">roles.properties</module-option>  
  7.           </login-module>  
  8.        </authentication>  
  9. </application-policy>  


启动服务输入http://localhost:8080/
 然后分别点击JMX Console以及Jboss Web Console测试安全机制

user.properties和role.propertie并修改users.properties其中的用户名和密码修改%JBOSS_HOME%/server/default/conf/login-config.xml中web-console节点修改为以下:
<application-policy name="web-console"></application-policy>到后自行修改或重新定义用户名、密码。JBOSS_HOME%/server/default/config下找到它。查找名字为:jmx-console的application-policy:
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics