下午看到一篇文章,說是JBOSS服務(wù)器可以通過遠(yuǎn)程的方式關(guān)閉服務(wù),因?yàn)槟J(rèn)情況控制臺(tái)的用戶密碼都為空,見前一篇文章,看到這個(gè)消息后,吃了一驚,因?yàn)槲覀冇袀€(gè)東東正在用JBOSS做服務(wù)器,測(cè)試了一下,確實(shí)存在這樣的問題,趕緊照著材料補(bǔ)了一下
我用的JBOSS版本是Version: 4.0.4CR2,操作如下
一、為jms-console加上認(rèn)證
修改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下的兩個(gè)配置文件jmx-console-roles.properties和jmx-console-users.properties,添加用戶和密碼,搞定上面的配置之后,訪問jms-console就需要認(rèn)證了,下面繼續(xù)web-console的配置
二、為web-console加上認(rèn)證
在deploy目錄下面沒有看到web-console,就通過查找,結(jié)果找到了兩個(gè)地方,分別是
jboss4\server\default\deploy\management\console-mgr.sar\web-console.war\
jboss4\server\all\deploy\management\console-mgr.sar\web-console.war\
我也沒搞清楚倒底是哪個(gè)起作用,我改了其中一個(gè)試試,沒效果,干脆兩個(gè)都改了,改的步驟都是相同的,下面就對(duì)其中一個(gè)的配置進(jìn)行說明了
找到 WEB-INF\下面的jboss-web.xml和web.xml,修改的方法同上,去掉兩個(gè)注釋
認(rèn)證的文件放在了 WEB-INF\classes\下面,分別是web-console-roles.properties和web-console-users.properties,把用戶的認(rèn)證信息添加到里面即可,重新啟動(dòng)JBOSS,此時(shí)登錄控制臺(tái)會(huì)要求輸入密碼,我測(cè)試后發(fā)現(xiàn)有效的密碼是default下面的配置,也搞不懂為什么要兩個(gè)都改了才會(huì)彈出要求身份認(rèn)證的對(duì)話框
先暫時(shí)就記在這里吧,如果哪位有做深入的研究,希望可以多提意見完善這個(gè)文檔