Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public Response addConsentOfLoggedInUser(@ApiParam(value = "Consent to be create
@Path("/consents/{consent-id}/authorize")
@Consumes({ "application/json" })
@Produces({ "application/json" })
@ApiOperation(value = "Authorize a consent", notes = "Authorizes a PENDING consent. The authenticated user must be in the consent's authorization list, returns 403 otherwise. When all required users have approved, the consent transitions to ACTIVE state. If any user rejects, the consent transitions to REJECTED state. <br> <b>Permission required:</b> <br> * None <br> <b>Scope required:</b> <br> * internal_login ", response = Void.class, authorizations = {
@ApiOperation(value = "Authorize a consent", notes = "Authorizes a PENDING consent. The authenticated user must either be the subject of the consent, or be listed in the consent's authorization list; returns 403 otherwise. When all required users have approved, the consent transitions to ACTIVE state. If any user rejects, the consent transitions to REJECTED state. <br> <b>Permission required:</b> <br> * None <br> <b>Scope required:</b> <br> * internal_login ", response = Void.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

Expand All @@ -100,7 +100,7 @@ public Response authorizeConsentOfLoggedInUser(@ApiParam(value = "UUID of the co
@Path("/consents/{consent-id}")

@Produces({ "application/json" })
@ApiOperation(value = "Get a consent record", notes = "Retrieve a specific consent record by consent ID. Only the consent subject may retrieve the record. Returns 403 if the authenticated user is not the consent subject. <br> <b>Permission required:</b> <br> * None <br> <b>Scope required:</b> <br> * internal_login ", response = ConsentResponse.class, authorizations = {
@ApiOperation(value = "Get a consent record", notes = "Retrieve a specific consent record by consent ID. The authenticated user must either be the subject of the consent, or be listed in the consent's authorization list; returns 403 otherwise. <br> <b>Permission required:</b> <br> * None <br> <b>Scope required:</b> <br> * internal_login ", response = ConsentResponse.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

Expand All @@ -123,28 +123,29 @@ public Response getConsentOfLoggedInUser(@ApiParam(value = "UUID of the consent
@Path("/consents")

@Produces({ "application/json" })
@ApiOperation(value = "List consent records", notes = "Retrieve consent records with optional filtering. Returns only the authenticated user's own consents. <br> <b>Permission required:</b> <br> * None <br> <b>Scope required:</b> <br> * internal_login ", response = ConsentSummary.class, responseContainer = "List", authorizations = {
@ApiOperation(value = "List consent records", notes = "Retrieve consent records with optional filtering. Returns the authenticated user's own consents, or those the user authorizes, based on the `relation` parameter. <br> <b>Permission required:</b> <br> * None <br> <b>Scope required:</b> <br> * internal_login ", response = ConsentSummary.class, responseContainer = "List", authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

})
}, tags={ "me", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Consents retrieved successfully.", response = ConsentSummary.class, responseContainer = "List"),
@ApiResponse(code = 400, message = "Invalid input request", response = Error.class),
@ApiResponse(code = 401, message = "Unauthorized", response = Void.class),
@ApiResponse(code = 500, message = "Internal Server Error", response = Error.class)
})
public Response listConsentsOfLoggedInUser( @Valid@ApiParam(value = "Filter consents by service identifier.") @QueryParam("serviceId") String serviceId, @Valid@ApiParam(value = "Filter consents by state.", allowableValues="PENDING, ACTIVE, REJECTED, REVOKED, EXPIRED") @QueryParam("state") String state, @Valid@ApiParam(value = "Filter consents by purpose UUID.") @QueryParam("purposeId") String purposeId, @Valid@ApiParam(value = "Filter consents by specific purpose version UUID.") @QueryParam("purposeVersionId") String purposeVersionId, @Valid@ApiParam(value = "Filter consents by custom properties using dot notation `properties.<key>`. Supports 'sw' (starts with), 'co' (contains), 'ew' (ends with), and 'eq' (equals) operations. Combine multiple conditions with 'and', 'or' logical operators. Examples: filter=properties.region eq EU ") @QueryParam("filter") String filter, @Valid @Min(1)@ApiParam(value = "Maximum number of records to return. Default is 10.", defaultValue="10") @DefaultValue("10") @QueryParam("limit") Integer limit, @Valid@ApiParam(value = "Cursor for forward pagination. Pass the base64-encoded UUID of the last item received from the previous page to retrieve the next page of results. ") @QueryParam("after") String after, @Valid@ApiParam(value = "Cursor for backward pagination. Pass the base64-encoded UUID of the first item received from the current page to retrieve the previous page of results. ") @QueryParam("before") String before) {
public Response listConsentsOfLoggedInUser( @Valid@ApiParam(value = "Relation of the authenticated user to the retrieved consents. SUBJECT returns consents given by the user, AUTHORIZER returns consents the user is listed as an authorizer of, ANY returns both. ", allowableValues="SUBJECT, AUTHORIZER, ANY", defaultValue="SUBJECT") @DefaultValue("SUBJECT") @QueryParam("relation") String relation, @Valid@ApiParam(value = "Filter consents by service identifier.") @QueryParam("serviceId") String serviceId, @Valid@ApiParam(value = "Filter consents by state.", allowableValues="PENDING, ACTIVE, REJECTED, REVOKED, EXPIRED") @QueryParam("state") String state, @Valid@ApiParam(value = "Filter consents by purpose UUID.") @QueryParam("purposeId") String purposeId, @Valid@ApiParam(value = "Filter consents by specific purpose version UUID.") @QueryParam("purposeVersionId") String purposeVersionId, @Valid@ApiParam(value = "Filter consents by custom properties using dot notation `properties.<key>`, and by `timestamp` (milliseconds since epoch). Properties support 'sw' (starts with), 'co' (contains), 'ew' (ends with), and 'eq' (equals) operations. `timestamp` supports 'ge' (greater than or equals) and 'le' (less than or equals) operations. Combine multiple conditions with the 'and' logical operator. Examples: filter=properties.region eq EU, filter=timestamp ge 1744000000000 and timestamp le 1766383796000 ") @QueryParam("filter") String filter, @Valid@ApiParam(value = "Specifies the required attributes in the response as a comma-separated string. Supported values: `purposes`, `authorizations`, `properties`. Example: attributes=purposes,properties ") @QueryParam("attributes") String attributes, @Valid @Min(1)@ApiParam(value = "Maximum number of records to return. Default is 10.", defaultValue="10") @DefaultValue("10") @QueryParam("limit") Integer limit, @Valid@ApiParam(value = "Cursor for forward pagination. Pass the base64-encoded UUID of the last item received from the previous page to retrieve the next page of results. ") @QueryParam("after") String after, @Valid@ApiParam(value = "Cursor for backward pagination. Pass the base64-encoded UUID of the first item received from the current page to retrieve the previous page of results. ") @QueryParam("before") String before) {

return delegate.listConsentsOfLoggedInUser(serviceId, state, purposeId, purposeVersionId, filter, limit, after, before );
return delegate.listConsentsOfLoggedInUser(relation, serviceId, state, purposeId, purposeVersionId, filter, attributes, limit, after, before );
}

@Valid
@POST
@Path("/consents/{consent-id}/revoke")

@Produces({ "*/*" })
@ApiOperation(value = "Revoke a consent", notes = "Revokes the consent. The authenticated user must be the consent subject, returns 403 otherwise. Idempotent — if the consent is already revoked, returns 200 with no error. <br> <b>Permission required:</b> <br> * None <br> <b>Scope required:</b> <br> * internal_login ", response = Void.class, authorizations = {
@ApiOperation(value = "Revoke a consent", notes = "Revokes the consent. The authenticated user must either be the subject of the consent, or be listed in the consent's authorization list; returns 403 otherwise. Idempotent — if the consent is already revoked, returns 200 with no error. <br> <b>Permission required:</b> <br> * None <br> <b>Scope required:</b> <br> * internal_login ", response = Void.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

Expand All @@ -167,7 +168,7 @@ public Response revokeConsentOfLoggedInUser(@ApiParam(value = "UUID of the conse
@Path("/consents/{consent-id}/validate")

@Produces({ "application/json" })
@ApiOperation(value = "Get the current state of a consent object", notes = "Returns the current state of a consent record, performing a lazy expiry check. The authenticated user must be the consent subject, returns 403 otherwise. <br> <b>Permission required:</b> <br> * None <br> <b>Scope required:</b> <br> * internal_login ", response = ConsentValidationResponse.class, authorizations = {
@ApiOperation(value = "Get the current state of a consent object", notes = "Returns the current state of a consent record, performing a lazy expiry check. The authenticated user must either be the subject of the consent, or be listed in the consent's authorization list; returns 403 otherwise. <br> <b>Permission required:</b> <br> * None <br> <b>Scope required:</b> <br> * internal_login ", response = ConsentValidationResponse.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public interface MeApiService {

public Response getConsentOfLoggedInUser(String consentId);

public Response listConsentsOfLoggedInUser(String serviceId, String state, String purposeId, String purposeVersionId, String filter, Integer limit, String after, String before);
public Response listConsentsOfLoggedInUser(String relation, String serviceId, String state, String purposeId, String purposeVersionId, String filter, String attributes, Integer limit, String after, String before);

public Response revokeConsentOfLoggedInUser(String consentId);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
/*
* Copyright (c) 2026, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.identity.api.user.consent.v1.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.*;

/**
* Minimal consented purpose information for list responses.
**/

import io.swagger.annotations.*;
import java.util.Objects;
import javax.validation.Valid;
import javax.xml.bind.annotation.*;
@ApiModel(description = "Minimal consented purpose information for list responses.")
public class ConsentPurposeSummary {

private String id;
private String name;
private String type;
private String versionId;
private String version;

/**
* UUID of the purpose.
**/
public ConsentPurposeSummary id(String id) {

this.id = id;
return this;
}

@ApiModelProperty(example = "a43f8d09-2e1f-4b3a-9f6e-3a1b2c4d5e6f", value = "UUID of the purpose.")
@JsonProperty("id")
@Valid
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}

/**
* Name of the purpose.
**/
public ConsentPurposeSummary name(String name) {

this.name = name;
return this;
}

@ApiModelProperty(example = "Marketing communications", value = "Name of the purpose.")
@JsonProperty("name")
@Valid
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}

/**
* Purpose type classification.
**/
public ConsentPurposeSummary type(String type) {

this.type = type;
return this;
}

@ApiModelProperty(example = "Policy", value = "Purpose type classification.")
@JsonProperty("type")
@Valid
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}

/**
* UUID of the purpose version consented to.
**/
public ConsentPurposeSummary versionId(String versionId) {

this.versionId = versionId;
return this;
}

@ApiModelProperty(example = "b53g9e10-3f2g-5c4b-0g7f-4b2c3d5e6f7g", value = "UUID of the purpose version consented to.")
@JsonProperty("versionId")
@Valid
public String getVersionId() {
return versionId;
}
public void setVersionId(String versionId) {
this.versionId = versionId;
}

/**
* Human-readable version label.
**/
public ConsentPurposeSummary version(String version) {

this.version = version;
return this;
}

@ApiModelProperty(example = "2", value = "Human-readable version label.")
@JsonProperty("version")
@Valid
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}



@Override
public boolean equals(java.lang.Object o) {

if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ConsentPurposeSummary consentPurposeSummary = (ConsentPurposeSummary) o;
return Objects.equals(this.id, consentPurposeSummary.id) &&
Objects.equals(this.name, consentPurposeSummary.name) &&
Objects.equals(this.type, consentPurposeSummary.type) &&
Objects.equals(this.versionId, consentPurposeSummary.versionId) &&
Objects.equals(this.version, consentPurposeSummary.version);
}

@Override
public int hashCode() {
return Objects.hash(id, name, type, versionId, version);
}

@Override
public String toString() {

StringBuilder sb = new StringBuilder();
sb.append("class ConsentPurposeSummary {\n");

sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" versionId: ").append(toIndentedString(versionId)).append("\n");
sb.append(" version: ").append(toIndentedString(version)).append("\n");
sb.append("}");
return sb.toString();
}

/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {

if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n");
}
}

Loading
Loading