@VisibleForTesting
  void setMBeanServerForwarder(MBeanServer mbs, HashMap<String, Object> env)
      throws IOException {
    if (securityService.isIntegratedSecurity()) {
      JMXShiroAuthenticator shiroAuthenticator = new JMXShiroAuthenticator(securityService);
      env.put(JMXConnectorServer.AUTHENTICATOR, shiroAuthenticator);
      jmxConnectorServer.addNotificationListener(shiroAuthenticator, null,
          jmxConnectorServer.getAttributes());
      // always going to assume authorization is needed as well, if no custom AccessControl, then
      // the CustomAuthRealm should take care of that
      MBeanServerWrapper mBeanServerWrapper = new MBeanServerWrapper(securityService);
      jmxConnectorServer.setMBeanServerForwarder(mBeanServerWrapper);
    } else {
      /* Disable the old authenticator mechanism */
      String pwFile = config.getJmxManagerPasswordFile();
      if (pwFile != null && pwFile.length() > 0) {
        env.put("jmx.remote.x.password.file", pwFile);
      }

      String accessFile = config.getJmxManagerAccessFile();
      if (accessFile != null && accessFile.length() > 0) {
        // Rewire the mbs hierarchy to set accessController
        ReadOpFileAccessController controller = new ReadOpFileAccessController(accessFile);
        jmxConnectorServer.setMBeanServerForwarder(controller);
      } else {
        // if no access control, do not allow mbean creation to prevent Mlet attack
        jmxConnectorServer.setMBeanServerForwarder(new BlockMBeanCreationController());
      }
    }
  }
Gets the hostname that should be set on the RMI server for based on the given values.

@param hostnameForClients the hostname clients will expect to access.
@param hostnameForServer the hostname that this server is bound to.
@param sslEnabled is SSL enabled.
@return {@code hostnameForClients} if not blank, otherwise {@code hostnameForServer} if not
        blank and {@code sslEnabled}, otherwise {@code null}.
geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java