posts - 2, comments - 27, trackbacks - 0, articles - 60
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

为JBOSS的远程控制台加锁

Posted on 2009-04-10 17:01 ZhouFeng 阅读(526) 评论(0)  编辑  收藏 所属分类: 原创Web服务器
下午看到一篇文章,说是JBOSS服务器可以通过远程的方式关闭服务,因为默认情况控制台的用户密码都为空,见前一篇文章,看到这个消息后,吃了一惊,因为我们有个东东正在用JBOSS做服务器,测试了一下,确实存在这样的问题,赶紧照着材料补了一下
我用的JBOSS版本是Version: 4.0.4CR2,操作如下
一、为jms-console加上认证
修改jboss4\server\default\deploy\jmx-console.war\WEB-INF下的web.xml和jboss-web.xml
在web.xml中把<security-constraint>的注释去掉
   <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>
在jboss-web.xml中把<security-domain>注释去掉
<jboss-web>
   
<!-- Uncomment the security-domain to enable security. You will
      need to edit the htmladaptor login configuration to setup the
      login modules used to authentication users.
   
-->
      
<security-domain>java:/jaas/jmx-console</security-domain>
</jboss-web>
然后修改jboss4\server\default\conf\props下的两个配置文件jmx-console-roles.properties和jmx-console-users.properties,添加用户和密码,搞定上面的配置之后,访问jms-console就需要认证了,下面继续web-console的配置
二、为web-console加上认证
在deploy目录下面没有看到web-console,就通过查找,结果找到了两个地方,分别是
jboss4\server\default\deploy\management\console-mgr.sar\web-console.war\
jboss4\server\all\deploy\management\console-mgr.sar\web-console.war\
我也没搞清楚倒底是哪个起作用,我改了其中一个试试,没效果,干脆两个都改了,改的步骤都是相同的,下面就对其中一个的配置进行说明了
找到 WEB-INF\下面的jboss-web.xml和web.xml,修改的方法同上,去掉两个注释
认证的文件放在了 WEB-INF\classes\下面,分别是web-console-roles.properties和web-console-users.properties,把用户的认证信息添加到里面即可,重新启动JBOSS,此时登录控制台会要求输入密码,我测试后发现有效的密码是default下面的配置,也搞不懂为什么要两个都改了才会弹出要求身份认证的对话框
先暂时就记在这里吧,如果哪位有做深入的研究,希望可以多提意见完善这个文档


只有注册用户登录后才能发表评论。


网站导航: