当前位置: 首页 > 知识库问答 >
问题:

在JBoss 5.1.0.GA中保护JMXConnectorServerService(jmx remoting.sar)

闻修筠
2023-03-14

我一直在试图理解如何保护JBoss 5.1.0.GA默认提供的JMXConnectorServerService。

目前,如果我将以下URL粘贴到JConsole中,我可以直接访问JMX而无需任何身份验证:service: jmx: rmi://jndi/rmi://: 1290/jmxconnect

然后我这样做是为了保护我的JMXInvoker,希望这能保护所有JMX访问:http://objectopia.com/2009/10/01/securing-jmx-invoker-layer-in-jboss/

但是,很明显,这不适用于JMXConnectorServerService。我仍然可以使用上面的服务URL通过jsole访问JMX。

然后我发现这个功能要求还没有得到满足:https://issues.jboss.org/browse/JBAS-8159

现在,目前我不担心疯狂的安全措施。这个URL不会被暴露在外部网络中。所以,我只想看看使用“jmx控制台”安全域保护jmx-remoting.sar的最简单方法是什么?

我可以切换到默认的MBean服务器,但显然,在5.1.0.GA中,这很痛苦:https://community.jboss.org/thread/153594

我非常感谢在这方面的任何意见。

谢啦!

共有1个答案

严书
2023-03-14

我不认为该服务是安全的,但有一个补丁。

对于一个稍微简单的版本,我在这里冒险,因为我还没有在AS 5上测试过这个,但是我把它反向移植到AS 4,它工作正常。

我不确定你有哪个版本,但让我们假设它是这个版本。EAP版本有一个稍微复杂的版本,但前提是相同的。您需要扩展JMXConnectorServerService和JMXConnectorServerServiceMBean。

在此实现中,创建服务器的代码如下所示:

// create new connector server and start it
connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbeanServer);

在您的扩展中,添加以下内容:

/** The name of the JAAS domain to use for authentication */
protected String jaasDomain = null; 
...
/**
   * Returns the name of the JAAS domain to use for authentication
   * @return the name of a JAAS Domain
   */
public String getJaasDomain() {
   return jaasDomain;
}

/**
  * Sets the name of the JAAS domain to use for authentication
  * @param jaasDomain the JAAS Domain to use for authentication
  */
public void setJaasDomain(String jaasDomain) {
   this.jaasDomain = jaasDomain;
}

现在您需要重新实现start方法,该方法添加了一个包含要进行身份验证的JAAS域名的环境。

   public void start() throws Exception
   {
      // the address to expose in the urls
      String host = System.getProperty("java.rmi.server.hostname");

      // check to see if registry already created
      rmiRegistry = LocateRegistry.getRegistry(host, registryPort);
      if (rmiRegistry != null)
      {
         try
         {
            rmiRegistry.list();
         }
         catch(RemoteException e)
         {
            log.debug("No registry running at host '" + host +
                  "', port '" + registryPort + "'.  Will create one.");
            rmiRegistry = LocateRegistry.createRegistry(registryPort, null, new DefaultSocketFactory(bindAddress));
         }
      }
      else
      {
         rmiRegistry = LocateRegistry.createRegistry(registryPort, null, new DefaultSocketFactory(bindAddress));
      }

      String serviceURL = "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + registryPort + jndiPath;

      JMXServiceURL url = new JMXServiceURL(serviceURL);

      // create new connector server and start it
      // ==== NEW AUTH CODE HERE ====
      final Map<String, Object> environment = new HashMap<String, Object>();
      environment.put("jmx.remote.x.login.config", jaasDomain);
      connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, environment, mbeanServer);
      // ==== NEW AUTH CODE ENDS ====
      connectorServer.start();

      log.info("JMX Connector server: " + serviceURL);
   }

您可以选择如下方式验证JAAS名称:

/**
 * Validates the name of the passed JAAS domain. 
 * If the name is not valid, a RuntimeException will the thrown.
 * @param domain The name of the JAAS domain to validate.
 */
private void validateJaasDomain(String domain) {
    try {
        new LoginContext(domain);
    } catch (Exception e) {
        throw new RuntimeException("The JAAS Domain [" + domain + "] could not be loaded", e);
    }
}

将jaasDomain属性添加到新的MBean接口:

/**
 * Returns the name of the JAAS domain to use for authentication
 * @return the name of a JAAS Domain
 */
public String getJaasDomain();

