6 Replies Latest reply on Aug 5, 2014 10:55 PM by xiang yingbing

    How to pass parameters into mbean server during flushing JAAS cache?

    xiang yingbing Master

      Dear all,

       

      Bellow codes works well in my sessioin bean

       

          public static final void flushJaasCache(String securityDomain){
                try {
                     javax.management.MBeanServerConnection mbeanServerConnection = java.lang.management.ManagementFactory
                               .getPlatformMBeanServer();
                     javax.management.ObjectName mbeanName = new javax.management.ObjectName("jboss.as:subsystem=security,security-domain="+securityDomain);
                     mbeanServerConnection.invoke(mbeanName, "flushCache", null, null);
                } catch (Exception e) {
                     throw new SecurityException(e);
                }
          }
      
      

       

      But I want to flush just one certain principal's cache instead of the whole cache.

       

      Can you tell me the java class name of the ObjectName("jboss.as:subsystem=security,security-domain="+securityDomain)?

      Or

      Can you tell me how to pass parameters in bellow code line?

      mbeanServerConnection.invoke(mbeanName, "flushCache", null, null);
      

       

      I have tried bellow method:

          public static final void flushJaasCache(String securityDomain, String jaasUsername){
                try {
                     Object[] params = {jaasUsername};
                     String[] signature = {"java.lang.String"};
                     
                     javax.management.MBeanServerConnection mbeanServerConnection = java.lang.management.ManagementFactory
                               .getPlatformMBeanServer();
                     javax.management.ObjectName mbeanName = new javax.management.ObjectName("jboss.as:subsystem=security,security-domain="+securityDomain);
                     mbeanServerConnection.invoke(mbeanName, "flushCache", params, signature);
                } catch (Exception e) {
                     throw new SecurityException(e);
                }
          }
      
      

      It just run without exception. I am NOT sure if it works as I expect.