Thanks for that answer. Though it didn't really prove to be useful to me  it
made me look deeper into the AuthorizingRealm and AuthenticatingRealm
classes.

This here works without logging out:

        LOG.trace("called: clearShiroCacheFor('{}')", usernames);

        if (usernames == null) {
            return;
        }

        Object[][] oousers = ca.oltis.eweb.services.rest.Helper.splitUpIds(
                usernames, String.class);

        RealmSecurityManager mgr = (RealmSecurityManager) SecurityUtils
                .getSecurityManager();

        Collection<Realm> realmCollection = mgr.getRealms();
        for (Realm realm : realmCollection) {
            if (realm instanceof AuthorizingRealm) {
                for (Object[] ouser : oousers) {
                    SimplePrincipalCollection spc = new
SimplePrincipalCollection();
                    spc.add((String) ouser[0], realm.getName());

                    AuthorizingRealm authRealm = (AuthorizingRealm) realm;
                    authRealm.getAuthenticationCache().remove(spc);
                    authRealm.getAuthorizationCache().remove(spc);
                }

                LOG.debug("cleared caches in realm '{}'", realm.getName());
            }
        }




--
View this message in context: 
http://shiro-user.582556.n2.nabble.com/how-to-clear-cache-objects-for-certain-user-tp7580454p7580456.html
Sent from the Shiro User mailing list archive at Nabble.com.

Reply via email to