Search in sources :

Example 1 with YubicoClient

use of com.yubico.client.v2.YubicoClient in project cas by apereo.

the class YubiKeyAuthenticationEventExecutionPlanConfiguration method yubicoClient.

@RefreshScope
@Bean
@ConditionalOnMissingBean(name = "yubicoClient")
public YubicoClient yubicoClient() {
    final YubiKeyMultifactorProperties 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 YubicoClient client = YubicoClient.getClient(yubi.getClientId(), yubi.getSecretKey());
    if (!yubi.getApiUrls().isEmpty()) {
        final String[] urls = yubi.getApiUrls().toArray(new String[] {});
        client.setWsapiUrls(urls);
    }
    return client;
}
Also used : YubiKeyMultifactorProperties(org.apereo.cas.configuration.model.support.mfa.YubiKeyMultifactorProperties) YubicoClient(com.yubico.client.v2.YubicoClient) 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

YubicoClient (com.yubico.client.v2.YubicoClient)1 YubiKeyMultifactorProperties (org.apereo.cas.configuration.model.support.mfa.YubiKeyMultifactorProperties)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