org.apache.shiro.session.mgt.eis.SessionDAO Java Examples

The following examples show how to use org.apache.shiro.session.mgt.eis.SessionDAO. 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: WebSecurityModule.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void configureShiroWeb() {
  bindRealm().to(EmptyRealm.class); // not used in practice, just here to keep Shiro module happy

  bindSingleton(SessionFactory.class, NexusSessionFactory.class);
  bindSingleton(SessionStorageEvaluator.class, NexusSessionStorageEvaluator.class);
  bindSingleton(SubjectDAO.class, NexusSubjectDAO.class);

  // configure our preferred security components
  bindSingleton(SessionDAO.class, NexusSessionDAO.class);
  bindSingleton(Authenticator.class, FirstSuccessfulModularRealmAuthenticator.class);
  bindSingleton(Authorizer.class, ExceptionCatchingModularRealmAuthorizer.class);
  bindSingleton(FilterChainManager.class, DynamicFilterChainManager.class);

  // path matching resolver has several constructors so we need to point Guice to the appropriate one
  bind(FilterChainResolver.class).toConstructor(ctor(PathMatchingFilterChainResolver.class)).asEagerSingleton();

  // bindings used by external modules
  expose(FilterChainResolver.class);
  expose(FilterChainManager.class);
}
 
Example #2
Source File: GuicySessionManager.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Inject
public GuicySessionManager(SessionDAO sessionDAO, CacheManager cacheManager, @Named(PROP_SESSION_LISTENERS) Set<SessionListener> listeners, SessionConfig config) {
	super();
	this.globalSessionTimeoutInSecs = config.getDefaultSessionTimeoutInSecs();
	setSessionDAO(sessionDAO);
	setCacheManager(cacheManager);		
	setSessionListeners(listeners);
}
 
Example #3
Source File: SecurityModule.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureShiro() {
   bindSessionDAO(bind(SessionDAO.class));
   bindCacheManager(bind(CacheManager.class));
   bindAuthenticationDAO(bind(AuthenticationDAO.class));
   bindAuthorizationDAO(bind(AuthorizationDAO.class));
   bindPrincipalResolver(bind(PrincipalResolver.class));
   bindCredentialsHashingStrategy(bind(CredentialsHashingStrategy.class));
   expose(CredentialsHashingStrategy.class);
   bindRealm().to(GuicedIrisRealm.class);
}
 
Example #4
Source File: ShiroConfig.java    From erp-framework with MIT License 5 votes vote down vote up
/**
 * SessionDAO的作用为Session提供CRUD并进行持久化的一个shiro组件
 * MemorySessionDAO 直接在内存中进行会话维护
 * EnterpriseCacheSessionDAO  提供了缓存功能的会话维护,默认情况下使用MapCache实现,内部使用ConcurrentHashMap保存缓存的会话。
 * @return
 */
@Bean
public SessionDAO sessionDao() {
    RedisSessionDAO redisSessionDAO = new RedisSessionDAO();
    redisSessionDAO.setKeyPrefix("erp_");
    redisSessionDAO.setRedisManager(redisManager());
    return redisSessionDAO;
}
 
Example #5
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 #6
Source File: SSOServiceImpl.java    From nano-framework with Apache License 2.0 5 votes vote down vote up
@Override
public void delete(Session session) {
    final SessionDAO sessionDAO = getSessionDAO();
    if(sessionDAO != null) {
        sessionDAO.delete(session);
    }
}
 
Example #7
Source File: SSOServiceImpl.java    From nano-framework with Apache License 2.0 5 votes vote down vote up
@Override
public void update(Session session) throws UnknownSessionException {
    final SessionDAO sessionDAO = getSessionDAO();
    if(sessionDAO != null) {
        sessionDAO.update(session);
    }
}
 
