use of org.keycloak.wellknown.WellKnownProviderFactory 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