本文整理匯總了Java中org.apache.shiro.web.mgt.DefaultWebSecurityManager.setSessionManager方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultWebSecurityManager.setSessionManager方法的具體用法?Java DefaultWebSecurityManager.setSessionManager怎麽用?Java DefaultWebSecurityManager.setSessionManager使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.shiro.web.mgt.DefaultWebSecurityManager
的用法示例。
在下文中一共展示了DefaultWebSecurityManager.setSessionManager方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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包/類
private SecurityManager createSecurityManager() {
// create security manager
DefaultWebSecurityManager securityManager = /*new DefaultWebSecurityManager();/*/new JawnSecurityManager();
// add rememberme manager
securityManager.setSessionManager(new JawnSecuritySessionManager());//TODO
securityManager.setRememberMeManager(new JawnRememberMeManager());//TODO
securityManager.setSubjectFactory(new JWebSubjectFactory());//TODO
Collection<Realm> realms = readRealms();
// add realms to security manager
if (!realms.isEmpty())
applyRealmsToSecurityManager(realms, securityManager);
return securityManager;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: provideWebSecurityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入方法依賴的package包/類
@Singleton
@Provides
WebSecurityManager provideWebSecurityManager(
SessionManager sessionManager,
RememberMeManager rememberMeManager,
Realms realms,
Set<AuthenticationListener> authListeners) {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(realms.getRealms());
// TODO: from here the code is copied from ShiroModule ... error prone... use factory or something
((AbstractAuthenticator) securityManager.getAuthenticator()).setAuthenticationListeners(authListeners);
securityManager.setSessionManager(sessionManager);
securityManager.setRememberMeManager(rememberMeManager);
return securityManager;
}
示例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: 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;
}
示例11: 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;
}
示例12: securityManager
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入方法依賴的package包/類
@Bean
public SecurityManager securityManager(net.sf.ehcache.CacheManager cacheManager, SessionManager sessionManager, MyRealm myRealm) {
DefaultWebSecurityManager sm = new DefaultWebSecurityManager();
registLoggingAuthenticationListener(sm);
//
EhCacheManager cm = new EhCacheManager();
cm.setCacheManager(cacheManager);
sm.setCacheManager(cm);
sm.setSessionManager(sessionManager);
// realm.
Preconditions.checkNotNull(myRealm);
sm.setRealm(myRealm);
//
return sm;
}
示例13: initialize
import org.apache.shiro.web.mgt.DefaultWebSecurityManager; //導入方法依賴的package包/類
@Override
public boolean initialize(SilentGo me) throws AppBuildException {
ShiroConfig config = (ShiroConfig) me.getConfig().getConfig(Name);
me.getFactory(CacheFactory.class);
PropKit prop = me.getConfig().getUserProp();
RetryLimitHashedCredentialsMatcher retryLimitHashedCredentialsMatcher = new RetryLimitHashedCredentialsMatcher();
retryLimitHashedCredentialsMatcher.setHashAlgorithmName(prop.getValue(Dict.SHIRO_CREDENTIALS_MATCHER_HASHALGORITHMNAME, "md5"));
retryLimitHashedCredentialsMatcher.setHashIterations(prop.getInt(Dict.SHIRO_CREDENTIALS_MATCHER_HASHITERATIONS, 2));
retryLimitHashedCredentialsMatcher.setStoredCredentialsHexEncoded(prop.getBool(Dict.SHIRO_CREDENTIALS_MATCHER_STOREDCREDENTIALSHEXENCODED, true));
EhCacheManager ehCacheManager = new EhCacheManager();
EhCache cache = (EhCache) me.getConfig().getCacheManager();
ehCacheManager.setCacheManager(cache.getCacheManager());
JavaUuidSessionIdGenerator sessionIdGenerator = new JavaUuidSessionIdGenerator();
SimpleCookie sessionIdCookie = new SimpleCookie(prop.getValue(Dict.SHIRO_SESSION_COOKIENAME, "lc4e"));
sessionIdCookie.setMaxAge(prop.getInt(Dict.SHIRO_SESSION_IDCOOKIE_MAXAGE, -1));
sessionIdCookie.setHttpOnly(prop.getBool(Dict.SHIRO_SESSION_IDCOOKIE_HTTPONLY, true));
SimpleCookie rememberMeCookie = new SimpleCookie(prop.getValue(Dict.SHIRO_SESSION_REMEMBER_COOKIENAME, "rlc4e"));
rememberMeCookie.setHttpOnly(prop.getBool(Dict.SHIRO_SESSION_REMEMBER_ME_HTTPONLY, true));
rememberMeCookie.setMaxAge(prop.getInt(Dict.SHIRO_SESSION_REMEMBER_ME_MAXAGE, 2592000));
CookieRememberMeManager rememberMeManager = new CookieRememberMeManager();
rememberMeManager.setCipherKey(Base64.decode(prop.getValue(Dict.SECURITY_KEY, "4AvVhmFLUs0KTA3Kprsdag==")));
rememberMeManager.setCookie(rememberMeCookie);
EnterpriseCacheSessionDAO sessionDAO = new EnterpriseCacheSessionDAO();
sessionDAO.setActiveSessionsCacheName(prop.getValue(Dict.SHIRO_SESSION_ACTIVE_NAME, "shiro-activeSessionCache"));
sessionDAO.setSessionIdGenerator(sessionIdGenerator);
sessionDAO.setCacheManager(ehCacheManager);
config.getRealm().setCredentialsMatcher(retryLimitHashedCredentialsMatcher);
config.getRealm().setCachingEnabled(false);
config.getRealm().setCacheManager(ehCacheManager);
DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
sessionValidationScheduler = new QuartzSessionValidationScheduler(sessionManager);
sessionValidationScheduler.setSessionValidationInterval(prop.getLong(Dict.SHIRO_SESSION_VALIDATIONINTERVAL, 1800000L));
sessionManager.setGlobalSessionTimeout(prop.getLong(Dict.SHIRO_SESSION_GLOBALSESSIONTIMEOUT, 1800000L));
sessionManager.setSessionDAO(sessionDAO);
sessionManager.setSessionValidationInterval(prop.getLong(Dict.SHIRO_SESSION_VALIDATIONINTERVAL, 360000L));
sessionManager.setSessionValidationScheduler(sessionValidationScheduler);
sessionManager.setSessionIdCookieEnabled(prop.getBool(Dict.SHIRO_SESSION_IDCOOKIEENABLED, true));
sessionManager.setSessionIdCookie(sessionIdCookie);
sessionValidationScheduler.setSessionManager(sessionManager);
defaultWebSecurityManager = new DefaultWebSecurityManager(config.getRealm());
defaultWebSecurityManager.setCacheManager(ehCacheManager);
defaultWebSecurityManager.setRememberMeManager(rememberMeManager);
defaultWebSecurityManager.setSessionManager(sessionManager);
ServletContext servletContext = me.getContext();
ShiroLoader shiroLoader = new ShiroLoader();
shiroLoader.initEnvironment(servletContext);
WebEnvironment environment = (WebEnvironment) servletContext.getAttribute(ShiroLoader.ENVIRONMENT_ATTRIBUTE_KEY);
((MutableWebEnvironment) environment).setWebSecurityManager(defaultWebSecurityManager);
servletContext.setAttribute(ShiroLoader.ENVIRONMENT_ATTRIBUTE_KEY, environment);
return false;
}