為JBoss控制臺加鎖
JBoss服務(wù)器可以通過遠(yuǎn)程的方式關(guān)閉服務(wù),因為默認(rèn)情況JBoss控制臺的用戶密碼都為空,見前一篇文章,看到這個消息后,吃了一驚,因為我們有個東東正在用JBoss做服務(wù)器,測試了一下,確實存在這樣的問題,趕緊照著材料補了一下
我用的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下的兩個配置文件jmx-console-roles.properties 和jmx-console-users.properties,添加用戶和密碼,搞定上面的配置之后,訪問jms-console就需要認(rèn)證了,下面繼續(xù) web-console的配置
二、為web-console加上認(rèn)證
在deploy目錄下面沒有看到web-console,就通過查找,結(jié)果找到了兩個地方,分別是
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,修改的方法同上,去掉兩個注釋
認(rèn)證的文件放在了 WEB-INF\classes\下面,分別是web-console-roles.properties和web-console- users.properties,把用戶的認(rèn)證信息添加到里面即可,重新啟動JBoss控制臺,此時登錄JBoss控制臺會要求輸入密碼,我測試后發(fā)現(xiàn)有效的密碼是 default下面的配置,也搞不懂為什么要兩個都改了才會彈出要求身份認(rèn)證的對話框
以上是JBoss控制臺加鎖,先暫時就記在這里吧,如果哪位有做深入的研究,希望可以多提意見完善這個文檔
【編輯推薦】