Example #8
Source File: ShiroAutoConfiguration.java    From utils with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public SessionDAO sessionDAO(CacheManager cacheManager) {
    EnterpriseCacheSessionDAO dao = new EnterpriseCacheSessionDAO();
    dao.setActiveSessionsCacheName(shiroSessionProperties.getActiveSessionsCacheName());
    Class<? extends SessionIdGenerator> idGenerator = shiroSessionProperties.getIdGenerator();
    if (idGenerator != null) {
        SessionIdGenerator sessionIdGenerator = BeanUtils.instantiate(idGenerator);
        dao.setSessionIdGenerator(sessionIdGenerator);
    }
    dao.setCacheManager(cacheManager);

    return dao;
}
 
Example #9
Source File: SSOServiceImpl.java    From nano-framework with Apache License 2.0 5 votes vote down vote up
@Override
public Session readSession(Serializable sessionId) throws UnknownSessionException {
    final SessionDAO sessionDAO = getSessionDAO();
    if(sessionDAO != null) {
        sessionDAO.readSession(sessionId);
    }
    
    return null;
}
 
Example #10
Source File: NexusWebSecurityManager.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void destroy() {
  // underlying manager cannot be restarted, so avoid shutting it down when bouncing the service
  if (isShuttingDown()) {
    super.destroy();
  }
  else {
    // null out the session cache to force it to be recreated on the next request after bouncing
    SessionDAO sessionDAO = ((NexusWebSessionManager) getSessionManager()).getSessionDAO();
    if (sessionDAO instanceof CachingSessionDAO) {
      ((CachingSessionDAO) sessionDAO).setActiveSessionsCache(null);
    }
  }
}
 
Example #11
Source File: ShiroConfiguration.java    From spring-boot-shiro-orientdb with Apache License 2.0 4 votes vote down vote up
@Bean
public SessionDAO sessionDao() {
    return new HazelcastSessionDao();
}
 
Example #12
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;
}
 
Example #13
Source File: UserAdminManagerController.java    From MultimediaDesktop with Apache License 2.0 4 votes vote down vote up
public void setSessionDao(SessionDAO sessionDao) {
	this.sessionDao = sessionDao;
}
 
Example #14
Source File: ShiroConfiguration.java    From jee-universal-bms with Apache License 2.0 4 votes vote down vote up
@Bean
public SessionDAO getSessionDao() {
    ShiroRedisSessionDao sessionDAO = new ShiroRedisSessionDao();
    sessionDAO.setKeyPrefix(Constants.SHIRO_REDIS_SESSION);
    return sessionDAO;
}
 
Example #15
Source File: ShiroService.java    From VideoMeeting with Apache License 2.0 4 votes vote down vote up
@Autowired
public void setSessionDAO(SessionDAO sessionDAO) {
	this.sessionDAO = sessionDAO;
}
 
Example #16
Source File: ShiroService.java    From VideoMeeting with Apache License 2.0 4 votes vote down vote up
public SessionDAO getSessionDAO() {
	return sessionDAO;
}
 
Example #17
Source File: ShiroCustomizer.java    From jsets-shiro-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
public SessionDAO getSessionDAO() {
	return sessionDAO;
}
 
Example #18
Source File: ShiroConfig.java    From yyblog with MIT License 4 votes vote down vote up
@Bean
public SessionDAO sessionDAO() {
    
    return new MemorySessionDAO();
}
 
Example #19
Source File: MockDaoSecurityModule.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
@Override
protected void bindSessionDAO(AnnotatedBindingBuilder<SessionDAO> bind) {
   bind.toInstance(EasyMock.createMock(SessionDAO.class));
   expose(SessionDAO.class);
}
 
Example #20
Source File: SecurityModule.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
protected void bindSessionDAO(AnnotatedBindingBuilder<SessionDAO> bind) {
   bind.to(GuicedCassandraSessionDAO.class);
}
 
Example #21
Source File: ShiroCustomizer.java    From jsets-shiro-spring-boot-starter with Apache License 2.0 2 votes vote down vote up
/**
 * 设置SessionDAO
 * <br>
 * 如果组件提供的session缓存方式(内存、ehcache、redis)无法满足需求,可设置此项定制session持久化
 * 
 * @param sessionDAO  see org.apache.shiro.session.mgt.eis.SessionDAO
 */
public ShiroCustomizer setSessionDAO(SessionDAO sessionDAO) {
	this.sessionDAO = sessionDAO;
	return self();
}