Search in sources :

Example 1 with ResponseResourceList

use of com.authlete.jaxrs.server.obb.model.ResponseResourceList in project java-oauth-server by authlete.

the class ResourcesEndpoint method buildResponseBody.

private static ResponseResourceList buildResponseBody() {
    // Build dummy resources.
    Resource resource = new Resource("resourceId", "type", "status");
    Resource[] data = new Resource[] { resource };
    Links links = new Links().setSelf("/");
    Meta meta = new Meta(1, 1, ObbUtils.formatNow());
    return new ResponseResourceList(data, links, meta);
}
Also used : Meta(com.authlete.jaxrs.server.obb.model.Meta) Resource(com.authlete.jaxrs.server.obb.model.Resource) Links(com.authlete.jaxrs.server.obb.model.Links) ResponseResourceList(com.authlete.jaxrs.server.obb.model.ResponseResourceList)

Example 2 with ResponseResourceList

use of com.authlete.jaxrs.server.obb.model.ResponseResourceList in project java-oauth-server by authlete.

the class ResourcesEndpoint method read.

@GET
public Response read(@Context HttpServletRequest request, @HeaderParam(X_FAPI_INTERACTION_ID) String incomingInteractionId) {
    String code = "Resources Read";
    // Compute a value for the "x-fapi-interaction-id" HTTP response header.
    String outgoingInteractionId = ObbUtils.computeOutgoingInteractionId(code, incomingInteractionId);
    // Validate the access token.
    AuthleteApi authleteApi = AuthleteApiFactory.getDefaultApi();
    IntrospectionResponse info = ObbUtils.validateAccessToken(outgoingInteractionId, code, authleteApi, request, "resources");
    // Make sure that the access token has a "consent:{consentId}" scope.
    ensureConsentScope(outgoingInteractionId, code, info);
    // Build a response body.
    ResponseResourceList body = buildResponseBody();
    // Build a successful response.
    return ObbUtils.ok(outgoingInteractionId, body);
}
Also used : AuthleteApi(com.authlete.common.api.AuthleteApi) IntrospectionResponse(com.authlete.common.dto.IntrospectionResponse) ResponseResourceList(com.authlete.jaxrs.server.obb.model.ResponseResourceList) GET(javax.ws.rs.GET)

Aggregations

ResponseResourceList (com.authlete.jaxrs.server.obb.model.ResponseResourceList)2 AuthleteApi (com.authlete.common.api.AuthleteApi)1 IntrospectionResponse (com.authlete.common.dto.IntrospectionResponse)1 Links (com.authlete.jaxrs.server.obb.model.Links)1 Meta (com.authlete.jaxrs.server.obb.model.Meta)1 Resource (com.authlete.jaxrs.server.obb.model.Resource)1 GET (javax.ws.rs.GET)1