/**
 * Sets the name of the JAAS domain to use for authentication
 * @param jaasDomain the JAAS Domain to use for authentication
 */
public void setJaasDomain(String jaasDomain);

假设您的新impl是com.vijay。JMXConnectorServerService和新的MBean是com.vijay。JMXConnectorServerServiceMBean;您的部署描述符如下所示:(使用jmx控制台jaas域,因为您可能已经得到了保护……)

<!-- ======================================================== -->
<!-- Example Vijay JMX Remoting Service Configuration file        -->
<!-- ======================================================== -->
<server>

   <mbean code="com.vijay.JMXConnectorServerService"
      name="jboss.remoting:service=JMXConnectorServer,protocol=rmi"
      display-name="JMX Connector Server (RMI)">
           <attribute name="BindAddress">
               <!-- Get the port from the ServiceBindingManager -->
               <value-factory bean="ServiceBindingManager" method="getStringBinding" 
                  parameter="jboss.remoting:service=JMXConnectorServer,protocol=rmi"/>
            </attribute>
            <!-- if comment this out, will use 1099 as default and will conflict -->
            <!-- with default JNP (JNDI) port. -->
            <attribute name="RegistryPort">
               <!-- Get the port from the ServiceBindingManager -->
               <value-factory bean="ServiceBindingManager" method="getIntBinding" 
                  parameter="jboss.remoting:service=JMXConnectorServer,protocol=rmi"/>
            </attribute>
            <!-- the path to which will be bound in rmi registry -->
            <!-- the commented value below is the default. -->
            <!-- <attribute name="JndiPath">/jmxconnector</attribute> -->
            <attribute name="JaasDomain">jmx-console</attribute>
   </mbean>
</server>

我只有这些了。我希望它对你有用。

 类似资料:
  • 我正在JBoss-AS7下开发一个RESTeasy JSON API。 null 现在我想保护这两个人;RESTeasy API和Web服务器。 让我说说我的结构: 我用用户名-密码将用户保存在数据库中。目前只有这些用户。 我有一个登录页面来验证我的用户(我不想弹出http basic auth和任何解决方案) REST API的客户机是浏览器(而不是web服务器)。加载静态页面,然后通过REST

  • 问题内容: 我正在使用Golang来构建API Rest。我有一个包含很多字段的结构(超过100个),因此我使用了来自客户端的值来分配给该结构,效果很好。 现在,我要避免用户在任何字符串字段中插入Javascript代码,在结构中我定义了bool,strings,byte []和int值。因此,现在我想知道验证这一点的最佳方法是什么。 我正在考虑仅在字符串字段中对结构进行interate并进行如下

  • 问题内容: 在这个问题中,Erik需要在Node.js中生成一个安全的随机令牌。有一种生成随机缓冲区的方法。但是,node中的base64编码不是网址安全的,它包含和而不是和。因此,我发现生成这种令牌的最简单方法是 有没有更优雅的方式? 问题答案: 尝试crypto.randomBytes(): “十六进制”编码在节点v0.6.x或更高版本中有效。

  • 问题内容: 我正在使用基于Node.js的https服务器,该服务器使用HTTP Basic进行身份验证(这很好,因为数据是通过SSL加密连接发送的)。 现在我想提供一个Socket.io连接 加密和 仅适用于经过身份验证的用户。 问题是如何做到这一点。我已经发现在连接到套接字时需要在客户端JavaScript代码中指定,但是如何在服务器端强制套接字连接只能在SSL上运行,并且仅适用于经过身份验证

  • 问题内容: JKS(Java密钥存储)文件是否已加密?它们是否为加密密钥提供全面保护,还是我仅需要依赖访问控制? 有没有办法确保密钥受到保护? 我对详细的细节感兴趣,包括算法,密钥管理等。这些可配置的任何一个吗? 问题答案: 它们已加密。 该算法取决于提供者。提供者将根据密码返回密钥/证书。如果需要强安全性,请找到使用强加密的密钥库提供程序。

  • 简介 Laravel 可以轻松地保护应用程序免受 跨站点请求伪造 (CSRF) 攻击,跨站点请求伪造是一种恶意攻击,它凭借已通过身份验证的用户身份来运行未经过授权的命令。 Laravel 会自动为每个活跃用户的会话生成一个 CSRF「令牌」。该令牌用于验证经过身份验证的用户是否是向应用程序发出请求的用户。 无论何时,当您在应用程序中定义HTML表单时,都应该在表单中包含一个隐藏的CSRF标记字段,