use of org.apereo.cas.adaptors.u2f.storage.U2FJsonResourceDeviceRepository 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);
}
Aggregations