Search in sources :

Example 1 with AdminClientViewContext

use of org.keycloak.services.clientpolicy.context.AdminClientViewContext in project keycloak by keycloak.

the class ClientResource method getClient.

/**
 * Get representation of the client
 *
 * @return
 */
@GET
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public ClientRepresentation getClient() {
    try {
        session.clientPolicy().triggerOnEvent(new AdminClientViewContext(client, auth.adminAuth()));
    } catch (ClientPolicyException cpe) {
        throw new ErrorResponseException(cpe.getError(), cpe.getErrorDetail(), Response.Status.BAD_REQUEST);
    }
    auth.clients().requireView(client);
    ClientRepresentation representation = ModelToRepresentation.toRepresentation(client, session);
    representation.setAccess(auth.clients().getAccess(client));
    return representation;
}
Also used : AdminClientViewContext(org.keycloak.services.clientpolicy.context.AdminClientViewContext) ErrorResponseException(org.keycloak.services.ErrorResponseException) ClientPolicyException(org.keycloak.services.clientpolicy.ClientPolicyException) ClientRepresentation(org.keycloak.representations.idm.ClientRepresentation) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Aggregations

GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 NoCache (org.jboss.resteasy.annotations.cache.NoCache)1 ClientRepresentation (org.keycloak.representations.idm.ClientRepresentation)1 ErrorResponseException (org.keycloak.services.ErrorResponseException)1 ClientPolicyException (org.keycloak.services.clientpolicy.ClientPolicyException)1 AdminClientViewContext (org.keycloak.services.clientpolicy.context.AdminClientViewContext)1