I have read many topics on the forums about this, but it seems that I can't get it work right. Here is my code:
java.util.ArrayList servers=MBeanServerFactory.findMBeanServer(null);
if (servers.size() != 1)
System.out.println("uh-oh, etc");
MBeanServer mbeanServer = (MBeanServer) servers.get(0);
String[] mparams = { "myrealm" };
String[] msignature = { "java.lang.String" };
try
{
ObjectName name = new ObjectName("jboss.security:service=JaasSecurityManager");
// the following call DOES work
mbeanServer.invoke(name, "flushAuthenticationCache", mparams, msignature);
String domain = "myrealm";
Principal loggedUser=sessionctx.getCallerPrincipal();
Principal userp = new org.jboss.security.SimplePrincipal(loggedUser.getName()); // tried with my own custom principal as well
Object[] params = {domain, userp};
String[] signature = {"java.lang.String", "java.security.Principal"};
// the following call has NO effect whatsoever
Object result=mbeanServer.invoke(name, "flushAuthenticationCache", params, signature);
}
catch (Exception e)
{
e.printStackTrace();
}I forgot to mention that I use JBOSS 3.2.5 in case it makes a difference.