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;
}
Aggregations