0 Replies Latest reply on Dec 15, 2006 3:29 AM by joeyli

    Help! flushAuthenticationCache cann't work!

    joeyli

      I use the following code to flush the role, but I use the request.isUserInRole('Anonymous'), the result is still true:

       private void logout() throws Exception {
      
       String domainName = "EatOutDomain";
      
       MBeanServer server = (MBeanServer) MBeanServerFactory
       .findMBeanServer(null).get(0);
       String jaasMgrName= "jboss.security:service=JaasSecurityManager";
       ObjectName jaasMgr = new ObjectName(jaasMgrName);
       Object[] params = { domainName };
       String[] signature = { "java.lang.String" };
       List users = (List) server.invoke(jaasMgr,
       "getAuthenticationCachePrincipals", params, signature);
      
       for (int i = 0; i < users.size(); i++) {
       SimplePrincipal principal = (SimplePrincipal) users.get(i);
      
      
       Object[] pParams = { domainName, principal };
       String[] pSignature = { "java.lang.String", "java.security.Principal"};
       server.invoke(jaasMgr, "flushAuthenticationCache", pParams,
       pSignature);
      

      There have only one principal "Anonymous" in domain, and I user getAuthenticationCachePrincipals to get the roles after call "flushAuthenticationCache", the prinipals all clearned.
      But, I use the request.isUserInRole("Anonymous") the result is always is true.
      How can I clean the request.isUserInRole()? And relogin into web site?