Search in sources :

Example 1 with MongoDbAuditTrailManager

use of org.apereo.cas.audit.MongoDbAuditTrailManager in project cas by apereo.

the class CasSupportMongoDbAuditConfiguration method mongoDbAuditTrailManager.

@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnMissingBean(name = "mongoDbAuditTrailManager")
public AuditTrailManager mongoDbAuditTrailManager(final CasConfigurationProperties casProperties, @Qualifier(CasSSLContext.BEAN_NAME) final CasSSLContext casSslContext) {
    val mongo = casProperties.getAudit().getMongo();
    val factory = new MongoDbConnectionFactory(casSslContext.getSslContext());
    val mongoTemplate = factory.buildMongoTemplate(mongo);
    MongoDbConnectionFactory.createCollection(mongoTemplate, mongo.getCollection(), mongo.isDropCollection());
    return new MongoDbAuditTrailManager(mongoTemplate, mongo.getCollection(), mongo.isAsynchronous());
}
Also used : lombok.val(lombok.val) MongoDbAuditTrailManager(org.apereo.cas.audit.MongoDbAuditTrailManager) 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 2 with MongoDbAuditTrailManager

use of org.apereo.cas.audit.MongoDbAuditTrailManager 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

MongoDbAuditTrailManager (org.apereo.cas.audit.MongoDbAuditTrailManager)2 MongoDbConnectionFactory (org.apereo.cas.mongo.MongoDbConnectionFactory)2 Bean (org.springframework.context.annotation.Bean)2 lombok.val (lombok.val)1 AuditMongoDbProperties (org.apereo.cas.configuration.model.core.audit.AuditMongoDbProperties)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 MongoTemplate (org.springframework.data.mongodb.core.MongoTemplate)1