Search in sources :

Example 1 with RealmResourceProvider

use of org.keycloak.services.resource.RealmResourceProvider in project keycloak by keycloak.

the class RealmsResource method resolveRealmExtension.

/**
 * A JAX-RS sub-resource locator that uses the {@link org.keycloak.services.resource.RealmResourceSPI} to resolve sub-resources instances given an <code>unknownPath</code>.
 *
 * @param extension a path that could be to a REST extension
 * @return a JAX-RS sub-resource instance for the REST extension if found. Otherwise null is returned.
 */
@Path("{realm}/{extension}")
public Object resolveRealmExtension(@PathParam("realm") String realmName, @PathParam("extension") String extension) {
    init(realmName);
    RealmResourceProvider provider = session.getProvider(RealmResourceProvider.class, extension);
    if (provider != null) {
        Object resource = provider.getResource();
        if (resource != null) {
            return resource;
        }
    }
    throw new NotFoundException();
}
Also used : RealmResourceProvider(org.keycloak.services.resource.RealmResourceProvider) NotFoundException(javax.ws.rs.NotFoundException) Path(javax.ws.rs.Path)

Aggregations

NotFoundException (javax.ws.rs.NotFoundException)1 Path (javax.ws.rs.Path)1 RealmResourceProvider (org.keycloak.services.resource.RealmResourceProvider)1