Search in sources :

Example 1 with YubiKeyAuthenticationHandler

use of org.apereo.cas.adaptors.yubikey.YubiKeyAuthenticationHandler in project cas by apereo.

the class YubiKeyAuthenticationEventExecutionPlanConfiguration method yubikeyAuthenticationHandler.

@Bean
@RefreshScope
public YubiKeyAuthenticationHandler yubikeyAuthenticationHandler() {
    final MultifactorAuthenticationProperties.YubiKey yubi = this.casProperties.getAuthn().getMfa().getYubikey();
    if (StringUtils.isBlank(yubi.getSecretKey())) {
        throw new IllegalArgumentException("Yubikey secret key cannot be blank");
    }
    if (yubi.getClientId() <= 0) {
        throw new IllegalArgumentException("Yubikey client id is undefined");
    }
    final YubiKeyAuthenticationHandler handler = new YubiKeyAuthenticationHandler(yubi.getName(), servicesManager, yubikeyPrincipalFactory(), yubi.getClientId(), yubi.getSecretKey(), this.registry);
    if (!casProperties.getAuthn().getMfa().getYubikey().getApiUrls().isEmpty()) {
        final String[] urls = casProperties.getAuthn().getMfa().getYubikey().getApiUrls().toArray(new String[] {});
        handler.getClient().setWsapiUrls(urls);
    }
    return handler;
}
Also used : MultifactorAuthenticationProperties(org.apereo.cas.configuration.model.support.mfa.MultifactorAuthenticationProperties) YubiKeyAuthenticationHandler(org.apereo.cas.adaptors.yubikey.YubiKeyAuthenticationHandler) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

YubiKeyAuthenticationHandler (org.apereo.cas.adaptors.yubikey.YubiKeyAuthenticationHandler)1 MultifactorAuthenticationProperties (org.apereo.cas.configuration.model.support.mfa.MultifactorAuthenticationProperties)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