进入JBOSS管理员控制台,需要管理员账号和密码,初次使用JBOSS的时候就需要进行一些设定。 

以jboss-5.1.0.GA为例:

  1. 修改%JBOSS_HOME%\server\default\deploy\jmx-console.war\WEB-INF\jboss-web.xml文件的内容,取消注释:
  1. <jboss-web> 
  2.    <!-- Uncomment the security-domain to enable security. You will 
  3.       need to edit the htmladaptor login configuration to setup the 
  4.       login modules used to authentication users. 
  5.    --> 
  6.       <security-domain>java:/jaas/jmx-console</security-domain> 
  7.     
  8. </jboss-web> 
修改%JBOSS_HOME%\server\default\deploy\jmx-console.war\WEB-INF\web.xml文件的内容,取消注释:
  1. <!-- A security constraint that restricts access to the HTML JMX console 
  2. to users with the role JBossAdmin. Edit the roles to what you want and 
  3. uncomment the WEB-INF/jboss-web.xml/security-domain element to enable 
  4. secured access to the HTML JMX console. 
  5. --> 
  6. <security-constraint> 
  7.   <web-resource-collection> 
  8.     <web-resource-name>HtmlAdaptor</web-resource-name> 
  9.     <description>An example security config that only allows users with the 
  10.       role JBossAdmin to access the HTML JMX console web application 
  11.     </description> 
  12.     <url-pattern>/*</url-pattern> 
  13.     <http-method>GET</http-method> 
  14.     <http-method>POST</http-method> 
  15.   </web-resource-collection> 
  16.   <auth-constraint> 
  17.     <role-name>JBossAdmin</role-name> 
  18.   </auth-constraint> 
  19. </security-constraint> 
角色JBossAdmin是在%JBOSS_HOME%\server\default\conf\login-config.xml中配置的:
  1. <!-- A template configuration for the jmx-console web application. This 
  2.   defaults to the UsersRolesLoginModule the same as other and should be 
  3.   changed to a stronger authentication mechanism as required. 
  4. --> 
  5. <application-policy name="jmx-console"> 
  6.   <authentication> 
  7.     <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" 
  8.       flag="required"> 
  9.       <module-option name="usersProperties">props/jmx-console-users.properties</module-option> 
  10.       <module-option name="rolesProperties">props/jmx-console-roles.properties</module-option> 
  11.     </login-module> 
  12.   </authentication> 
  13. </application-policy> 
props/jmx-console-roles.properties文件的格式是,用户名=角色,多个角色以逗号分开:
  1. admin=JBossAdmin,HttpInvoker 
文件格式是,用户名=密码
  1. adminadmin=admin