org.apereo.cas.config.CasMongoDbThrottlingConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cas-server-support-throttle-mongo Show documentation
Show all versions of cas-server-support-throttle-mongo Show documentation
cas-server-support-throttle-mongo
package org.apereo.cas.config;
import org.apereo.cas.configuration.CasConfigurationProperties;
import org.apereo.cas.mongo.MongoDbConnectionFactory;
import org.apereo.cas.web.support.MongoDbThrottledSubmissionHandlerInterceptorAdapter;
import org.apereo.cas.web.support.ThrottledSubmissionHandlerConfigurationContext;
import org.apereo.cas.web.support.ThrottledSubmissionHandlerInterceptor;
import lombok.val;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.net.ssl.SSLContext;
/**
* This is {@link CasMongoDbThrottlingConfiguration}.
*
* @author Misagh Moayyed
* @since 5.3.0
*/
@Configuration(value = "casMongoDbThrottlingConfiguration", proxyBeanMethods = false)
@EnableConfigurationProperties(CasConfigurationProperties.class)
public class CasMongoDbThrottlingConfiguration {
@Autowired
private CasConfigurationProperties casProperties;
@Autowired
@Qualifier("authenticationThrottlingConfigurationContext")
private ObjectProvider authenticationThrottlingConfigurationContext;
@Autowired
@Qualifier("sslContext")
private ObjectProvider sslContext;
@Autowired
@Bean
@RefreshScope
public ThrottledSubmissionHandlerInterceptor authenticationThrottle() {
val mongo = casProperties.getAudit().getMongo();
val factory = new MongoDbConnectionFactory(sslContext.getObject());
val mongoTemplate = factory.buildMongoTemplate(mongo);
MongoDbConnectionFactory.createCollection(mongoTemplate, mongo.getCollection(), mongo.isDropCollection());
return new MongoDbThrottledSubmissionHandlerInterceptorAdapter(
authenticationThrottlingConfigurationContext.getObject(), mongoTemplate, mongo.getCollection());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy