Search in sources :

Example 6 with AuthleteApi

use of com.authlete.common.api.AuthleteApi in project java-oauth-server by authlete.

the class ClientRegistrationEndpoint method read.

/**
 * Dynamic client registration management endpoint, "read" functionality.
 */
@GET
@Path("/{id}")
public Response read(@HeaderParam(HttpHeaders.AUTHORIZATION) String authorization, @PathParam("id") String clientId, @Context HttpServletRequest httpServletRequest) {
    // The interface of Authlete APIs.
    AuthleteApi api = AuthleteApiFactory.getDefaultApi();
    // Extra process before executing the "read" operation.
    preprocessClient(httpServletRequest, api, clientId);
    // Execute the "read" operation.
    return handleGet(api, clientId, authorization);
}
Also used : AuthleteApi(com.authlete.common.api.AuthleteApi) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 7 with AuthleteApi

use of com.authlete.common.api.AuthleteApi in project java-oauth-server by authlete.

the class AccountsEndpoint method read.

@GET
public Response read(@Context HttpServletRequest request, @HeaderParam(X_FAPI_INTERACTION_ID) String incomingInteractionId) {
    String code = "Accounts 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, "accounts");
    // Make sure that the access token has a "consent:{consentId}" scope.
    ensureConsentScope(outgoingInteractionId, code, info);
    // Build a response body.
    ResponseAccountList body = buildResponseBody();
    // Build a successful response.
    return ObbUtils.ok(outgoingInteractionId, body);
}
Also used : AuthleteApi(com.authlete.common.api.AuthleteApi) ResponseAccountList(com.authlete.jaxrs.server.obb.model.ResponseAccountList) IntrospectionResponse(com.authlete.common.dto.IntrospectionResponse) GET(javax.ws.rs.GET)

Example 8 with AuthleteApi

use of com.authlete.common.api.AuthleteApi 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 9 with AuthleteApi

use of com.authlete.common.api.AuthleteApi 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)

Example 10 with AuthleteApi

use of com.authlete.common.api.AuthleteApi in project java-oauth-server by authlete.

the class FAPI2BaseAccountsEndpoint method read.

@GET
public Response read(@Context HttpServletRequest request, @HeaderParam(X_FAPI_INTERACTION_ID) String incomingInteractionId) {
    String code = "Accounts 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, "fapi2base-accounts");
    // Make sure that the access token has a "consent:{consentId}" scope.
    ensureConsentScope(outgoingInteractionId, code, info);
    // Build a response body.
    ResponseAccountList body = buildResponseBody();
    // Build a successful response.
    return ObbUtils.ok(outgoingInteractionId, body);
}
Also used : AuthleteApi(com.authlete.common.api.AuthleteApi) ResponseAccountList(com.authlete.jaxrs.server.obb.model.ResponseAccountList) IntrospectionResponse(com.authlete.common.dto.IntrospectionResponse) GET(javax.ws.rs.GET)

Aggregations

AuthleteApi (com.authlete.common.api.AuthleteApi)12 IntrospectionResponse (com.authlete.common.dto.IntrospectionResponse)6 GET (javax.ws.rs.GET)5 Path (javax.ws.rs.Path)5 Consumes (javax.ws.rs.Consumes)4 Consent (com.authlete.jaxrs.server.obb.model.Consent)3 CreateConsent (com.authlete.jaxrs.server.obb.model.CreateConsent)3 ResponseConsent (com.authlete.jaxrs.server.obb.model.ResponseConsent)3 POST (javax.ws.rs.POST)3 ResponseAccountList (com.authlete.jaxrs.server.obb.model.ResponseAccountList)2 DELETE (javax.ws.rs.DELETE)2 AuthleteApiException (com.authlete.common.api.AuthleteApiException)1 ResponseResourceList (com.authlete.jaxrs.server.obb.model.ResponseResourceList)1 PUT (javax.ws.rs.PUT)1 Response (javax.ws.rs.core.Response)1