当前位置: 首页>>代码示例>>Java>>正文


Java SessionManager类代码示例

本文整理汇总了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;
}
 
开发者ID:bootique,项目名称:bootique-shiro,代码行数:17,代码来源:ShiroModule.java

示例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);
    }
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:29,代码来源:DefaultWebSecurityManager.java

示例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);
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:21,代码来源:SimpleWebSecurityManager.java

示例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());
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:15,代码来源:IntegratedSecurityService.java

示例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;
}
 
开发者ID:ranji1221,项目名称:lemcloud,代码行数:10,代码来源:ShiroConfig.java

示例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;
}
 
开发者ID:johntostring,项目名称:spring-boot-shiro,代码行数:12,代码来源:ShiroConfiguration.java

示例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;
}
 
开发者ID:bootique,项目名称:bootique-shiro,代码行数:16,代码来源:ShiroWebModule.java

示例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;
}
 
开发者ID:sisyphsu,项目名称:server-boilerplate,代码行数:8,代码来源:ShiroConfig.java

示例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;
}
 
开发者ID:storezhang,项目名称:utils,代码行数:12,代码来源:ShiroConfiguration.java

示例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);
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:15,代码来源:DefaultWebSecurityManager.java

示例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();
    }
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:10,代码来源:DefaultWebSecurityManager.java

示例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);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:9,代码来源:WebSecurityModule.java

示例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;
}
 
开发者ID:nano-projects,项目名称:nano-framework,代码行数:12,代码来源:SSOServiceImpl.java

示例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);
}
 
开发者ID:icode,项目名称:ameba-shiro,代码行数:13,代码来源:ShiroBinder.java

示例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;
    }
 
开发者ID:qatang,项目名称:ctm,代码行数:12,代码来源:ShiroConfig.java


注:本文中的org.apache.shiro.session.mgt.SessionManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。