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

The following examples show how to use org.apache.shiro.session.mgt.SessionValidationScheduler. 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: ShiroAutoConfiguration.java    From spring-boot-shiro with Apache License 2.0 6 votes vote down vote up
@Bean(name = "sessionValidationScheduler")
@DependsOn(value = {"sessionManager"})
@ConditionalOnMissingBean(SessionValidationScheduler.class)
public SessionValidationScheduler sessionValidationScheduler(DefaultWebSessionManager sessionManager) {
    ExecutorServiceSessionValidationScheduler validationScheduler = new ExecutorServiceSessionValidationScheduler(sessionManager);
    sessionManager.setDeleteInvalidSessions(shiroSessionProperties.isDeleteInvalidSessions());
    sessionManager.setSessionValidationInterval(shiroSessionProperties.getValidationInterval());
    sessionManager.setSessionValidationSchedulerEnabled(shiroSessionProperties.isValidationSchedulerEnabled());
    sessionManager.setSessionValidationScheduler(validationScheduler);
    return validationScheduler;
}
 
Example #2
Source File: ShiroAutoConfiguration.java    From utils with Apache License 2.0 5 votes vote down vote up
@Bean(name = "sessionValidationScheduler")
@DependsOn(value = {"sessionManager"})
@ConditionalOnMissingBean(SessionValidationScheduler.class)
public SessionValidationScheduler sessionValidationScheduler(DefaultWebSessionManager sessionManager) {
    ExecutorServiceSessionValidationScheduler scheduler = new ExecutorServiceSessionValidationScheduler(sessionManager);
    sessionManager.setDeleteInvalidSessions(shiroSessionProperties.isDeleteInvalidSessions());
    sessionManager.setSessionValidationInterval(shiroSessionProperties.getValidationInterval());
    sessionManager.setSessionValidationSchedulerEnabled(shiroSessionProperties.isValidationSchedulerEnabled());
    sessionManager.setSessionValidationScheduler(scheduler);

    return scheduler;
}
 
Example #3
Source File: NexusWebSessionManager.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * See https://issues.sonatype.org/browse/NEXUS-5727, https://issues.apache.org/jira/browse/SHIRO-443
 */
@Override
protected synchronized void enableSessionValidation() {
  final SessionValidationScheduler scheduler = getSessionValidationScheduler();
  if (scheduler == null) {
    super.enableSessionValidation();
  }
}
 
Example #4
Source File: TestSessionManager.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * See https://issues.sonatype.org/browse/NEXUS-5727, https://issues.apache.org/jira/browse/SHIRO-443
 */
@Override
protected synchronized void enableSessionValidation() {
  final SessionValidationScheduler scheduler = getSessionValidationScheduler();
  if (scheduler == null) {
    log.info("Global session timeout: {} ms", getGlobalSessionTimeout());
    super.enableSessionValidation();
  }
}
 
Example #5
Source File: SecurityGuiceConfigurer.java    From seed with Mozilla Public License 2.0 5 votes vote down vote up
public void configure(Binder binder) {
    // Subject
    SecurityConfig.SubjectConfig subjectConfig = securityConfig.subject();
    Optional.ofNullable(subjectConfig.getContext()).ifPresent(c -> binder.bind(SubjectContext.class).to(c));
    Optional.ofNullable(subjectConfig.getFactory()).ifPresent(f -> binder.bind(SubjectFactory.class).to(f));
    Class<? extends SubjectDAO> subjectDao = subjectConfig.getDao();
    binder.bind(SubjectDAO.class).to(subjectDao != null ? subjectDao : DefaultSubjectDAO.class);

    // Authentication
    SecurityConfig.AuthenticationConfig authenticationConfig = securityConfig.authentication();
    binder.bind(Authenticator.class).to(authenticationConfig.getAuthenticator());
    binder.bind(AuthenticationStrategy.class).to(authenticationConfig.getStrategy());
    binder.bind(CredentialsMatcher.class).to(authenticationConfig.getCredentialsMatcher());

    // Cache configuration
    SecurityConfig.CacheConfig cacheConfig = securityConfig.cache();
    binder.bind(CacheManager.class).to(cacheConfig.getManager());

    // Sessions
    SecurityConfig.SessionConfig sessionConfig = securityConfig.sessions();
    binder.bind(SessionStorageEvaluator.class).to(sessionConfig.getStorageEvaluator());
    Optional.ofNullable(sessionConfig.getValidationScheduler())
            .ifPresent(s -> binder.bind(SessionValidationScheduler.class).to(s));
    binder.bindConstant()
            .annotatedWith(Names.named("shiro.sessionValidationInterval"))
            .to(sessionConfig.getValidationInterval() * 1000);
    binder.bindConstant()
            .annotatedWith(Names.named("shiro.globalSessionTimeout"))
            .to(sessionConfig.getTimeout() * 1000);
}
 
Example #6
Source File: SecurityConfig.java    From seed with Mozilla Public License 2.0 4 votes vote down vote up
public Class<? extends SessionValidationScheduler> getValidationScheduler() {
    return validationScheduler;
}
 
Example #7
Source File: SecurityConfig.java    From seed with Mozilla Public License 2.0 4 votes vote down vote up
public SessionConfig setValidationScheduler(
        Class<? extends SessionValidationScheduler> validationScheduler) {
    this.validationScheduler = validationScheduler;
    return this;
}