Tapestry-security CacheManager

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Tapestry-security CacheManager

Charlouze
Hello tapestry users,

I wanted to get rid of the log message that says "*No cache or cacheManager
properties have been set. Authorization cache cannot be obtained.*".

I read that shiro offers an implementation of their CacheManager using
EhCache so I tried to set it up.

In order to set the CacheManager I had to override
TapestryRealmSecurityManager with one of my own (see below) using a
ServiceOverride contribution. I don't really like using ServiceOverride as
it feels i'm hacking something. Is there a better way to achieve what I
want tot do ?

Regards,
Charles

import org.apache.shiro.cache.CacheManager;
import org.apache.shiro.mgt.RememberMeManager;
import org.apache.shiro.mgt.SubjectFactory;
import org.apache.shiro.realm.Realm;
import org.tynamo.security.Authenticator;
import org.tynamo.security.services.TapestryRealmSecurityManager;

import java.util.Collection;

public class MySecurityManager extends TapestryRealmSecurityManager {
    public MySecurityManager(final Authenticator authenticator, final
SubjectFactory subjectFactory,
                                    final RememberMeManager
rememberMeManager, final Collection<Realm> realms,
                                    final CacheManager cacheManager) {
        super(authenticator, subjectFactory, rememberMeManager, realms);
        setCacheManager(cacheManager);
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: Tapestry-security CacheManager

kaosko
Typically, you'd set the desired cachemanager in the realm itself, e.g.:

public class UserRealm extends AuthorizingRealm {
    public UserRealm(...) {
        super(new MemoryConstrainedCacheManager());


Kalle

On Wed, Dec 21, 2016 at 12:47 AM, Charlouze <[hidden email]> wrote:

> Hello tapestry users,
>
> I wanted to get rid of the log message that says "*No cache or cacheManager
> properties have been set. Authorization cache cannot be obtained.*".
>
> I read that shiro offers an implementation of their CacheManager using
> EhCache so I tried to set it up.
>
> In order to set the CacheManager I had to override
> TapestryRealmSecurityManager with one of my own (see below) using a
> ServiceOverride contribution. I don't really like using ServiceOverride as
> it feels i'm hacking something. Is there a better way to achieve what I
> want tot do ?
>
> Regards,
> Charles
>
> import org.apache.shiro.cache.CacheManager;
> import org.apache.shiro.mgt.RememberMeManager;
> import org.apache.shiro.mgt.SubjectFactory;
> import org.apache.shiro.realm.Realm;
> import org.tynamo.security.Authenticator;
> import org.tynamo.security.services.TapestryRealmSecurityManager;
>
> import java.util.Collection;
>
> public class MySecurityManager extends TapestryRealmSecurityManager {
>     public MySecurityManager(final Authenticator authenticator, final
> SubjectFactory subjectFactory,
>                                     final RememberMeManager
> rememberMeManager, final Collection<Realm> realms,
>                                     final CacheManager cacheManager) {
>         super(authenticator, subjectFactory, rememberMeManager, realms);
>         setCacheManager(cacheManager);
>     }
> }
>