1. 为jms-console加上认证
(1) 修改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>
(2) 修改jboss4\server\default\conf\props下的两个配置文件jmx-console-roles.properties和jmx-console-users.properties,添加或修改用户和密码
2. 为web-console加上认证
(1) 修改jboss4\server\default\deploy\management\console-mgr.sar\web-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/web-console</security-domain> </jboss-web>
(2) 修改jboss4\server\default\deploy\management\console-mgr.sar\web-console.war\WEB-INF\classes
下的两个配置文件web-console-roles.properties和web-console-users.properties,添加或修改用户和密码
注:修改了用户名后,jmx-console-roles.properties和web-console-roles.properties 里面Role 对应的用户名也要修改;如果不对应进行修改是登录不了的。