I have XWiki and a separate app. I need to use my app permissions in XWiki.
XWiki uses security cache and asks my app for a particular permission only
once. I need to make XWiki aware about permission changes in my app.

I have several options:
1. sometimes I invalidate cache in my application. I could call xwiki api to
invalidate the whole xwiki cache when I invalidate my app cache.
2. from time to time (say, every minute) make a REST call to my app. My app
says if cache was invalidated. If it was I would like to invalidate xwiki
cache.

My questions are:
1. how to invalidate the whole cache? I implemented
CustomSecurityCacheInvalidator, but it seems like I can remove only separate
entities there via `remove` call. As I understand I have to call `suspend`
and then remove entities from the cache and then call `resume`, right? But
SecurityCache has only `get` and `remove` methods for separate entities.
2. should I create a separate `Component` for scheduler which will poll data
from my app from time to time? I could start new thread there to ask my app
on schedule and Inject CustomSecurityCacheInvalidator. Is it the right
approach?

My class is here:

@Component
@Singleton
public class CustomSecurityCacheInvalidator extends
DefaultSecurityCacheRulesInvalidator {

    @Inject
    private SecurityCache securityCache;

    @Override
    public void suspend() {
        System.out.println("suspend!");
        super.suspend();

        //I can use securityCache here
    }

    @Override
    public void resume() {
        System.out.println("resume!");
        super.resume();
    }
}



--
View this message in context: 
http://xwiki.475771.n2.nabble.com/How-to-invalidate-security-cache-tp7599138.html
Sent from the XWiki- Dev mailing list archive at Nabble.com.
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to