Search in sources :

Example 1 with ResponseConsent

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

the class ConsentsEndpoint method read.

@GET
@Path("{consentId}")
public Response read(@Context HttpServletRequest request, @HeaderParam(X_FAPI_INTERACTION_ID) String incomingInteractionId, @PathParam("consentId") String consentId) {
    String code = "Consent 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, "consents");
    // Find "consent".
    Consent consent = ConsentDao.getInstance().read(consentId);
    // Validate the consent.
    validateConsent(outgoingInteractionId, code, consent, info);
    // Build a response body.
    ResponseConsent rc = ResponseConsent.create(consent);
    // Build a successful response.
    return ObbUtils.ok(outgoingInteractionId, rc);
}
Also used : ResponseConsent(com.authlete.jaxrs.server.obb.model.ResponseConsent) AuthleteApi(com.authlete.common.api.AuthleteApi) IntrospectionResponse(com.authlete.common.dto.IntrospectionResponse) CreateConsent(com.authlete.jaxrs.server.obb.model.CreateConsent) ResponseConsent(com.authlete.jaxrs.server.obb.model.ResponseConsent) Consent(com.authlete.jaxrs.server.obb.model.Consent) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 2 with ResponseConsent

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

the class ConsentsEndpoint method create.

@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response create(@Context HttpServletRequest request, @HeaderParam(X_FAPI_INTERACTION_ID) String incomingInteractionId, CreateConsent createConsent) {
    String code = "Consent Create";
    // 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, "consents");
    // Validate the input.
    validateCreateConsent(outgoingInteractionId, code, createConsent);
    // Create "consent".
    Consent consent = ConsentDao.getInstance().create(createConsent, info.getClientId());
    // Build a response body.
    ResponseConsent rc = ResponseConsent.create(consent);
    // Build a successful response.
    return ObbUtils.created(outgoingInteractionId, rc);
}
Also used : ResponseConsent(com.authlete.jaxrs.server.obb.model.ResponseConsent) AuthleteApi(com.authlete.common.api.AuthleteApi) IntrospectionResponse(com.authlete.common.dto.IntrospectionResponse) CreateConsent(com.authlete.jaxrs.server.obb.model.CreateConsent) ResponseConsent(com.authlete.jaxrs.server.obb.model.ResponseConsent) Consent(com.authlete.jaxrs.server.obb.model.Consent) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Aggregations

AuthleteApi (com.authlete.common.api.AuthleteApi)2 IntrospectionResponse (com.authlete.common.dto.IntrospectionResponse)2 Consent (com.authlete.jaxrs.server.obb.model.Consent)2 CreateConsent (com.authlete.jaxrs.server.obb.model.CreateConsent)2 ResponseConsent (com.authlete.jaxrs.server.obb.model.ResponseConsent)2 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1