1 Reply Latest reply on Aug 19, 2002 9:40 PM by Mike

    Jboss 3 Flushing Authentication Cache

    Mike Newbie

      I am trying to flush the authentication cache in jboss 3. In going through the forums, I found some code, but I can't get any of it to work. The code I'm working off of now is.

      java.util.ArrayList servers = MBeanServerFactory.findMBeanServer(null);

      if (servers.size() != 1)
      throw new EJBException("Not exactly one server found");

      MBeanServer mbeanServer = (MBeanServer) servers.get(0);
      String[] params = { "yourSecurityDomainName" };
      String[] signature = { "java.lang.String" };
      try
      {
      ObjectName name = new ObjectName("Security", "name", "JaasSecurityManager");
      mbeanServer.invoke(name, "flushAuthenticationCache", params, signature);
      }
      catch (Exception e)
      {
      e.printStackTrace();
      throw new EJBException(e);
      }

      The Exception I get is Security:name=JaasSecurityManager is not registered.
      Anyone have any ideas?

      Mike

        • 1. Re: Jboss 3 Flushing Authentication Cache
          Mike Newbie

          I figured it out. Here's the a summary of the code taken from JBossTestServices.java in the source.

          import org.jboss.jmx.adaptor.rmi.*;

          InitialContext initialContext = new InitialContext();
          String serverName = System.getProperty("jbosstest.server.name");

          if (serverName == null)
          serverName = java.net.InetAddress.getLocalHost().getHostName();

          RMIAdaptor server = (org.jboss.jmx.adaptor.rmi.RMIAdaptor)initialContext.lookup("jmx:" + serverName + ":rmi");

          ObjectName jaasMgr = new ObjectName("jboss.security:name=JaasSecurityManager");
          Object[] params = {"SecurityRealm"};
          String[] signature = {"java.lang.String"};
          server.invoke(jaasMgr, "flushAuthenticationCache", params, signature);