use of com.authlete.jaxrs.server.obb.model.CreateConsent in project java-oauth-server by authlete.
the class ConsentDao method create.
public Consent create(CreateConsent createConsent, long clientId) {
CreateConsentData data = createConsent.getData();
String consentId = generateConsentId();
String now = ObbUtils.formatNow();
Consent consent = new Consent().setConsentId(consentId).setPermissions(data.getPermissions()).setStatus("AWAITING_AUTHORISATION").setCreationDateTime(now).setExpirationDateTime(data.getExpirationDateTime()).setStatusUpdateDateTime(now).setClientId(clientId);
getStore().put(consentId, consent);
return consent;
}
use of com.authlete.jaxrs.server.obb.model.CreateConsent 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);
}
Aggregations