Search in sources :

Example 31 with MongoDbConnectionFactory

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

the class CasAcceptableUsagePolicyMongoDbConfiguration method mongoAcceptableUsagePolicyTemplate.

@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@Bean
@ConditionalOnMissingBean(name = "mongoAcceptableUsagePolicyTemplate")
public MongoOperations mongoAcceptableUsagePolicyTemplate(final ConfigurableApplicationContext applicationContext, final CasConfigurationProperties casProperties, @Qualifier(CasSSLContext.BEAN_NAME) final CasSSLContext casSslContext) throws Exception {
    return BeanSupplier.of(MongoOperations.class).when(AcceptableUsagePolicyRepository.CONDITION_AUP_ENABLED.given(applicationContext.getEnvironment())).supply(() -> {
        val mongo = casProperties.getAcceptableUsagePolicy().getMongo();
        val factory = new MongoDbConnectionFactory(casSslContext.getSslContext());
        val mongoTemplate = factory.buildMongoTemplate(mongo);
        MongoDbConnectionFactory.createCollection(mongoTemplate, mongo.getCollection(), mongo.isDropCollection());
        return mongoTemplate;
    }).otherwiseProxy().get();
}
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)

Example 32 with MongoDbConnectionFactory

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

the class OidcJwksMongoDbConfiguration method mongoOidcJsonWebKeystoreTemplate.

@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@Bean
@ConditionalOnMissingBean(name = "mongoOidcJsonWebKeystoreTemplate")
public MongoOperations mongoOidcJsonWebKeystoreTemplate(final ConfigurableApplicationContext applicationContext, final CasConfigurationProperties casProperties, @Qualifier(CasSSLContext.BEAN_NAME) final CasSSLContext casSslContext) {
    return BeanSupplier.of(MongoOperations.class).when(CONDITION_HOST.given(applicationContext.getEnvironment())).and(CONDITION_COLLECTION.given(applicationContext.getEnvironment())).supply(() -> {
        val mongo = casProperties.getAuthn().getOidc().getJwks().getMongo();
        val factory = new MongoDbConnectionFactory(casSslContext.getSslContext());
        val mongoTemplate = factory.buildMongoTemplate(mongo);
        MongoDbConnectionFactory.createCollection(mongoTemplate, mongo.getCollection(), mongo.isDropCollection());
        return mongoTemplate;
    }).otherwiseProxy().get();
}
Also used : lombok.val(lombok.val) MongoDbConnectionFactory(org.apereo.cas.mongo.MongoDbConnectionFactory) MongoOperations(org.springframework.data.mongodb.core.MongoOperations) 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)

Example 33 with MongoDbConnectionFactory

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

the class SamlIdPMongoDbIdPMetadataConfiguration method mongoDbSamlIdPMetadataTemplate.

@ConditionalOnMissingBean(name = "mongoDbSamlIdPMetadataTemplate")
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public MongoOperations mongoDbSamlIdPMetadataTemplate(final ConfigurableApplicationContext applicationContext, final CasConfigurationProperties casProperties, @Qualifier(CasSSLContext.BEAN_NAME) final CasSSLContext casSslContext) {
    return BeanSupplier.of(MongoOperations.class).when(CONDITION.given(applicationContext.getEnvironment())).supply(() -> {
        val idp = casProperties.getAuthn().getSamlIdp();
        val mongo = idp.getMetadata().getMongo();
        val factory = new MongoDbConnectionFactory(casSslContext.getSslContext());
        val mongoTemplate = factory.buildMongoTemplate(mongo);
        MongoDbConnectionFactory.createCollection(mongoTemplate, mongo.getIdpMetadataCollection(), mongo.isDropCollection());
        return mongoTemplate;
    }).otherwiseProxy().get();
}
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)

Example 34 with MongoDbConnectionFactory

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

the class SamlIdPMongoDbRegisteredServiceMetadataConfiguration method mongoDbSamlMetadataResolverTemplate.

@ConditionalOnMissingBean(name = "mongoDbSamlMetadataResolverTemplate")
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public MongoOperations mongoDbSamlMetadataResolverTemplate(final CasConfigurationProperties casProperties, @Qualifier(CasSSLContext.BEAN_NAME) final CasSSLContext casSslContext) {
    val mongo = casProperties.getAuthn().getSamlIdp().getMetadata().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) OpenSamlConfigBean(org.apereo.cas.support.saml.OpenSamlConfigBean) Bean(org.springframework.context.annotation.Bean)

Example 35 with MongoDbConnectionFactory

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

the class MongoDbYubiKeyConfiguration method mongoYubiKeyTemplate.

@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@Bean
public MongoOperations mongoYubiKeyTemplate(@Qualifier(CasSSLContext.BEAN_NAME) final CasSSLContext casSslContext, final CasConfigurationProperties casProperties) {
    val mongo = casProperties.getAuthn().getMfa().getYubikey().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)

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