3 Replies Latest reply on Dec 18, 2003 7:35 AM by Richard Liehmann

    Flush Authentication Cache don't work

    Richard Liehmann Newbie

      Hello!

      I have a servlet which changes the roles of users in a database. To make this changes also in JaasSecurityManager, I flush the authentication cache.

      here is a sniplet of my code for this:
      try
      {
      RMIAdaptor server = (RMIAdaptor) ctx.lookup("jmx/rmi/RMIAdaptor");
      ObjectName name = new ObjectName("jboss.security:service=JaasSecurityManager");

      String[] params = { "codatexsecurity" };
      String[] signature = { "java.lang.String" };
      Object result = server.invoke(name, "flushAuthenticationCache", params, signature);
      }
      catch (Exception eee)
      {
      //forward to reg.jsp with mode=error
      error = eee.getMessage();
      url = "/reg.jsp?mode=error&error="+error;
      }

      I get no error or exception when accessing the servlet. Everything seem to work correct, but actually nothing happens. When I try to login with a user, the old cached role is still active.

      I have JBoss Version 3.2.2 with tomcat and using DatabaseLoginModul.

      How can I flush the cache? Or is there another solution for my problem?

      Thanks...

        • 1. Re: Flush Authentication Cache don't work
          doomsday Newbie

          Hi,

          I use the following code snippet:

          ---------- SNIP ---------- SNIP ---------- SNIP ----------
          InitialContext ctx = new InitialContext();
          RMIAdaptor jbossServer = (RMIAdaptor) ctx.lookup( "jmx/invoker/RMIAdaptor" );
          ObjectName jaasSecMgr =
          new ObjectName("jboss.security:service=JaasSecurityManager");
          // jboss-web.xml: <security-domain>java:/jaas/other</security-domain>
          String secDomain = "other";
          String method = "flushAuthenticationCache";
          Object[] params = { secDomain };
          String[] paramTypes = { String.class.getName() };
          jbossServer.invoke( jaasSecMgr, method, params, paramTypes);
          ---------- SNIP ---------- SNIP ---------- SNIP ----------

          This works perfectly for me, even fetching the list of cached Principals (method name "getAuthenticationCachePrincipals") and flushing individual Principals ("flushAuthenticationCache" overloaded with additional Principal parameter)

          Cheers,
          Doomsday

          • 2. Re: Flush Authentication Cache don't work
            doomsday Newbie

            Hi again,

            forgot to mention that I also use JBoss 3.2.2 with Tomcat and the DatabaseLoginModule.

            Cheers,
            Doomsday

            • 3. Re: Flush Authentication Cache don't work
              Richard Liehmann Newbie

              Hello,

              Now it's working.
              It was a wrong typed String in the lookup for the securitymanager.

              Thanks to all for helping...