1 Reply Latest reply on Jul 27, 2015 12:04 PM by sridhar thiyagarajan

    How to fetch security domains defined in standalone-full-ha.xml in Wildfly 8.2.0 by coding

    sridhar thiyagarajan Novice

      Hello,

       

      I am migrating my application from JBoss 6 AS to Wildfly 8.2.0 AS. In JBoss 6 AS, PFB the code snippet which gives XMLLoginConfigMBean object from which list of security domains configured for applications can be obtained utilizing login-config.xml.

       

      (XMLLoginConfigMBean) MBeanServerInvocationHandler

                      .newProxyInstance(

                              ManagementFactory.getPlatformMBeanServer(),

                              new ObjectName("jboss.security:service=XMLLoginConfig",

                              XMLLoginConfigMBean.class,

                              false);

       

      Similarly, in Wildfly 8.2.0 AS, I found one equivalent class XMLLoginConfigImpl and I am trying to get all security domains configured for application using the below code snippet.

       

       

      (XMLLoginConfigImpl) MBeanServerInvocationHandler

                      .newProxyInstance(

                              ManagementFactory.getPlatformMBeanServer(),

                              new ObjectName("jboss.as:subsystem=security"),

                              XMLLoginConfigImpl.class,

                              false);

       

      Note: I have highlighted the MBeans object name in bold in the code snippets and this functionality is to fetch security domain attributes.

       

      But, I am getting the error - java.lang.IllegalArgumentException - javax.management.NotCompliantMBeanException: Not an interface: org.jboss.security.auth.login.XMLLoginConfigImpl.

       

      java.lang.IllegalArgumentException - javax.management.NotCompliantMBeanException: Not an interface: org.jboss.security.auth.login.XMLLoginConfigImpl

         at javax.management.JMX.createProxy(JMX.java:404)

         at javax.management.JMX.newMBeanProxy(JMX.java:208)

         at javax.management.MBeanServerInvocationHandler.newProxyInstance(MBeanServerInvocationHandler.java:234)

       

      Could anyone please help me about how to retrieve list of security domains configured in standalone-full-ha.xml by code.

        • 1. Re: How to fetch security domains defined in standalone-full-ha.xml in Wildfly 8.2.0 by coding
          sridhar thiyagarajan Novice

          Hello,

           

          jboss.as:subsystem=security,security-domain=EncryptPassword is the object name for the security domain I created which is obtained by using JConsole.bat. There is an operation listCachedPrincipals returning an output of array of strings associated with that object.

           

          I tried the below code to fetch created security domain information but got an error javax.management.InstanceNotFoundException: jboss.as:subsystem=security,security-domain=EncryptPassword'].

           

          String[] output = (String[]) ManagementFactory.getPlatformMBeanServer().invoke(new ObjectName("jboss.as:subsystem=security,security-domain=EncryptPassword"), "listCachedPrincipals", null, null);

           

          Could anyone please help me out if you have achieved this. Many thanks.