This topic describes how to develop a Java™ Management Extensions (JMX) client application that can access the secured REST connector of the Liberty profile.
Using a JMX remote client application, you can administer the Liberty profile through JMX programming.
import javax.management.remote.JMXServiceURL;
import javax.management.MBeanServerConnection;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import java.util.HashMap;
public class Test {
public static void main(String[] args) {
System.setProperty("javax.net.ssl.trustStore", <truststore location>);
System.setProperty("javax.net.ssl.trustStorePassword", <truststore password>);
//If the type of the trustStore is not jks, which is default,
//set the type by using the following line.
System.setProperty("javax.net.ssl.trustStoreType", <truststore type>);
try {
HashMap<String, Object> environment = new HashMap<String, Object>();
environment.put("jmx.remote.protocol.provider.pkgs", "com.ibm.ws.jmx.connector.client");
environment.put(JMXConnector.CREDENTIALS, new String[] { "bob", "bobpassword" });
JMXServiceURL url = new JMXServiceURL("service:jmx:rest://<host>:<port>/IBMJMXConnectorREST");
JMXConnector connector = JMXConnectorFactory.newJMXConnector(url, environment);
connector.connect();
MBeanServerConnection mbsc = connector.getMBeanServerConnection();
} catch(Throwable t) {
...
}
}
}
HashMap<String, Object> environment = new HashMap<String, Object>();
environment.put("jmx.remote.protocol.provider.pkgs", "com.ibm.ws.jmx.connector.client");
environment.put("com.ibm.ws.jmx.connector.client.disableURLHostnameVerification", Boolean.TRUE);
environment.put(JMXConnector.CREDENTIALS, new String[] { "bob", "bobpassword" });
...
...
HashMap<String, Object> environment = new HashMap<String, Object>();
environment.put("com.ibm.ws.jmx.connector.client.rest.maxServerWaitTime", 0);
environment.put("com.ibm.ws.jmx.connector.client.rest.notificationDeliveryInterval", 65000);
...