Search in sources :

Example 6 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 7 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 8 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 9 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 10 with MongoDbConnectionFactory

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

the class CasSupportMongoDbAuditConfiguration method mongoDbAuditTrailManager.

@Bean
public AuditTrailManager mongoDbAuditTrailManager() {
    final AuditMongoDbProperties mongo = casProperties.getAudit().getMongo();
    final MongoDbConnectionFactory factory = new MongoDbConnectionFactory();
    final MongoTemplate mongoTemplate = factory.buildMongoTemplate(mongo);
    factory.createCollection(mongoTemplate, mongo.getCollection(), mongo.isDropCollection());
    final MongoDbAuditTrailManager mgmr = new MongoDbAuditTrailManager(mongoTemplate, mongo.getCollection());
    mgmr.setAsynchronous(mongo.isAsynchronous());
    return mgmr;
}
Also used : MongoDbAuditTrailManager(org.apereo.cas.audit.MongoDbAuditTrailManager) MongoDbConnectionFactory(org.apereo.cas.mongo.MongoDbConnectionFactory) MongoTemplate(org.springframework.data.mongodb.core.MongoTemplate) AuditMongoDbProperties(org.apereo.cas.configuration.model.core.audit.AuditMongoDbProperties) Bean(org.springframework.context.annotation.Bean)

Aggregations

MongoDbConnectionFactory (org.apereo.cas.mongo.MongoDbConnectionFactory)16 Bean (org.springframework.context.annotation.Bean)15 MongoTemplate (org.springframework.data.mongodb.core.MongoTemplate)13 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)6 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)3 AuditMongoDbProperties (org.apereo.cas.configuration.model.core.audit.AuditMongoDbProperties)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 Getter (lombok.Getter)1 ToString (lombok.ToString)1 Slf4j (lombok.extern.slf4j.Slf4j)1 U2FMongoDbDeviceRepository (org.apereo.cas.adaptors.u2f.storage.U2FMongoDbDeviceRepository)1 MongoDbAuditTrailManager (org.apereo.cas.audit.MongoDbAuditTrailManager)1 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)1 EventsProperties (org.apereo.cas.configuration.model.core.events.EventsProperties)1 MetricsProperties (org.apereo.cas.configuration.model.core.metrics.MetricsProperties)1