Search in sources :

Example 21 with MongoDbConnectionFactory

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

the class MongoDbYubiKeyConfiguration method mongoYubiKeyTemplate.

@RefreshScope
@Bean
public MongoTemplate mongoYubiKeyTemplate() {
    final YubiKeyMultifactorProperties.MongoDb mongo = casProperties.getAuthn().getMfa().getYubikey().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) YubiKeyMultifactorProperties(org.apereo.cas.configuration.model.support.mfa.YubiKeyMultifactorProperties) MongoTemplate(org.springframework.data.mongodb.core.MongoTemplate) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Bean(org.springframework.context.annotation.Bean)

Example 22 with MongoDbConnectionFactory

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

the class MongoDbWebAuthnConfiguration method mongoWebAuthnTemplate.

@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@Bean
public MongoOperations mongoWebAuthnTemplate(final CasConfigurationProperties casProperties, @Qualifier(CasSSLContext.BEAN_NAME) final CasSSLContext casSslContext) {
    val mongo = casProperties.getAuthn().getMfa().getWebAuthn().getMongo();
    val factory = new MongoDbConnectionFactory(casSslContext.getSslContext());
    val mongoTemplate = factory.buildMongoTemplate(mongo);
    MongoDbConnectionFactory.createCollection(mongoTemplate, mongo.getCollection(), mongo.isDropCollection());
    return mongoTemplate;
}
Also used : lombok.val(lombok.val) MongoDbConnectionFactory(org.apereo.cas.mongo.MongoDbConnectionFactory) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Bean(org.springframework.context.annotation.Bean)

Example 23 with MongoDbConnectionFactory

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

the class U2FMongoDbConfiguration method u2fDeviceRepository.

@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public U2FDeviceRepository u2fDeviceRepository(final CasConfigurationProperties casProperties, @Qualifier("u2fRegistrationRecordCipherExecutor") final CipherExecutor u2fRegistrationRecordCipherExecutor, @Qualifier(CasSSLContext.BEAN_NAME) final CasSSLContext casSslContext) {
    val u2f = casProperties.getAuthn().getMfa().getU2f();
    val factory = new MongoDbConnectionFactory(casSslContext.getSslContext());
    val mongoProps = u2f.getMongo();
    val mongoTemplate = factory.buildMongoTemplate(mongoProps);
    MongoDbConnectionFactory.createCollection(mongoTemplate, mongoProps.getCollection(), mongoProps.isDropCollection());
    final LoadingCache<String, String> requestStorage = Caffeine.newBuilder().expireAfterWrite(u2f.getCore().getExpireRegistrations(), u2f.getCore().getExpireRegistrationsTimeUnit()).build(key -> StringUtils.EMPTY);
    return new U2FMongoDbDeviceRepository(requestStorage, mongoTemplate, u2fRegistrationRecordCipherExecutor, casProperties);
}
Also used : lombok.val(lombok.val) U2FMongoDbDeviceRepository(org.apereo.cas.adaptors.u2f.storage.U2FMongoDbDeviceRepository) MongoDbConnectionFactory(org.apereo.cas.mongo.MongoDbConnectionFactory) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Bean(org.springframework.context.annotation.Bean)

Example 24 with MongoDbConnectionFactory

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

the class CasConsentMongoDbConfiguration method consentRepository.

@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public ConsentRepository consentRepository(final CasConfigurationProperties casProperties, @Qualifier(CasSSLContext.BEAN_NAME) final CasSSLContext casSslContext) {
    val mongo = casProperties.getConsent().getMongo();
    val factory = new MongoDbConnectionFactory(casSslContext.getSslContext());
    val mongoTemplate = factory.buildMongoTemplate(mongo);
    MongoDbConnectionFactory.createCollection(mongoTemplate, mongo.getCollection(), mongo.isDropCollection());
    return new MongoDbConsentRepository(mongoTemplate, mongo.getCollection());
}
Also used : lombok.val(lombok.val) MongoDbConnectionFactory(org.apereo.cas.mongo.MongoDbConnectionFactory) MongoDbConsentRepository(org.apereo.cas.consent.MongoDbConsentRepository) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Bean(org.springframework.context.annotation.Bean)

Example 25 with MongoDbConnectionFactory

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

the class MongoDbPasswordlessAuthenticationConfiguration method mongoDbPasswordlessAuthenticationTemplate.

@ConditionalOnMissingBean(name = "mongoDbPasswordlessAuthenticationTemplate")
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public MongoOperations mongoDbPasswordlessAuthenticationTemplate(final CasConfigurationProperties casProperties, @Qualifier(CasSSLContext.BEAN_NAME) final CasSSLContext casSslContext) {
    val mongo = casProperties.getAuthn().getPasswordless().getAccounts().getMongo();
    val factory = new MongoDbConnectionFactory(casSslContext.getSslContext());
    val mongoTemplate = factory.buildMongoTemplate(mongo);
    MongoDbConnectionFactory.createCollection(mongoTemplate, mongo.getCollection(), mongo.isDropCollection());
    return mongoTemplate;
}
Also used : lombok.val(lombok.val) MongoDbConnectionFactory(org.apereo.cas.mongo.MongoDbConnectionFactory) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) 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