MBeans Secure Client
akash_bansal Nov 1, 2012 7:26 AMPls. help me.
I have several MBeans packaged as SAR file which are deployed in JBoss 7.1 server. Now I want to invoke their methods in Secure Context. i.e. if any client wants to invoke one of the methods of MBeans calling client should supply credentials. But JBoss 7.1 is letting the client invoke MBeans functions even if client does not provide credentials. Belw is my Client Code:
import java.io.IOException;
import javax.management.AttributeNotFoundException;
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanServerConnection;
import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
import javax.management.ReflectionException;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
public class MBeanClient {
public static void main(String[] args) throws MalformedObjectNameException, NullPointerException, IOException,
AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException,
InstanceAlreadyExistsException, NotCompliantMBeanException {
// code to invoke MBean
JMXServiceURL serviceURL1 = new JMXServiceURL("service:jmx:remoting-jmx://localhost:4447");
JMXConnector jmxConnector1 = JMXConnectorFactory.connect(serviceURL1, null);
MBeanServerConnection connection1 = jmxConnector1.getMBeanServerConnection();
ObjectName mbeanObject = new ObjectName("service.server.monitor:service=MyMonitor");
connection1.invoke(mbeanObject, "updateFrequence", new String[]{"910"}, new String[]{"java.lang.String"});
jmxConnector1.close();
}
}
I have also attached my mbeans code.
-
mbean.zip 7.4 KB