`
hxsmile
  • 浏览: 60192 次
  • 性别: Icon_minigender_1
  • 来自: 广州
文章分类
社区版块
存档分类
最新评论

jboss中 web-console 登录的用户名和密码设置

 
阅读更多

E:\tools\jboss-5.1.0.GA\jboss-5.1.0.GA\server\default\deploy\management\console-mgr.sar\web-console.war\WEB-INF


web-console 登录的用户名和密码设置
默认情况下,用户访问JBoss的web-console时,不需要输入用户名和密码,为了安全起见,我们通过修改配置来为其加上用户名和密码。步骤如下:
i)找到JBoss安装目录"server"default"deploy"management"console-mgr.sar"web-console.war"WEB-INF"jboss-web.xml文件,去掉<security-domain>java:/jaas/web-console</security-domain>的注释,修改后的文件内容为:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE jboss-web
    PUBLIC "-//JBoss//DTD Web Application 2.3V2//EN"
    "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">
<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>
   <!-- The war depends on the -->
   <depends>jboss.admin:service=PluginManager</depends>
</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>
iii)打开JBoss安装目录"server"default"conf下的login-config.xml文件,搜索web-console,可找到如下内容:
<application-policy name = "web-console">
       <authentication>
          <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
             flag = "required">
             <module-option name="usersProperties">web-console-users.properties</module-option>
             <module-option name="rolesProperties">web-console-roles.properties</module-option>
          </login-module>
       </authentication>
    </application-policy>
在文件中可以看到,设置登录web-console的用户名和角色等信息分别在login-config.xml文件所在目录下的web-console-users.properties和web-console-roles.properties文件中,但因为该目录下无这两个文件,我们在JBoss安装目录"server"default"conf"props目录下建立这两个文件,文件内容可参考在“jmx-console登录的用户名和密码设置”中的两个相应的配置文件的内容,web-console-users.properties文件的内容如下:
# A sample users.properties file for use with the UsersRolesLoginModule
admin=admin
web-console-roles.properties文件的内容如下:
# A sample roles.properties file for use with the UsersRolesLoginModule
admin=JBossAdmin,HttpInvoker
因为此时这两个文件不与login-config.xml同目录,所以login-config.xml文件需进行少许修改,修改后的<application-policy name = "web-console">元素的内容为:
<application-policy name = "web-console">
       <authentication>
          <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
             flag = "required">
             <module-option name="usersProperties">props/web-console-users.properties</module-option>
             <module-option name="rolesProperties">props/web-console-roles.properties</module-option>
          </login-module>
       </authentication>
    </application-policy>
分享到:
评论
1 楼 hxsmile 2012-02-01  
JBoss设置
  1.隐藏访问目录
  jboss_home/server/default/deploy/jbossweb-tomcat55.sar/conf/web.xml
  <param-name>listings</param-name>
  <param-value>false</param-value>
  2.设置JMX-Console控制台密码
  因为即使用防火墙将8080端口屏蔽,别有用心的用户也可以通过http://your_domain/JMX-Console进行访问,修改如下
  JBOSS_HOME/server/default/deploy/jmx-console.war/WEB-INF/
  web.xml  取消 <security-constraint>这段注释
  jboss-web.xml 取消  <security-domain> 这段注释
  JBOSS_HOME/server/default/conf/props
  jmx-console-users.properties   修改 admin=admin  设置用户名=设置密码
  jmx-console-roles.properties   修改 admin 改为  上面设置的用户名
  3、设置web-console的控制台密码:
  JBOSS_HOME/server/default/deploy/management/console-mgr.sar/web-console.war/WEB-INF/
  web.xml  取消 <security-constraint>这段注释
  jboss-web.xml 取消  <security-domain> 这段注释
  cd ../class
  web-console-roles.properties  修改 admin 改为  上面设置的用户名
  web-console-users.properties 修改 admin=admin  设置用户名=设置密码
  将以上两个文件拷贝到 JBOSS_HOME/server/default/conf/props
  vi JBOSS_HOME/server/default/conf/login-config.xml
  找到
  <application-policy name = "web-console">
  <authentication>
  <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
  flag = "required">
  <module-option name="usersProperties">props/web-console-users.properties</module-option>
  <module-option name="rolesProperties">props/web-console-roles.properties</module-option>
  </login-module>
  </authentication>
  </application-policy>
  4.修改jboss_home/server/default/conf/jboss-service.xml
  将<!-- A flag to disable the scans -->
  <attribute name="ScanEnabled">true</attribute> 将true改为false
  到这里,完成JBoss控制台密码的设置。这样设置一方面可以提高性能,另一方面及时JBoss应用被修改,也不会马上生效,有利有弊

相关推荐

Global site tag (gtag.js) - Google Analytics