This code work fine. I just wonder if flushing the user cache is equal to 
logging out? How can I log out the user?


  | 
  |     private void logout(Principal user) {
  | 
  |             try {
  | 
  |                     String domainName = "domain";
  | 
  |                     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);
  | 
  |                             log.info("user = " + principal);
  |                             
  |                             if (user.equals(principal)) {
  | 
  |                                     log.info("Logging out");
  |                                     
  |                                     Object[] pParams = { domainName, user };
  |                                     String[] pSignature = { 
"java.lang.String", "java.security.Principal"};
  |                                     server.invoke(jaasMgr, 
"flushAuthenticationCache", pParams,
  |                                                     pSignature);
  | 
  |                             }
  |                     }
  |             } catch (MalformedObjectNameException e) {
  |                     log.error("Malformed Object", e);
  |             } catch (NullPointerException e) {
  |                     log.error("Null Pointer", e);
  |             } catch (InstanceNotFoundException e) {
  |                     log.error("Instance not found", e);
  |             } catch (MBeanException e) {
  |                     log.error("MBean Exception", e);
  |             } catch (ReflectionException e) {
  |                     log.error("Reflection Exception", e);
  |             }
  | 
  |     }
  | 

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3872260#3872260

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3872260


-------------------------------------------------------
This SF.net email is sponsored by Demarc:
A global provider of Threat Management Solutions.
Download our HomeAdmin security software for free today!
http://www.demarc.com/info/Sentarus/hamr30
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to