Search in sources :

Example 46 with NoCache

use of org.jboss.resteasy.annotations.cache.NoCache in project keycloak by keycloak.

the class ClientStorageProviderResource method getSimpleName.

/**
 * Need this for admin console to display simple name of provider when displaying client detail
 *
 * KEYCLOAK-4328
 *
 * @param id
 * @return
 */
@GET
@Path("{id}/name")
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public Map<String, String> getSimpleName(@PathParam("id") String id) {
    auth.clients().requireList();
    ComponentModel model = realm.getComponent(id);
    if (model == null) {
        throw new NotFoundException("Could not find component");
    }
    if (!model.getProviderType().equals(ClientStorageProvider.class.getName())) {
        throw new NotFoundException("found, but not a ClientStorageProvider");
    }
    Map<String, String> data = new HashMap<>();
    data.put("id", model.getId());
    data.put("name", model.getName());
    return data;
}
Also used : HashMap(java.util.HashMap) ComponentModel(org.keycloak.component.ComponentModel) NotFoundException(javax.ws.rs.NotFoundException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 47 with NoCache

use of org.jboss.resteasy.annotations.cache.NoCache in project keycloak by keycloak.

the class ComponentResource method getComponent.

@GET
@Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
@NoCache
public ComponentRepresentation getComponent(@PathParam("id") String id) {
    auth.realm().requireViewRealm();
    ComponentModel model = realm.getComponent(id);
    if (model == null) {
        throw new NotFoundException("Could not find component");
    }
    ComponentRepresentation rep = ModelToRepresentation.toRepresentation(session, model, false);
    return rep;
}
Also used : ComponentRepresentation(org.keycloak.representations.idm.ComponentRepresentation) ComponentModel(org.keycloak.component.ComponentModel) NotFoundException(javax.ws.rs.NotFoundException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 48 with NoCache

use of org.jboss.resteasy.annotations.cache.NoCache in project keycloak by keycloak.

the class ComponentResource method getSubcomponentConfig.

/**
 * List of subcomponent types that are available to configure for a particular parent component.
 *
 * @param parentId
 * @param subtype
 * @return
 */
@GET
@Path("{id}/sub-component-types")
@Produces(MediaType.APPLICATION_JSON)
@NoCache
public Stream<ComponentTypeRepresentation> getSubcomponentConfig(@PathParam("id") String parentId, @QueryParam("type") String subtype) {
    auth.realm().requireViewRealm();
    ComponentModel parent = realm.getComponent(parentId);
    if (parent == null) {
        throw new NotFoundException("Could not find parent component");
    }
    if (subtype == null) {
        throw new BadRequestException("must specify a subtype");
    }
    Class<? extends Provider> providerClass;
    try {
        providerClass = (Class<? extends Provider>) Class.forName(subtype);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
    return session.getKeycloakSessionFactory().getProviderFactoriesStream(providerClass).filter(ComponentFactory.class::isInstance).map(factory -> toComponentTypeRepresentation(factory, parent));
}
Also used : ComponentModel(org.keycloak.component.ComponentModel) NotFoundException(javax.ws.rs.NotFoundException) BadRequestException(javax.ws.rs.BadRequestException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 49 with NoCache

use of org.jboss.resteasy.annotations.cache.NoCache in project keycloak by keycloak.

the class IdentityProviderResource method getIdentityProvider.

/**
 * Get the identity provider
 *
 * @return
 */
@GET
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public IdentityProviderRepresentation getIdentityProvider() {
    this.auth.realm().requireViewIdentityProviders();
    if (identityProviderModel == null) {
        throw new javax.ws.rs.NotFoundException();
    }
    IdentityProviderRepresentation rep = ModelToRepresentation.toRepresentation(realm, this.identityProviderModel);
    return StripSecretsUtils.strip(rep);
}
Also used : IdentityProviderRepresentation(org.keycloak.representations.idm.IdentityProviderRepresentation) NotFoundException(javax.ws.rs.NotFoundException) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 50 with NoCache

use of org.jboss.resteasy.annotations.cache.NoCache in project keycloak by keycloak.

the class IdentityProviderResource method getMapperById.

/**
 * Get mapper by id for the identity provider
 *
 * @param id
 * @return
 */
@GET
@NoCache
@Path("mappers/{id}")
@Produces(MediaType.APPLICATION_JSON)
public IdentityProviderMapperRepresentation getMapperById(@PathParam("id") String id) {
    this.auth.realm().requireViewIdentityProviders();
    if (identityProviderModel == null) {
        throw new javax.ws.rs.NotFoundException();
    }
    IdentityProviderMapperModel model = realm.getIdentityProviderMapperById(id);
    if (model == null)
        throw new NotFoundException("Model not found");
    return ModelToRepresentation.toRepresentation(model);
}
Also used : NotFoundException(javax.ws.rs.NotFoundException) IdentityProviderMapperModel(org.keycloak.models.IdentityProviderMapperModel) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Aggregations

NoCache (org.jboss.resteasy.annotations.cache.NoCache)152 Path (javax.ws.rs.Path)128 Produces (javax.ws.rs.Produces)100 GET (javax.ws.rs.GET)82 NotFoundException (javax.ws.rs.NotFoundException)67 POST (javax.ws.rs.POST)49 Consumes (javax.ws.rs.Consumes)48 PUT (javax.ws.rs.PUT)24 DELETE (javax.ws.rs.DELETE)23 HashMap (java.util.HashMap)20 RoleModel (org.keycloak.models.RoleModel)18 UserModel (org.keycloak.models.UserModel)18 BadRequestException (javax.ws.rs.BadRequestException)17 Response (javax.ws.rs.core.Response)16 ErrorResponseException (org.keycloak.services.ErrorResponseException)16 ClientModel (org.keycloak.models.ClientModel)15 AuthenticationFlowModel (org.keycloak.models.AuthenticationFlowModel)14 RealmModel (org.keycloak.models.RealmModel)14 List (java.util.List)12 Map (java.util.Map)12