0 Replies Latest reply on Jul 21, 2005 2:31 PM by Michael Caughey

    Adding SecurityConf to Dynamically created topic

    Michael Caughey Newbie

      I have been able to create a TopicMBean in code but i haven ot been able to get access to it becuase I can not authenticate against it. I would imagine that is becuase it doesn't have a SecurityConf. Here's what I did.

       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;

      How ever I get the following Exception, no protocol [then is spits out the XML I put in the Element].

      Any help?