use of org.pac4j.oidc.client.AppleClient in project cas by apereo.
the class DefaultDelegatedClientFactory method getOidcClientFrom.
@SneakyThrows
private OidcClient getOidcClientFrom(final Pac4jOidcClientProperties oidc) {
if (oidc.getAzure().isEnabled() && StringUtils.isNotBlank(oidc.getAzure().getId())) {
LOGGER.debug("Building OpenID Connect client for Azure AD...");
val azure = getOidcConfigurationForClient(oidc.getAzure(), AzureAdOidcConfiguration.class);
azure.setTenant(oidc.getAzure().getTenant());
val cfg = new AzureAdOidcConfiguration(azure);
val azureClient = new AzureAdClient(cfg);
configureClient(azureClient, oidc.getAzure());
return azureClient;
}
if (oidc.getGoogle().isEnabled() && StringUtils.isNotBlank(oidc.getGoogle().getId())) {
LOGGER.debug("Building OpenID Connect client for Google...");
val cfg = getOidcConfigurationForClient(oidc.getGoogle(), OidcConfiguration.class);
val googleClient = new GoogleOidcClient(cfg);
configureClient(googleClient, oidc.getGoogle());
return googleClient;
}
if (oidc.getKeycloak().isEnabled() && StringUtils.isNotBlank(oidc.getKeycloak().getId())) {
LOGGER.debug("Building OpenID Connect client for KeyCloak...");
val cfg = getOidcConfigurationForClient(oidc.getKeycloak(), KeycloakOidcConfiguration.class);
cfg.setRealm(oidc.getKeycloak().getRealm());
cfg.setBaseUri(oidc.getKeycloak().getBaseUri());
val kc = new KeycloakOidcClient(cfg);
configureClient(kc, oidc.getKeycloak());
return kc;
}
if (oidc.getApple().isEnabled() && StringUtils.isNotBlank(oidc.getApple().getPrivateKey())) {
LOGGER.debug("Building OpenID Connect client for Apple...");
val cfg = getOidcConfigurationForClient(oidc.getApple(), AppleOidcConfiguration.class);
val factory = new PrivateKeyFactoryBean();
factory.setAlgorithm("EC");
factory.setSingleton(false);
factory.setLocation(ResourceUtils.getResourceFrom(oidc.getApple().getPrivateKey()));
cfg.setPrivateKey((ECPrivateKey) factory.getObject());
cfg.setPrivateKeyID(oidc.getApple().getPrivateKeyId());
cfg.setTeamID(oidc.getApple().getTeamId());
cfg.setTimeout(Beans.newDuration(oidc.getApple().getTimeout()));
val kc = new AppleClient(cfg);
configureClient(kc, oidc.getApple());
return kc;
}
if (oidc.getGeneric().isEnabled()) {
LOGGER.debug("Building generic OpenID Connect client...");
val generic = getOidcConfigurationForClient(oidc.getGeneric(), OidcConfiguration.class);
val oc = new OidcClient(generic);
configureClient(oc, oidc.getGeneric());
return oc;
}
return null;
}
Aggregations