Search in sources :

Example 1 with AccessPolicyNotFoundException

use of io.gravitee.am.service.exception.AccessPolicyNotFoundException in project gravitee-access-management by gravitee-io.

the class ResourceAccessPoliciesEndpoint method get.

public void get(RoutingContext context) {
    final JWT accessToken = context.get(ConstantKeys.TOKEN_CONTEXT_KEY);
    final Client client = context.get(ConstantKeys.CLIENT_CONTEXT_KEY);
    final String resource = context.request().getParam(RESOURCE_ID);
    final String accessPolicyId = context.request().getParam(POLICY_ID);
    resourceService.findAccessPolicy(domain.getId(), client.getId(), accessToken.getSub(), resource, accessPolicyId).switchIfEmpty(Single.error(new AccessPolicyNotFoundException(accessPolicyId))).subscribe(response -> context.response().putHeader(HttpHeaders.CACHE_CONTROL, "no-store").putHeader(HttpHeaders.PRAGMA, "no-cache").putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).end(Json.encodePrettily(response)), error -> context.fail(error));
}
Also used : JWT(io.gravitee.am.common.jwt.JWT) AccessPolicyNotFoundException(io.gravitee.am.service.exception.AccessPolicyNotFoundException) Client(io.gravitee.am.model.oidc.Client)

Aggregations

JWT (io.gravitee.am.common.jwt.JWT)1 Client (io.gravitee.am.model.oidc.Client)1 AccessPolicyNotFoundException (io.gravitee.am.service.exception.AccessPolicyNotFoundException)1