Example usage for org.apache.shiro.mgt RealmSecurityManager setCacheManager

List of usage examples for org.apache.shiro.mgt RealmSecurityManager setCacheManager

Introduction

In this page you can find the example usage for org.apache.shiro.mgt RealmSecurityManager setCacheManager.

Prototype

public void setCacheManager(CacheManager cacheManager) 

Source Link

Document

Sets the CacheManager used by this SecurityManager and potentially any of its children components.

Usage

From source file:com.josue.kingdom.security.CustomEnvironmentLoaderListener.java

@Override
protected WebEnvironment createEnvironment(ServletContext pServletContext) {

    LOG.log(Level.INFO, "########## INITIALIZING CUSTOMENVIRONMENTLOADERLISTENER ##########");

    WebEnvironment environment = super.createEnvironment(pServletContext);
    RealmSecurityManager rsm = (RealmSecurityManager) environment.getSecurityManager();
    //TODO check for how to read from shiro.ini

    //        PasswordService passwordService = new DefaultPasswordService();
    //        PasswordMatcher passwordMatcher = new PasswordMatcher();
    //        passwordMatcher.setPasswordService(passwordService);
    //        jpaRealm.setCredentialsMatcher(passwordMatcher);
    //TODO add another realms here
    Set<Realm> realms = new HashSet<>();
    realms.add(apiCredentialJPARealm);/*from  w w  w . ja va  2 s  .  c om*/
    realms.add(managerJPARealm);
    rsm.setRealms(realms);

    rsm.setCacheManager(new MemoryConstrainedCacheManager());

    ((DefaultWebEnvironment) environment).setSecurityManager(rsm);

    return environment;
}