本文整理汇总了Java中org.apache.shiro.session.mgt.eis.SessionDAO类的典型用法代码示例。如果您正苦于以下问题:Java SessionDAO类的具体用法?Java SessionDAO怎么用?Java SessionDAO使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SessionDAO类属于org.apache.shiro.session.mgt.eis包,在下文中一共展示了SessionDAO类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureShiroWeb
import org.apache.shiro.session.mgt.eis.SessionDAO; //导入依赖的package包/类
@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);
}
示例2: sessionDAO
import org.apache.shiro.session.mgt.eis.SessionDAO; //导入依赖的package包/类
@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;
}
示例3: testBasicOperations
import org.apache.shiro.session.mgt.eis.SessionDAO; //导入依赖的package包/类
@Test
public void testBasicOperations() throws Exception {
final SessionDAO dao = new FileBasedSessionDAO(rootDir.getRoot().toPath());
final Session initial = new SimpleSession();
// A new session ID would be issued.
final Serializable sessionId = dao.create(initial);
assertThat(sessionId).isEqualTo(initial.getId());
assertThat(countSessions(dao)).isOne();
final Session session = dao.readSession(sessionId);
assertThat(session).isEqualTo(initial);
// Change session's last accessed time locally.
Thread.sleep(10);
session.touch();
assertThat(dao.readSession(sessionId).getLastAccessTime())
.isNotEqualTo(session.getLastAccessTime());
// Update the session.
dao.update(session);
assertThat(dao.readSession(sessionId).getLastAccessTime())
.isEqualTo(session.getLastAccessTime());
// Delete the session.
dao.delete(session);
// No session exists with the specified session ID.
assertThatThrownBy(() -> dao.readSession(sessionId))
.isInstanceOf(UnknownSessionException.class);
assertThat(countSessions(dao)).isZero();
}
示例4: countSessions
import org.apache.shiro.session.mgt.eis.SessionDAO; //导入依赖的package包/类
private static int countSessions(SessionDAO dao) {
int count = 0;
for (Session ignored : dao.getActiveSessions()) {
count++;
}
return count;
}
示例5: readSession
import org.apache.shiro.session.mgt.eis.SessionDAO; //导入依赖的package包/类
@Override
public Session readSession(Serializable sessionId) throws UnknownSessionException {
final SessionDAO sessionDAO = getSessionDAO();
if(sessionDAO != null) {
sessionDAO.readSession(sessionId);
}
return null;
}
示例6: update
import org.apache.shiro.session.mgt.eis.SessionDAO; //导入依赖的package包/类
@Override
public void update(Session session) throws UnknownSessionException {
final SessionDAO sessionDAO = getSessionDAO();
if(sessionDAO != null) {
sessionDAO.update(session);
}
}
示例7: delete
import org.apache.shiro.session.mgt.eis.SessionDAO; //导入依赖的package包/类
@Override
public void delete(Session session) {
final SessionDAO sessionDAO = getSessionDAO();
if(sessionDAO != null) {
sessionDAO.delete(session);
}
}
示例8: getSessionDAO
import org.apache.shiro.session.mgt.eis.SessionDAO; //导入依赖的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;
}
示例9: CentralDogmaSessionManager
import org.apache.shiro.session.mgt.eis.SessionDAO; //导入依赖的package包/类
CentralDogmaSessionManager(SessionDAO sessionDao) {
setSessionDAO(sessionDao);
setSessionValidationInterval(Duration.ofHours(1).toMillis());
}
示例10: getSessionDAO
import org.apache.shiro.session.mgt.eis.SessionDAO; //导入依赖的package包/类
public SessionDAO getSessionDAO() {
return sessionDAO;
}
示例11: setSessionDAO
import org.apache.shiro.session.mgt.eis.SessionDAO; //导入依赖的package包/类
@Autowired
public void setSessionDAO(SessionDAO sessionDAO) {
this.sessionDAO = sessionDAO;
}
示例12: setSessionDAO
import org.apache.shiro.session.mgt.eis.SessionDAO; //导入依赖的package包/类
public void setSessionDAO(SessionDAO sessionDAO) {
this.sessionDAO = sessionDAO;
applyCacheManagerToSessionDAO();
}
示例13: getSessionDAO
import org.apache.shiro.session.mgt.eis.SessionDAO; //导入依赖的package包/类
public SessionDAO getSessionDAO() {
return this.sessionDAO;
}
示例14: setSessionDAO
import org.apache.shiro.session.mgt.eis.SessionDAO; //导入依赖的package包/类
public void setSessionDAO(SessionDAO sessionDAO) {
this.sessionDAO = sessionDAO;
applyCacheManagerToSessionDAO();
}
示例15: getSessionDAO
import org.apache.shiro.session.mgt.eis.SessionDAO; //导入依赖的package包/类
public SessionDAO getSessionDAO() {
return this.sessionDAO;
}