paulwong

          jboss中控制臺jmx-console 登錄的用戶名和密碼設置

          默認情況訪問 http://localhost:8080/jmx-console 就可以瀏覽jboss的部署管理的一些信息,不需要輸入用戶名和密碼,使用起來有點安全隱患。下面我們針對此問題對jboss進行配置,使得訪問jmx- console也必須要知道用戶名和密碼才可進去訪問。步驟如下:

          i) 找到JBoss安裝目錄/server/default/deploy/jmx-console.war/WEB-INF/jboss-web.xml文 件,去掉<security-domain>java:/jaas/jmx-console</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>


          ii)修改與i)中的jboss-web.xml同級目錄下的web.xml文件,查找到<security-constraint/>節點,去掉它的注釋,修改后該部分內容為:

          <!-- A security constraint that restricts access to the HTML JMX console
             to users with the role JBossAdmin. Edit the roles to what you want and
             uncomment the WEB-INF/jboss-web.xml/security-domain element to enable
             secured access to the HTML JMX console.
          -->
             
          <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>

             在此處可以看出,為登錄配置了角色JBossAdmin。

          iii) 在第一步中的jmx-console安全域和第二步中的運行角色JBossAdmin都是在login-config.xml中配置,我們在JBoss安 裝目錄/server/default/conf下找到它。查找名字為:jmx-console的application-policy:

          <application-policy name = "jmx-console">
                 
          <authentication>
                    
          <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
                       flag 
          = "required">
                     
          <module-option name="usersProperties">props/jmx-console-users.properties</module-option>
                     
          <module-option name="rolesProperties">props/jmx-console-roles.properties</module-option>
                    
          </login-module>
                 
          </authentication>
              
          </application-policy>


          在此處可以看出,登錄的角色、用戶等的信息分別在props目錄下的jmx-console-roles.properties和jmx-console-users.properties文件中設置,分別打開這兩個文件。
          其中jmx-console-users.properties文件的內容如下:

          # A sample users.properties file for use with the UsersRolesLoginModule
          admin
          =admin

          該文件定義的格式為:用戶名=密碼,在該文件中,默認定義了一個用戶名為admin,密碼也為admin的用戶,讀者可將其改成所需的用戶名和密碼。
          jmx-console-roles.properties的內容如下:

          # A sample roles.properties file for use with the UsersRolesLoginModule
          admin
          =JBossAdmin, HttpInvoker

          該文件定義的格式為:用戶名=角色,多個角色以“,”隔開,該文件默認為admin用戶定義了JBossAdmin和HttpInvoker這兩個角色。
          配置完成后讀者可以通過訪問: http://localhost:8088/jmx-console/ ,輸入jmx-console-roles.properties文件中定義的用戶名和密碼,訪問jmx-console的頁面。

          posted on 2012-02-13 11:04 paulwong 閱讀(9558) 評論(0)  編輯  收藏 所屬分類: JBOSS

          主站蜘蛛池模板: 新龙县| 东光县| 福州市| 广汉市| 上思县| 松江区| 丹东市| 镇安县| 定南县| 云梦县| 千阳县| 肇州县| 长沙县| 腾冲县| 五常市| 丰城市| 德兴市| 周口市| 沅江市| 广安市| 依安县| 呼和浩特市| 鹤山市| 合山市| 京山县| 宝鸡市| 三明市| 白河县| 华阴市| 汕头市| 五原县| 甘德县| 自治县| 南昌市| 城固县| 和顺县| 光山县| 临桂县| 彭水| 肥东县| 两当县|