Search in sources :

Example 1 with U2FMultifactorProperties

use of org.apereo.cas.configuration.model.support.mfa.U2FMultifactorProperties 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 U2FMultifactorProperties

use of org.apereo.cas.configuration.model.support.mfa.U2FMultifactorProperties in project cas by apereo.

the class U2FConfiguration method u2fDeviceRepository.

@ConditionalOnMissingBean(name = "u2fDeviceRepository")
@Bean
public U2FDeviceRepository u2fDeviceRepository() {
    final U2FMultifactorProperties u2f = casProperties.getAuthn().getMfa().getU2f();
    final LoadingCache<String, String> requestStorage = Caffeine.newBuilder().expireAfterWrite(u2f.getExpireDevices(), u2f.getExpireDevicesTimeUnit()).build(key -> StringUtils.EMPTY);
    if (u2f.getJson().getLocation() != null) {
        return new U2FJsonResourceDeviceRepository(requestStorage, u2f.getJson().getLocation(), u2f.getExpireDevices(), u2f.getExpireDevicesTimeUnit());
    }
    if (u2f.getGroovy().getLocation() != null) {
        return new U2FGroovyResourceDeviceRepository(requestStorage, u2f.getGroovy().getLocation(), u2f.getExpireDevices(), u2f.getExpireDevicesTimeUnit());
    }
    if (StringUtils.isNotBlank(u2f.getRest().getUrl())) {
        return new U2FRestResourceDeviceRepository(requestStorage, u2f.getExpireDevices(), u2f.getExpireDevicesTimeUnit(), u2f.getRest());
    }
    final LoadingCache<String, Map<String, String>> userStorage = Caffeine.newBuilder().expireAfterWrite(u2f.getExpireDevices(), u2f.getExpireDevicesTimeUnit()).build(key -> new HashMap<>());
    return new U2FInMemoryDeviceRepository(userStorage, requestStorage);
}
Also used : U2FRestResourceDeviceRepository(org.apereo.cas.adaptors.u2f.storage.U2FRestResourceDeviceRepository) U2FInMemoryDeviceRepository(org.apereo.cas.adaptors.u2f.storage.U2FInMemoryDeviceRepository) U2FJsonResourceDeviceRepository(org.apereo.cas.adaptors.u2f.storage.U2FJsonResourceDeviceRepository) U2FGroovyResourceDeviceRepository(org.apereo.cas.adaptors.u2f.storage.U2FGroovyResourceDeviceRepository) U2FMultifactorProperties(org.apereo.cas.configuration.model.support.mfa.U2FMultifactorProperties) HashMap(java.util.HashMap) Map(java.util.Map) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with U2FMultifactorProperties

use of org.apereo.cas.configuration.model.support.mfa.U2FMultifactorProperties in project cas by apereo.

the class U2FJpaConfiguration method u2fDeviceRepository.

@Bean
public U2FDeviceRepository u2fDeviceRepository() {
    final U2FMultifactorProperties u2f = casProperties.getAuthn().getMfa().getU2f();
    final LoadingCache<String, String> requestStorage = Caffeine.newBuilder().expireAfterWrite(u2f.getExpireRegistrations(), u2f.getExpireRegistrationsTimeUnit()).build(key -> StringUtils.EMPTY);
    final U2FJpaDeviceRepository repo = new U2FJpaDeviceRepository(requestStorage, u2f.getExpireRegistrations(), u2f.getExpireDevicesTimeUnit());
    repo.setCipherExecutor(this.u2fRegistrationRecordCipherExecutor);
    return repo;
}
Also used : U2FJpaDeviceRepository(org.apereo.cas.adaptors.u2f.storage.U2FJpaDeviceRepository) U2FMultifactorProperties(org.apereo.cas.configuration.model.support.mfa.U2FMultifactorProperties) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Aggregations

U2FMultifactorProperties (org.apereo.cas.configuration.model.support.mfa.U2FMultifactorProperties)3 Bean (org.springframework.context.annotation.Bean)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 U2FGroovyResourceDeviceRepository (org.apereo.cas.adaptors.u2f.storage.U2FGroovyResourceDeviceRepository)1 U2FInMemoryDeviceRepository (org.apereo.cas.adaptors.u2f.storage.U2FInMemoryDeviceRepository)1 U2FJpaDeviceRepository (org.apereo.cas.adaptors.u2f.storage.U2FJpaDeviceRepository)1 U2FJsonResourceDeviceRepository (org.apereo.cas.adaptors.u2f.storage.U2FJsonResourceDeviceRepository)1 U2FMongoDbDeviceRepository (org.apereo.cas.adaptors.u2f.storage.U2FMongoDbDeviceRepository)1 U2FRestResourceDeviceRepository (org.apereo.cas.adaptors.u2f.storage.U2FRestResourceDeviceRepository)1 MongoDbConnectionFactory (org.apereo.cas.mongo.MongoDbConnectionFactory)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 MongoTemplate (org.springframework.data.mongodb.core.MongoTemplate)1 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)1