歡迎您光臨本站 註冊首頁

為JBoss控制台加鎖

←手機掃碼閱讀     火星人 @ 2014-03-10 , reply:0

JBoss伺服器可以通過遠程的方式關閉服務,因為默認情況JBoss控制台的用戶密碼都為空,見前一篇文章,看到這個消息后,吃了一驚,因為我們有個東東正在用JBoss做伺服器,測試了一下,確實存在這樣的問題,趕緊照著材料補了一下

我用的JBoss版本是Version: 4.0.4CR2,操作如下

一、為jms-console加上認證

修改JBoss4serverdefaultdeployjmx-console.warWEB-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>

然後修改JBoss4serverdefaultconfprops下的兩個配置文件jmx-console-roles.properties 和jmx-console-users.properties,添加用戶和密碼,搞定上面的配置之後,訪問jms-console就需要認證了,下面繼續 web-console的配置

二、為web-console加上認證

在deploy目錄下面沒有看到web-console,就通過查找,結果找到了兩個地方,分別是

jboss4serverdefaultdeploymanagementconsole-mgr.sarweb-console.war jboss4serveralldeploymanagementconsole-mgr.sarweb-console.war

我也沒搞清楚倒底是哪個起作用,我改了其中一個試試,沒效果,乾脆兩個都改了,改的步驟都是相同的,下面就對其中一個的配置進行說明了

找到 WEB-INF下面的JBoss-web.xml和web.xml,修改的方法同上,去掉兩個註釋

認證的文件放在了 WEB-INFclasses下面,分別是web-console-roles.properties和web-console- users.properties,把用戶的認證信息添加到裡面即可,重新啟動JBoss控制台,此時登錄JBoss控制台會要求輸入密碼,我測試后發現有效的密碼是 default下面的配置,也搞不懂為什麼要兩個都改了才會彈出要求身份認證的對話框

以上是JBoss控制台加鎖,先暫時就記在這裡吧,如果哪位有做深入的研究,希望可以多提意見完善這個文檔


[火星人 ] 為JBoss控制台加鎖已經有798次圍觀

http://coctec.com/docs/java/show-post-61458.html