Search in sources :

Example 1 with U2FGroovyResourceDeviceRepository

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

Aggregations

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 U2FJsonResourceDeviceRepository (org.apereo.cas.adaptors.u2f.storage.U2FJsonResourceDeviceRepository)1 U2FRestResourceDeviceRepository (org.apereo.cas.adaptors.u2f.storage.U2FRestResourceDeviceRepository)1 U2FMultifactorProperties (org.apereo.cas.configuration.model.support.mfa.U2FMultifactorProperties)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1