use of org.keycloak.wellknown.WellKnownProvider in project keycloak by keycloak.
the class UmaConfiguration method create.
public static final UmaConfiguration create(KeycloakSession session) {
WellKnownProvider oidcProvider = session.getProvider(WellKnownProvider.class, OIDCWellKnownProviderFactory.PROVIDER_ID);
OIDCConfigurationRepresentation oidcConfig = OIDCConfigurationRepresentation.class.cast(oidcProvider.getConfig());
UmaConfiguration configuration = new UmaConfiguration();
configuration.setIssuer(oidcConfig.getIssuer());
configuration.setAuthorizationEndpoint(oidcConfig.getAuthorizationEndpoint());
configuration.setTokenEndpoint(oidcConfig.getTokenEndpoint());
configuration.setJwksUri(oidcConfig.getJwksUri());
configuration.setRegistrationEndpoint(oidcConfig.getRegistrationEndpoint());
configuration.setScopesSupported(oidcConfig.getScopesSupported());
configuration.setResponseTypesSupported(oidcConfig.getResponseTypesSupported());
configuration.setResponseModesSupported(oidcConfig.getResponseModesSupported());
configuration.setGrantTypesSupported(oidcConfig.getGrantTypesSupported());
configuration.setTokenEndpointAuthMethodsSupported(oidcConfig.getTokenEndpointAuthMethodsSupported());
configuration.setTokenEndpointAuthSigningAlgValuesSupported(oidcConfig.getTokenEndpointAuthSigningAlgValuesSupported());
configuration.setIntrospectionEndpoint(oidcConfig.getIntrospectionEndpoint());
configuration.setLogoutEndpoint(oidcConfig.getLogoutEndpoint());
UriBuilder uriBuilder = session.getContext().getUri().getBaseUriBuilder();
RealmModel realm = session.getContext().getRealm();
configuration.setPermissionEndpoint(uriBuilder.clone().path(RealmsResource.class).path(RealmsResource.class, "getAuthorizationService").path(AuthorizationService.class, "getProtectionService").path(ProtectionService.class, "permission").build(realm.getName()).toString());
configuration.setResourceRegistrationEndpoint(uriBuilder.clone().path(RealmsResource.class).path(RealmsResource.class, "getAuthorizationService").path(AuthorizationService.class, "getProtectionService").path(ProtectionService.class, "resource").build(realm.getName()).toString());
configuration.setPolicyEndpoint(uriBuilder.clone().path(RealmsResource.class).path(RealmsResource.class, "getAuthorizationService").path(AuthorizationService.class, "getProtectionService").path(ProtectionService.class, "policy").build(realm.getName()).toString());
return configuration;
}
use of org.keycloak.wellknown.WellKnownProvider in project keycloak by keycloak.
the class RealmsResource method getWellKnown.
@GET
@Path("{realm}/.well-known/{alias}")
@Produces(MediaType.APPLICATION_JSON)
public Response getWellKnown(@PathParam("realm") final String name, @PathParam("alias") final String alias) {
RealmModel realm = init(name);
checkSsl(realm);
WellKnownProviderFactory wellKnownProviderFactoryFound = session.getKeycloakSessionFactory().getProviderFactoriesStream(WellKnownProvider.class).map(providerFactory -> (WellKnownProviderFactory) providerFactory).filter(wellKnownProviderFactory -> alias.equals(wellKnownProviderFactory.getAlias())).sorted(Comparator.comparingInt(WellKnownProviderFactory::getPriority)).findFirst().orElseThrow(NotFoundException::new);
logger.tracef("Use provider with ID '%s' for well-known alias '%s'", wellKnownProviderFactoryFound.getId(), alias);
WellKnownProvider wellKnown = session.getProvider(WellKnownProvider.class, wellKnownProviderFactoryFound.getId());
if (wellKnown != null) {
ResponseBuilder responseBuilder = Response.ok(wellKnown.getConfig()).cacheControl(CacheControlUtil.noCache());
return Cors.add(request, responseBuilder).allowedOrigins("*").auth().build();
}
throw new NotFoundException();
}
Aggregations