Search in sources :

Example 1 with U2FMongoDbDeviceRepository

use of org.apereo.cas.adaptors.u2f.storage.U2FMongoDbDeviceRepository 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 2 with U2FMongoDbDeviceRepository

use of org.apereo.cas.adaptors.u2f.storage.U2FMongoDbDeviceRepository 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)

Aggregations

U2FMongoDbDeviceRepository (org.apereo.cas.adaptors.u2f.storage.U2FMongoDbDeviceRepository)2 MongoDbConnectionFactory (org.apereo.cas.mongo.MongoDbConnectionFactory)2 Bean (org.springframework.context.annotation.Bean)2 lombok.val (lombok.val)1 U2FMultifactorProperties (org.apereo.cas.configuration.model.support.mfa.U2FMultifactorProperties)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 MongoTemplate (org.springframework.data.mongodb.core.MongoTemplate)1