if (connectorServer != null) {
return;
}
if (mbs == null) {
throw new BrokerException(rb.getString(rb.X_JMX_CANT_CREATE_CONNECTOR_SVR, name));
}
useSSL = config.getBooleanProperty(CONNECTOR_PROPBASE
+ name
+ SSL_SUFFIX, false);
/*
* Query property that specifies if the broker is to be trusted.
* If this property is not set, by default the broker is *not*
* trusted.
*/
brokerHostTrusted = config.getBooleanProperty(CONNECTOR_PROPBASE
+ name
+ BROKER_HOST_TRUSTED_SUFFIX, false);
backlog = config.getIntProperty(CONNECTOR_PROPBASE
+ name
+ BACKLOG_SUFFIX, 0);
try {
/*
* We only support the RMI protocol in MQ 4.0
*/
if (configuredURL.getProtocol().equals("rmi")) {
boolean useAuth = true;
if (useAuth) {
env.put(JMXConnectorServer.AUTHENTICATOR, new MQJMXAuthenticator(this));
}
/*
* Use MQ specific server socket factory only if:
* - SSL is enabled
* - need to specify a specific host/IP on a multihome system
*/
if ((useSSL) ||
(jmxHostname != null && !jmxHostname.equals(Globals.HOSTNAME_ALL))) {
MQRMIServerSocketFactory ssf
= new MQRMIServerSocketFactory(jmxHostname, backlog, useSSL);
env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE,
ssf);
}
/*
* Use MQ specific client socket factory only if:
* - need to specify a specific host/IP on a multihome system
*/
if (jmxHostname != null && !jmxHostname.equals(Globals.HOSTNAME_ALL)) {
MQRMIClientSocketFactory csf
= new MQRMIClientSocketFactory(jmxHostname,
brokerHostTrusted, useSSL);
env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE,
csf);
} else {
/*
* Use MQ specific client socket factory only if:
* - SSL is enabled and brokerHostTrusted is true
* If brokerHostTrusted is false, use the JDK provided
* javax.rmi.ssl.SslRMIClientSocketFactory
*/
if (useSSL) {
if (brokerHostTrusted) {
MQRMIClientSocketFactory csf
= new MQRMIClientSocketFactory(jmxHostname,
brokerHostTrusted, useSSL);
env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE,
csf);
} else {
env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE,
new javax.rmi.ssl.SslRMIClientSocketFactory());
}
}
}
}
cs = JMXConnectorServerFactory.newJMXConnectorServer(configuredURL, env, mbs);
} catch (Exception e) {
throw new BrokerException(rb.getString(rb.W_JMX_ERROR_CREATING_CONNECTOR,
name), e);
}
cs.addNotificationListener(listener, null, this);