本文整理汇总了Java中org.apache.shiro.session.mgt.SessionManager类的典型用法代码示例。如果您正苦于以下问题:Java SessionManager类的具体用法?Java SessionManager怎么用?Java SessionManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SessionManager类属于org.apache.shiro.session.mgt包,在下文中一共展示了SessionManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: provideSecurityManager
import org.apache.shiro.session.mgt.SessionManager; //导入依赖的package包/类
@Provides
@Singleton
SecurityManager provideSecurityManager(
SessionManager sessionManager,
RememberMeManager rememberMeManager,
Realms realms,
Set<AuthenticationListener> authListeners) {
DefaultSecurityManager manager = new DefaultSecurityManager(realms.getRealms());
((AbstractAuthenticator) manager.getAuthenticator()).setAuthenticationListeners(authListeners);
manager.setSessionManager(sessionManager);
manager.setRememberMeManager(rememberMeManager);
return manager;
}
示例2: setSessionMode
import org.apache.shiro.session.mgt.SessionManager; //导入依赖的package包/类
/**
* @param sessionMode
* @deprecated since 1.2
*/
@Deprecated
public void setSessionMode(String sessionMode) {
log.warn("The 'sessionMode' property has been deprecated. Please configure an appropriate WebSessionManager " +
"instance instead of using this property. This property/method will be removed in a later version.");
String mode = sessionMode;
if (mode == null) {
throw new IllegalArgumentException("sessionMode argument cannot be null.");
}
mode = sessionMode.toLowerCase();
if (!HTTP_SESSION_MODE.equals(mode) && !NATIVE_SESSION_MODE.equals(mode)) {
String msg = "Invalid sessionMode [" + sessionMode + "]. Allowed values are " +
"public static final String constants in the " + getClass().getName() + " class: '"
+ HTTP_SESSION_MODE + "' or '" + NATIVE_SESSION_MODE + "', with '" +
HTTP_SESSION_MODE + "' being the default.";
throw new IllegalArgumentException(msg);
}
boolean recreate = this.sessionMode == null || !this.sessionMode.equals(mode);
this.sessionMode = mode;
if (recreate) {
LifecycleUtils.destroy(getSessionManager());
SessionManager sessionManager = createSessionManager(mode);
this.setInternalSessionManager(sessionManager);
}
}
示例3: setSessionManager
import org.apache.shiro.session.mgt.SessionManager; //导入依赖的package包/类
@Override
public void setSessionManager(SessionManager sessionManager) {
if (sessionManager != null
&& !(sessionManager instanceof WebSessionManager)) {
if (log.isWarnEnabled()) {
String msg = "The "
+ getClass().getName()
+ " implementation expects SessionManager instances "
+ "that implement the "
+ WebSessionManager.class.getName()
+ " interface. The "
+ "configured instance is of type ["
+ sessionManager.getClass().getName()
+ "] which does not "
+ "implement this interface.. This may cause unexpected behavior.";
log.warn(msg);
}
}
setInternalSessionManager(sessionManager);
}
示例4: increaseShiroGlobalSessionTimeout
import org.apache.shiro.session.mgt.SessionManager; //导入依赖的package包/类
private void increaseShiroGlobalSessionTimeout(final DefaultSecurityManager shiroManager) {
SessionManager sessionManager = shiroManager.getSessionManager();
if (DefaultSessionManager.class.isInstance(sessionManager)) {
DefaultSessionManager defaultSessionManager = (DefaultSessionManager) sessionManager;
defaultSessionManager.setGlobalSessionTimeout(Long.MAX_VALUE);
long value = defaultSessionManager.getGlobalSessionTimeout();
if (value != Long.MAX_VALUE) {
logger.error("Unable to set Shiro Global Session Timeout. Current value is '{}'.", value);
}
} else {
logger.error("Unable to set Shiro Global Session Timeout. Current SessionManager is '{}'.",
sessionManager == null ? "null" : sessionManager.getClass());
}
}
示例5: securitManager
import org.apache.shiro.session.mgt.SessionManager; //导入依赖的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;
}
示例6: securityManager
import org.apache.shiro.session.mgt.SessionManager; //导入依赖的package包/类
@Bean(name = "securityManager")
@DependsOn(value = {"cacheManager", "rememberMeManager", "mainRealm"})
public DefaultSecurityManager securityManager(Realm realm, RememberMeManager rememberMeManager,
CacheManager cacheManager, SessionManager sessionManager) {
DefaultSecurityManager sm = new DefaultWebSecurityManager();
sm.setRealm(realm);
sm.setCacheManager(cacheManager);
sm.setSessionManager(sessionManager);
sm.setRememberMeManager(rememberMeManager);
return sm;
}
示例7: provideWebSecurityManager
import org.apache.shiro.session.mgt.SessionManager; //导入依赖的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;
}
示例8: getSessionManager
import org.apache.shiro.session.mgt.SessionManager; //导入依赖的package包/类
@Bean
public SessionManager getSessionManager() {
DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
sessionManager.setGlobalSessionTimeout(180000);
sessionManager.setDeleteInvalidSessions(true);
return sessionManager;
}
示例9: securityManager
import org.apache.shiro.session.mgt.SessionManager; //导入依赖的package包/类
@Bean(name = "securityManager")
@DependsOn(value = {"cacheManager", "rememberMeManager", "mainRealm"})
public DefaultSecurityManager securityManager(Realm realm, RememberMeManager rememberMeManager, CacheManager cacheManager, SessionManager sessionManager) {
DefaultSecurityManager sm = new DefaultWebSecurityManager();
sm.setRealm(realm);
sm.setCacheManager(cacheManager);
sm.setSessionManager(sessionManager);
sm.setRememberMeManager(rememberMeManager);
return sm;
}
示例10: setSessionManager
import org.apache.shiro.session.mgt.SessionManager; //导入依赖的package包/类
@Override
public void setSessionManager(SessionManager sessionManager) {
this.sessionMode = null;
if (sessionManager != null && !(sessionManager instanceof WebSessionManager)) {
if (log.isWarnEnabled()) {
String msg = "The " + getClass().getName() + " implementation expects SessionManager instances " +
"that implement the " + WebSessionManager.class.getName() + " interface. The " +
"configured instance is of type [" + sessionManager.getClass().getName() + "] which does not " +
"implement this interface.. This may cause unexpected behavior.";
log.warn(msg);
}
}
setInternalSessionManager(sessionManager);
}
示例11: createSessionManager
import org.apache.shiro.session.mgt.SessionManager; //导入依赖的package包/类
protected SessionManager createSessionManager(String sessionMode) {
if (sessionMode == null || !sessionMode.equalsIgnoreCase(NATIVE_SESSION_MODE)) {
log.info("{} mode - enabling ServletContainerSessionManager (HTTP-only Sessions)", HTTP_SESSION_MODE);
return new ServletContainerSessionManager();
} else {
log.info("{} mode - enabling DefaultWebSessionManager (non-HTTP and HTTP Sessions)", NATIVE_SESSION_MODE);
return new DefaultWebSessionManager();
}
}
示例12: bindSessionManager
import org.apache.shiro.session.mgt.SessionManager; //导入依赖的package包/类
@Override
protected void bindSessionManager(final AnnotatedBindingBuilder<SessionManager> bind) {
// use native web session management instead of delegating to servlet container
// workaround for NEXUS-5727, see NexusDefaultWebSessionManager javadoc for clues
bind.to(NexusWebSessionManager.class).asEagerSingleton();
// this is a PrivateModule, so explicitly binding the NexusDefaultSessionManager class
bind(NexusWebSessionManager.class);
}
示例13: getSessionDAO
import org.apache.shiro.session.mgt.SessionManager; //导入依赖的package包/类
protected SessionDAO getSessionDAO() {
final SecurityManager securityManager = SecurityUtils.getSecurityManager();
if(securityManager instanceof SessionsSecurityManager) {
final SessionManager sessionManager = ((SessionsSecurityManager) securityManager).getSessionManager();
if(sessionManager instanceof DefaultSessionManager) {
return ((DefaultSessionManager) sessionManager).getSessionDAO();
}
}
return null;
}
示例14: configure
import org.apache.shiro.session.mgt.SessionManager; //导入依赖的package包/类
@Override
protected void configure() {
bindFactory(SubjectFactory.class)
.to(Subject.class)
.in(RequestScoped.class);
bind(securityManager)
.to(SecurityManager.class)
.to(Authenticator.class)
.to(Authorizer.class)
.to(SessionManager.class)
.proxy(false);
}
示例15: sessionManager
import org.apache.shiro.session.mgt.SessionManager; //导入依赖的package包/类
@Bean
public SessionManager sessionManager() {
DefaultWebSessionManager defaultWebSessionManager = new DefaultWebSessionManager();
defaultWebSessionManager.setGlobalSessionTimeout(Integer.valueOf(env.getProperty("session.max.age")) * 1000);
defaultWebSessionManager.setSessionValidationSchedulerEnabled(false);
// List<SessionListener> listenerList = new ArrayList<>();
// listenerList.add(sessionListener());
// defaultWebSessionManager.setSessionListeners(listenerList);
return defaultWebSessionManager;
}