org.apache.shiro.session.mgt.DefaultSessionManager Java Examples

The following examples show how to use org.apache.shiro.session.mgt.DefaultSessionManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShiroAuthProvider.java    From centraldogma with Apache License 2.0 6 votes vote down vote up
private static SecurityManager createSecurityManager(Ini config, Supplier<String> sessionIdGenerator) {
    final Factory<SecurityManager> factory = new IniSecurityManagerFactory(config) {
        @Override
        protected SecurityManager createDefaultInstance() {
            final DefaultSessionManager sessionManager = new DefaultSessionManager();
            // This session DAO is required to cache the session in a very short time, especially while
            // logging in to the Central Dogma server. After that, the general session manager provided
            // by Central Dogma server will be working for the session management.
            sessionManager.setSessionDAO(new LimitedMemorySessionDAO(sessionIdGenerator,
                                                                     64, Duration.ofHours(1)));

            final DefaultSecurityManager securityManager = new DefaultSecurityManager();
            securityManager.setSessionManager(sessionManager);

            return securityManager;
        }
    };
    return factory.getInstance();
}
 
Example #2
Source File: SecurityModule.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Override
protected void bindSessionManager(AnnotatedBindingBuilder<SessionManager> bind) {
bind.to(DefaultSessionManager.class).asEagerSingleton();
bind(DefaultSessionManager.class);
   bindConstant().annotatedWith(Names.named("shiro.globalSessionTimeout")).to(globalSessionTimeoutInSecs * 1000L);
   bindConstant().annotatedWith(Names.named("shiro.sessionValidationSchedulerEnabled")).to(false);
}
 
Example #3
Source File: ShiroManager.java    From shiro-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public DefaultSessionManager defaultSessionManager() {
    DefaultSessionManager manager = new DefaultSessionManager();

    // 关闭session定时检查
    manager.setSessionValidationSchedulerEnabled(false);

    return manager;
}
 
Example #4
Source File: SSOServiceImpl.java    From nano-framework with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #5
Source File: TelegramLongPollingSessionBot.java    From TelegramBots with MIT License 4 votes vote down vote up
public TelegramLongPollingSessionBot(ChatIdConverter chatIdConverter){
    this.setSessionManager(new DefaultSessionManager());
    this.setChatIdConverter(chatIdConverter);
    AbstractSessionDAO sessionDAO = (AbstractSessionDAO) sessionManager.getSessionDAO();
    sessionDAO.setSessionIdGenerator(chatIdConverter);
}
 
Example #6
Source File: TelegramLongPollingSessionBot.java    From TelegramBots with MIT License 4 votes vote down vote up
public void setSessionManager(DefaultSessionManager sessionManager) {
    this.sessionManager = sessionManager;
}
 
Example #7
Source File: ShiroSecurityHelper.java    From nano-framework with Apache License 2.0 4 votes vote down vote up
public SessionDAO getSessionDAO() {
	if(sessionDAO == null)
		sessionDAO = ((DefaultSessionManager) ((DefaultSecurityManager) SecurityUtils.getSecurityManager()).getSessionManager()).getSessionDAO();
	
	return sessionDAO;
}