Search in sources :

Example 1 with MongoDbConnectionFactory

use of org.apereo.cas.mongo.MongoDbConnectionFactory in project cas by apereo.

the class SamlIdPMongoDbMetadataConfiguration method mongoDbSamlMetadataResolverTemplate.

@ConditionalOnMissingBean(name = "mongoDbSamlMetadataResolverTemplate")
@Bean
public MongoTemplate mongoDbSamlMetadataResolverTemplate() {
    final MongoDbSamlMetadataProperties mongo = casProperties.getAuthn().getSamlIdp().getMetadata().getMongo();
    final MongoDbConnectionFactory factory = new MongoDbConnectionFactory();
    final MongoTemplate mongoTemplate = factory.buildMongoTemplate(mongo);
    factory.createCollection(mongoTemplate, mongo.getCollection(), mongo.isDropCollection());
    return mongoTemplate;
}
Also used : MongoDbSamlMetadataProperties(org.apereo.cas.configuration.model.support.saml.idp.metadata.MongoDbSamlMetadataProperties) MongoDbConnectionFactory(org.apereo.cas.mongo.MongoDbConnectionFactory) MongoTemplate(org.springframework.data.mongodb.core.MongoTemplate) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) OpenSamlConfigBean(org.apereo.cas.support.saml.OpenSamlConfigBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with MongoDbConnectionFactory

use of org.apereo.cas.mongo.MongoDbConnectionFactory in project cas by apereo.

the class U2FMongoDbConfiguration method u2fDeviceRepository.

@Bean
public U2FDeviceRepository u2fDeviceRepository() {
    final U2FMultifactorProperties u2f = casProperties.getAuthn().getMfa().getU2f();
    final MongoDbConnectionFactory factory = new MongoDbConnectionFactory();
    final U2FMultifactorProperties.MongoDb mongoProps = u2f.getMongo();
    final MongoTemplate mongoTemplate = factory.buildMongoTemplate(mongoProps);
    factory.createCollection(mongoTemplate, mongoProps.getCollection(), mongoProps.isDropCollection());
    final LoadingCache<String, String> requestStorage = Caffeine.newBuilder().expireAfterWrite(u2f.getExpireRegistrations(), u2f.getExpireRegistrationsTimeUnit()).build(key -> StringUtils.EMPTY);
    final U2FMongoDbDeviceRepository repo = new U2FMongoDbDeviceRepository(requestStorage, mongoTemplate, u2f.getExpireRegistrations(), u2f.getExpireDevicesTimeUnit(), mongoProps.getCollection());
    repo.setCipherExecutor(this.u2fRegistrationRecordCipherExecutor);
    return repo;
}
Also used : U2FMongoDbDeviceRepository(org.apereo.cas.adaptors.u2f.storage.U2FMongoDbDeviceRepository) MongoDbConnectionFactory(org.apereo.cas.mongo.MongoDbConnectionFactory) U2FMultifactorProperties(org.apereo.cas.configuration.model.support.mfa.U2FMultifactorProperties) MongoTemplate(org.springframework.data.mongodb.core.MongoTemplate) Bean(org.springframework.context.annotation.Bean)

Example 3 with MongoDbConnectionFactory

use of org.apereo.cas.mongo.MongoDbConnectionFactory in project cas by apereo.

the class CasAcceptableUsagePolicyMongoDbConfiguration method mongoAcceptableUsagePolicyTemplate.

@RefreshScope
@Bean
public MongoTemplate mongoAcceptableUsagePolicyTemplate() {
    final AcceptableUsagePolicyProperties.MongoDb mongo = casProperties.getAcceptableUsagePolicy().getMongo();
    final MongoDbConnectionFactory factory = new MongoDbConnectionFactory();
    final MongoTemplate mongoTemplate = factory.buildMongoTemplate(mongo);
    factory.createCollection(mongoTemplate, mongo.getCollection(), mongo.isDropCollection());
    return mongoTemplate;
}
Also used : MongoDbConnectionFactory(org.apereo.cas.mongo.MongoDbConnectionFactory) MongoTemplate(org.springframework.data.mongodb.core.MongoTemplate) AcceptableUsagePolicyProperties(org.apereo.cas.configuration.model.support.aup.AcceptableUsagePolicyProperties) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Bean(org.springframework.context.annotation.Bean)

Example 4 with MongoDbConnectionFactory

use of org.apereo.cas.mongo.MongoDbConnectionFactory in project cas by apereo.

the class CasConsentMongoDbConfiguration method consentRepository.

@Bean
public ConsentRepository consentRepository() {
    final ConsentProperties.MongoDb mongo = casProperties.getConsent().getMongo();
    final MongoDbConnectionFactory factory = new MongoDbConnectionFactory();
    final MongoTemplate mongoTemplate = factory.buildMongoTemplate(mongo);
    factory.createCollection(mongoTemplate, mongo.getCollection(), mongo.isDropCollection());
    return new MongoDbConsentRepository(mongoTemplate, mongo.getCollection());
}
Also used : MongoDbConnectionFactory(org.apereo.cas.mongo.MongoDbConnectionFactory) ConsentProperties(org.apereo.cas.configuration.model.support.consent.ConsentProperties) MongoTemplate(org.springframework.data.mongodb.core.MongoTemplate) MongoDbConsentRepository(org.apereo.cas.consent.MongoDbConsentRepository) Bean(org.springframework.context.annotation.Bean)

Example 5 with MongoDbConnectionFactory

use of org.apereo.cas.mongo.MongoDbConnectionFactory in project cas by apereo.

the class CasMongoDbThrottlingConfiguration method authenticationThrottle.

@Autowired
@Bean
@RefreshScope
public ThrottledSubmissionHandlerInterceptor authenticationThrottle(@Qualifier("auditTrailExecutionPlan") final AuditTrailExecutionPlan auditTrailExecutionPlan) {
    final ThrottleProperties throttle = casProperties.getAuthn().getThrottle();
    final ThrottleProperties.Failure failure = throttle.getFailure();
    final AuditMongoDbProperties mongo = casProperties.getAudit().getMongo();
    final MongoDbConnectionFactory factory = new MongoDbConnectionFactory();
    final MongoTemplate mongoTemplate = factory.buildMongoTemplate(mongo);
    factory.createCollection(mongoTemplate, mongo.getCollection(), mongo.isDropCollection());
    return new MongoDbThrottledSubmissionHandlerInterceptorAdapter(failure.getThreshold(), failure.getRangeSeconds(), throttle.getUsernameParameter(), auditTrailExecutionPlan, mongoTemplate, failure.getCode(), throttle.getAppcode(), mongo.getCollection());
}
Also used : MongoDbConnectionFactory(org.apereo.cas.mongo.MongoDbConnectionFactory) MongoTemplate(org.springframework.data.mongodb.core.MongoTemplate) MongoDbThrottledSubmissionHandlerInterceptorAdapter(org.apereo.cas.web.support.MongoDbThrottledSubmissionHandlerInterceptorAdapter) AuditMongoDbProperties(org.apereo.cas.configuration.model.core.audit.AuditMongoDbProperties) ThrottleProperties(org.apereo.cas.configuration.model.support.throttle.ThrottleProperties) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Autowired(org.springframework.beans.factory.annotation.Autowired) Bean(org.springframework.context.annotation.Bean)

Aggregations

MongoDbConnectionFactory (org.apereo.cas.mongo.MongoDbConnectionFactory)37 Bean (org.springframework.context.annotation.Bean)32 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)23 lombok.val (lombok.val)21 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)13 MongoTemplate (org.springframework.data.mongodb.core.MongoTemplate)13 SingleCollectionMongoDbProperties (org.apereo.cas.configuration.model.support.mongo.SingleCollectionMongoDbProperties)3 Test (org.junit.jupiter.api.Test)3 U2FMongoDbDeviceRepository (org.apereo.cas.adaptors.u2f.storage.U2FMongoDbDeviceRepository)2 MongoDbAuditTrailManager (org.apereo.cas.audit.MongoDbAuditTrailManager)2 AuditMongoDbProperties (org.apereo.cas.configuration.model.core.audit.AuditMongoDbProperties)2 MongoDbConsentRepository (org.apereo.cas.consent.MongoDbConsentRepository)2 OpenSamlConfigBean (org.apereo.cas.support.saml.OpenSamlConfigBean)2 MongoDbThrottledSubmissionHandlerInterceptorAdapter (org.apereo.cas.web.support.MongoDbThrottledSubmissionHandlerInterceptorAdapter)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 JsonTypeInfo (com.fasterxml.jackson.annotation.JsonTypeInfo)1 DBCollection (com.mongodb.DBCollection)1 Serializable (java.io.Serializable)1 Date (java.util.Date)1 TimeUnit (java.util.concurrent.TimeUnit)1