JBOSS的安全配置

一、JMX安全配置
1: 找到%JBOSS_HOME%/server/default/deploy/jmx-console.war/WEB-INF/jboss-web.xml文件,去掉对下面这段xml文本的注释。

<jboss-web> 
<security-domain>java:/jaas/jmx-console</security-domain>
</jboss-web>

2: 与jboss-web.xml同级目录下还有一个文件web.xml,找到下面这段xml文本,取消注释。

<security-constraint> 
<web-resource-collection>
<web-resource-name>HtmlAdaptor</web-resource-name>
<description>An example security config that only allows users with the
role JBossAdmin to access the HTML JMX console web application
</description>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>JBossAdmin</role-name>
</auth-constraint>
</security-constraint>

3: 在第一步中的jmx-console安全域和第二步中的运行角色JBossAdmin都是在login-config.xml中配置,我们在 % JBOSS_HOME%/server/default/conf/login-config.xml文件可以看到以下配置,

<application-policy name = "jmx-console"> 
<authentication>
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
flag = "required">
<module-option name="usersProperties">props/jmx-console-users.properties</module-option>
<module-option name="rolesProperties">props/jmx-console-roles.properties</module-option>
</login-module>
</authentication>
</application-policy>


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

注:
jmx-console-users.properties 格式是:用户名=密码明文
jmx-console-roles.properties 格式是:用户名=角色1,角色2,角色3

可以找到这两个文件,修改用户名和密码。

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

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

2:
与jboss-web.xml同级目录下还有一个文件web.xml,找到下面这段xml文本,取消注释。

<security-constraint> 
<web-resource-collection>
<web-resource-name>HtmlAdaptor</web-resource-name>
<description>An example security config that only allows users with the
role JBossAdmin to access the HTML JMX console web application
</description>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>JBossAdmin</role-name>
</auth-constraint>
</security-constraint>


3:
% JBOSS_HOME%/server/default/conf/login-config.xml文件可以看到以下配置:

<application-policy name = "web-console"> 
<authentication>
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
flag = "required">
<module-option name="usersProperties">web-console-users.properties</module-option>
<module-option name="rolesProperties">web-console-roles.properties</module-option>
</login-module>
</authentication>
</application-policy>


上面提到的两个文件在%JBOSS_HOME%/server/default/deploy/ management/console-mgr.sar/web-console.war/WEB-INF/classes文件夹下,你可以修改其中的用户名和密码,格式和上面的两个properties文件中的一样。

启动服务输入http://localhost:8080/jmx-console 和http://localhost:8080/web-console测试安全机制 。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值