1 Reply Latest reply on Jul 23, 2005 3:59 PM by Michael Caughey

    Adding SecurityConf to TopicMBean

    Michael Caughey Newbie

      I'm not possitive this is what I need to do but it makes sense. I'm dynamically creating a topic at runtime. It shows up in the jmx-console and is started however when I try to connect to it I get an Exception that states its unable to authenticate. So I added some additonal code that I thought should work, since i cannot find any examples. But now I get and Exception at creation time that states "no protocol : <The contents of my Security node I added>"

      The code is listed below that I used trying to attempt the adding of the SecurityConf Element attribute. i'm adding the code for the complete creation of the topic as well.

       private void registerTopic(String topicname)
       throws MalformedObjectNameException, Exception {
       getTopicObjectName(topicname), "topic/" + topicname);
       private ObjectName getTopicObjectName(String name)
       throws MalformedObjectNameException {
       return new ObjectName("jboss.mq.destination:service=Topic,name=" + name);
       protected void createDestination(String type, ObjectName name,
       String jndiName) throws Exception {
       if (logger.isDebugEnabled()) {
       logger.debug("Attempting to create destination: " + name
       + "; type=" + type);
       MBeanServer server = MBeanServerLocator.locateJBoss();
       server.createMBean(type, name);
       server.setAttribute(name, new Attribute("DestinationManager",
       new ObjectName("jboss.mq:service=DestinationManager")));
       server.setAttribute(name, new Attribute("SecurityManager",
       new ObjectName("jboss.mq:service=SecurityManager")));
       server.setAttribute(name, new Attribute("SecurityConf", getSecurityconf()));
       server.setAttribute(name, new Attribute("JNDIName", jndiName));
       TopicMBean tmb = (TopicMBean)MBeanServerInvocationHandler.newProxyInstance(server, name,TopicMBean.class,false);
       private Element getSecurityconf() throws SAXException, IOException{
       Element el = null;
       StringBuffer securityConfStr = new StringBuffer();
       securityConfStr.append(" <role name=\"publisher\" read=\"true\" write=\"true\" create=\"false\"/>");
       securityConfStr.append(" <role name=\"durpublisher\" read=\"true\" write=\"true\" create=\"true\"/>");
       DOMParser parser = new DOMParser();
       Document doc = parser.getDocument();
       el = doc.getDocumentElement();
       return el;

      Thanks in advance,

      PS I am aware I have a similar post in JMS forum, I realized that I should have probably posted it here. sorry for the cross post.