Search in sources :

Example 1 with JsonMultifactorAuthenticationTrustStorage

use of org.apereo.cas.trusted.authentication.storage.JsonMultifactorAuthenticationTrustStorage in project cas by apereo.

the class MultifactorAuthnTrustConfiguration method mfaTrustEngine.

@ConditionalOnMissingBean(name = "mfaTrustEngine")
@Bean
@RefreshScope
public MultifactorAuthenticationTrustStorage mfaTrustEngine() {
    final TrustedDevicesMultifactorProperties trusted = casProperties.getAuthn().getMfa().getTrusted();
    final LoadingCache<String, MultifactorAuthenticationTrustRecord> storage = Caffeine.newBuilder().initialCapacity(INITIAL_CACHE_SIZE).maximumSize(MAX_CACHE_SIZE).expireAfterWrite(trusted.getExpiration(), trusted.getTimeUnit()).build(s -> {
        LOGGER.error("Load operation of the cache is not supported.");
        return null;
    });
    storage.asMap();
    final BaseMultifactorAuthenticationTrustStorage m;
    if (trusted.getJson().getLocation() != null) {
        LOGGER.debug("Storing trusted device records inside the JSON resource [{}]", trusted.getJson().getLocation());
        m = new JsonMultifactorAuthenticationTrustStorage(trusted.getJson().getLocation());
    } else {
        LOGGER.warn("Storing trusted device records in runtime memory. Changes and records will be lost upon CAS restarts");
        m = new InMemoryMultifactorAuthenticationTrustStorage(storage);
    }
    m.setCipherExecutor(mfaTrustCipherExecutor());
    return m;
}
Also used : InMemoryMultifactorAuthenticationTrustStorage(org.apereo.cas.trusted.authentication.storage.InMemoryMultifactorAuthenticationTrustStorage) MultifactorAuthenticationTrustRecord(org.apereo.cas.trusted.authentication.api.MultifactorAuthenticationTrustRecord) BaseMultifactorAuthenticationTrustStorage(org.apereo.cas.trusted.authentication.storage.BaseMultifactorAuthenticationTrustStorage) TrustedDevicesMultifactorProperties(org.apereo.cas.configuration.model.support.mfa.TrustedDevicesMultifactorProperties) JsonMultifactorAuthenticationTrustStorage(org.apereo.cas.trusted.authentication.storage.JsonMultifactorAuthenticationTrustStorage) 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)

Aggregations

TrustedDevicesMultifactorProperties (org.apereo.cas.configuration.model.support.mfa.TrustedDevicesMultifactorProperties)1 MultifactorAuthenticationTrustRecord (org.apereo.cas.trusted.authentication.api.MultifactorAuthenticationTrustRecord)1 BaseMultifactorAuthenticationTrustStorage (org.apereo.cas.trusted.authentication.storage.BaseMultifactorAuthenticationTrustStorage)1 InMemoryMultifactorAuthenticationTrustStorage (org.apereo.cas.trusted.authentication.storage.InMemoryMultifactorAuthenticationTrustStorage)1 JsonMultifactorAuthenticationTrustStorage (org.apereo.cas.trusted.authentication.storage.JsonMultifactorAuthenticationTrustStorage)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Bean (org.springframework.context.annotation.Bean)1