本文整理汇总了Java中org.apache.shiro.web.mgt.DefaultWebSecurityManager.setCacheManager方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultWebSecurityManager.setCacheManager方法的具体用法?Java DefaultWebSecurityManager.setCacheManager怎么用?Java DefaultWebSecurityManager.setCacheManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.shiro.web.mgt.DefaultWebSecurityManager
的用法示例。
在下文中一共展示了DefaultWebSecurityManager.setCacheManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: securityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //导入方法依赖的package包/类
@Bean(name = "securityManager")
@ConditionalOnMissingBean
public DefaultSecurityManager securityManager(CacheManager shiroCacheManager) {
DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
// 用自己的Factory实现替换默认
// 用于关闭session功能
dwsm.setSubjectFactory(new StatelessSubjectFactory());
dwsm.setSessionManager(defaultSessionManager());
// 关闭session存储
((DefaultSessionStorageEvaluator) ((DefaultSubjectDAO)dwsm.getSubjectDAO()).getSessionStorageEvaluator()).setSessionStorageEnabled(false);
// <!-- 用户授权/认证信息Cache, 采用EhCache 缓存 -->
dwsm.setCacheManager(shiroCacheManager);
SecurityUtils.setSecurityManager(dwsm);
return dwsm;
}
示例2: securityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //导入方法依赖的package包/类
@Bean
public DefaultWebSecurityManager securityManager() {
realms = realms == null ? new ArrayList<Realm>() : realms;
boolean existCasRealm = false;
for (Realm realm : realms) {
if (realm == casRealm()) {
existCasRealm = true;
break;
}
}
if (!existCasRealm) {
realms.add(0, casRealm());
}
DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
//authenticator必须在realm前面设值,因为setRealm时会有条件的设置authenticator里的realm
manager.setAuthenticator(authenticator());
manager.setSubjectFactory(casSubjectFactory());
manager.setCacheManager(securityCacheManager());
manager.setSessionManager(sessionManager());
manager.setRealms(realms);
return manager;
}
示例3: createSecurityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //导入方法依赖的package包/类
/**
* Creates the security manager without registering it.
*
* @param repo the component repository, only used to register secondary items like lifecycle, not null
* @param pwService the password service, not null
* @return the security manager, not null
*/
protected SecurityManager createSecurityManager(ComponentRepository repo, PasswordService pwService) throws IOException {
// password matcher
PasswordMatcher pwMatcher = new PasswordMatcher();
pwMatcher.setPasswordService(pwService);
// user database realm
UserSource userSource = getUserSource();
if (userSource == null) {
userSource = getUserMaster();
}
UserSourceRealm realm = new UserSourceRealm(userSource);
realm.setAuthenticationCachingEnabled(true);
realm.setAuthorizationCachingEnabled(true);
realm.setCredentialsMatcher(pwMatcher);
realm.setPermissionResolver(AuthUtils.getPermissionResolver());
// security manager
DefaultWebSecurityManager sm = new DefaultWebSecurityManager();
sm.setRealm(realm);
sm.setAuthorizer(realm); // replace ModularRealmAuthorizer as not needed
sm.setCacheManager(new MemoryConstrainedCacheManager());
return sm;
}
示例4: getDefaultWebSecurityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //导入方法依赖的package包/类
@Bean(name = "securityManager")
public DefaultWebSecurityManager getDefaultWebSecurityManager(MyShiroCasRealm myShiroCasRealm) {
DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
dwsm.setRealm(myShiroCasRealm);
// <!-- 用户授权/认证信息Cache, 采用EhCache 缓存 -->
dwsm.setCacheManager(getEhCacheManager());
// 指定 SubjectFactory
dwsm.setSubjectFactory(new CasSubjectFactory());
return dwsm;
}
示例5: defaultWebSecurityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //导入方法依赖的package包/类
@Bean(name = "securityManager")
public DefaultWebSecurityManager defaultWebSecurityManager(@Qualifier("shiroRealm") ShiroRealm realm){
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
securityManager.setRealm(realm);
// 指定SubjectFactory
securityManager.setSessionManager(this.sessionManager());
securityManager.setCacheManager(this.redisCacheManager());
return securityManager;
}
示例6: defaultWebSecurityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //导入方法依赖的package包/类
@Bean(name = "securityManager")
public DefaultWebSecurityManager defaultWebSecurityManager(ShiroCasRealm realm){
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
securityManager.setRealm(realm);
// 指定SubjectFactory
securityManager.setSubjectFactory(new CasSubjectFactory());
securityManager.setSessionManager(this.sessionManager());
securityManager.setCacheManager(this.redisCacheManager());
return securityManager;
}
示例7: getDefaultWebSecurityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //导入方法依赖的package包/类
@Bean(name = "securityManager")
public DefaultWebSecurityManager getDefaultWebSecurityManager(
SystemAuthorizingRealm myShiroRealm,
DefaultWebSessionManager sessionManager,
EhCacheManager shiroCacheManager) {
DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
dwsm.setRealm(myShiroRealm);
dwsm.setSessionManager(sessionManager);
// <!-- 用户授权/认证信息Cache, 采用EhCache 缓存 -->
dwsm.setCacheManager(shiroCacheManager);
return dwsm;
}
示例8: securitManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //导入方法依赖的package包/类
@Bean(name="securityManager")
public SecurityManager securitManager(@Qualifier("systemRealm")SystemRealm systemRealm, @Qualifier("sessionManager")SessionManager sessionManager, @Qualifier("ehcacheManager")CacheManager cacheManager){
DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
manager.setSessionManager(sessionManager);
//-- 两种缓存方式: 第一,使用ehcache(shiro自带的本地内存缓存机制); 第二,使用redis服务进行缓存操作
manager.setCacheManager(redisCacheManager());
manager.setRealm(systemRealm);
return manager;
}
示例9: getDefaultWebSecurityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //导入方法依赖的package包/类
@Bean
public DefaultWebSecurityManager getDefaultWebSecurityManager() {
DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
dwsm.setRealm(getShiroRealm());
dwsm.setCacheManager(getCacheManager());
dwsm.setSessionManager(getSessionManager());
return dwsm;
}
示例10: getDefaultWebSecurityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //导入方法依赖的package包/类
@Bean(name = "securityManager")
public DefaultWebSecurityManager getDefaultWebSecurityManager(MyShiroRealm myShiroRealm) {
DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
dwsm.setRealm(myShiroRealm);
// <!-- 用户授权/认证信息Cache, 采用EhCache 缓存 -->
dwsm.setCacheManager(getEhCacheManager());
return dwsm;
}
示例11: getDefaultWebSecurityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //导入方法依赖的package包/类
@Bean(name = "securityManager")
public DefaultWebSecurityManager getDefaultWebSecurityManager(
MyShiroRealm myShiroRealm) {
DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
dwsm.setRealm(myShiroRealm);
// <!-- 用户授权/认证信息Cache, 采用EhCache 缓存 -->
dwsm.setCacheManager(getEhCacheManager());
return dwsm;
}
示例12: webSecurityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //导入方法依赖的package包/类
@Bean
public DefaultWebSecurityManager webSecurityManager(Realm realm,
CookieRememberMeManager rememberMeManager,
DefaultWebSessionManager sessionManager,
EhCacheManager ehCacheManager) {
DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
defaultWebSecurityManager.setRealm(realm);
defaultWebSecurityManager.setRememberMeManager(rememberMeManager);
defaultWebSecurityManager.setSessionManager(sessionManager);
defaultWebSecurityManager.setCacheManager(ehCacheManager);
return defaultWebSecurityManager;
}
示例13: getDefaultWebSecurityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //导入方法依赖的package包/类
@Bean(name = "securityManager")
public DefaultWebSecurityManager getDefaultWebSecurityManager(AuthorizingRealm realm) {
DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
dwsm.setRealm(realm);
dwsm.setCacheManager(getEhCacheManager());
return dwsm;
}
示例14: initSecurityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //导入方法依赖的package包/类
private WebSecurityManager initSecurityManager() {
AppDbRealm appDbRealm = new AppDbRealm();
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(appDbRealm);
final EhCacheManager cacheManager = new EhCacheManager();
cacheManager.setCacheManagerConfigFile("classpath:goja/ehcache/shiro-ehcache.xml");
securityManager.setCacheManager(cacheManager);
final DefaultWebSessionManager defaultWebSessionManager = new DefaultWebSessionManager();
defaultWebSessionManager.setSessionIdCookieEnabled(true);
// 默认一年过期时间
final String expiredTimes = shiroConfig.getProperty("session.expired", "10800000");
defaultWebSessionManager.setGlobalSessionTimeout(MoreObjects.firstNonNull(Ints.tryParse(expiredTimes), 10800000));
securityManager.setSessionManager(defaultWebSessionManager);
return securityManager;
}
示例15: getDefaultWebSecurityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //导入方法依赖的package包/类
@Bean(name = "securityManager")
public DefaultWebSecurityManager getDefaultWebSecurityManager() {
DefaultWebSecurityManager dwsm = new DefaultWebSecurityManager();
dwsm.setRealm(getShiroRealm());
dwsm.setCacheManager(getEhCacheManager());
return dwsm;
}