Verifiable Presentations Template Management#1091
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| public static PresentationDefinitionService getPresentationDefinitionService() { | ||
|
|
||
| return (PresentationDefinitionService) PrivilegedCarbonContext | ||
| .getThreadLocalCarbonContext() | ||
| .getOSGiService(PresentationDefinitionService.class, null); | ||
| } |
There was a problem hiding this comment.
Log Improvement Suggestion No: 1
| public static PresentationDefinitionService getPresentationDefinitionService() { | |
| return (PresentationDefinitionService) PrivilegedCarbonContext | |
| .getThreadLocalCarbonContext() | |
| .getOSGiService(PresentationDefinitionService.class, null); | |
| } | |
| public static PresentationDefinitionService getPresentationDefinitionService() { | |
| PresentationDefinitionService service = (PresentationDefinitionService) PrivilegedCarbonContext | |
| .getThreadLocalCarbonContext() | |
| .getOSGiService(PresentationDefinitionService.class, null); | |
| if (service == null) { | |
| log.error("PresentationDefinitionService OSGi service not found."); | |
| } | |
| return service; |
| * @return PresentationDefinitionList | ||
| */ | ||
| public PresentationDefinitionList listPresentationDefinitions() { | ||
|
|
||
| try { |
There was a problem hiding this comment.
Log Improvement Suggestion No: 2
| * @return PresentationDefinitionList | |
| */ | |
| public PresentationDefinitionList listPresentationDefinitions() { | |
| try { | |
| public PresentationDefinitionList listPresentationDefinitions() { | |
| try { | |
| int tenantId = getTenantId(); | |
| log.info("Listing presentation definitions for tenant: " + tenantId); |
| .tenantId(tenantId) | ||
| .build(); |
There was a problem hiding this comment.
Log Improvement Suggestion No: 3
| .tenantId(tenantId) | |
| .build(); | |
| PresentationDefinition created = service.createPresentationDefinition(definition, tenantId); | |
| log.info("Successfully created presentation definition with ID: " + created.getDefinitionId()); | |
| return toResponse(created); |
|
|
||
| @Override | ||
| public Response createPresentationDefinition( | ||
| PresentationDefinitionCreationModel presentationDefinitionCreationModel) { | ||
|
|
||
| PresentationDefinitionResponse created = | ||
| CORE_SERVICE.createPresentationDefinition(presentationDefinitionCreationModel); | ||
| URI location = URI.create( | ||
| VPDefinitionManagementConstants.VP_DEFINITION_MANAGEMENT_PATH_COMPONENT | ||
| + "/" + created.getId()); | ||
| return Response.created(location).entity(created).build(); |
There was a problem hiding this comment.
Log Improvement Suggestion No: 4
| @Override | |
| public Response createPresentationDefinition( | |
| PresentationDefinitionCreationModel presentationDefinitionCreationModel) { | |
| PresentationDefinitionResponse created = | |
| CORE_SERVICE.createPresentationDefinition(presentationDefinitionCreationModel); | |
| URI location = URI.create( | |
| VPDefinitionManagementConstants.VP_DEFINITION_MANAGEMENT_PATH_COMPONENT | |
| + "/" + created.getId()); | |
| return Response.created(location).entity(created).build(); | |
| @Override | |
| public Response createPresentationDefinition( | |
| PresentationDefinitionCreationModel presentationDefinitionCreationModel) { | |
| log.info("Creating new presentation definition"); | |
| PresentationDefinitionResponse created = | |
| CORE_SERVICE.createPresentationDefinition(presentationDefinitionCreationModel); | |
| URI location = URI.create( | |
| VPDefinitionManagementConstants.VP_DEFINITION_MANAGEMENT_PATH_COMPONENT | |
| + "/" + created.getId()); | |
| log.debug("Successfully created presentation definition with ID: " + created.getId()); | |
| return Response.created(location).entity(created).build(); | |
| } |
|
|
||
| @Override | ||
| public Response deletePresentationDefinition(String definitionId) { | ||
|
|
||
| CORE_SERVICE.deletePresentationDefinition(definitionId); | ||
| return Response.noContent().build(); |
There was a problem hiding this comment.
Log Improvement Suggestion No: 5
| @Override | |
| public Response deletePresentationDefinition(String definitionId) { | |
| CORE_SERVICE.deletePresentationDefinition(definitionId); | |
| return Response.noContent().build(); | |
| @Override | |
| public Response deletePresentationDefinition(String definitionId) { | |
| log.info("Deleting presentation definition with ID: " + definitionId); | |
| CORE_SERVICE.deletePresentationDefinition(definitionId); | |
| log.debug("Successfully deleted presentation definition with ID: " + definitionId); | |
| return Response.noContent().build(); | |
| } |
There was a problem hiding this comment.
AI Agent Log Improvement Checklist
- The log-related comments and suggestions in this review were generated by an AI tool to assist with identifying potential improvements. Purpose of reviewing the code for log improvements is to improve the troubleshooting capabilities of our products.
- Please make sure to manually review and validate all suggestions before applying any changes. Not every code suggestion would make sense or add value to our purpose. Therefore, you have the freedom to decide which of the suggestions are helpful.
✅ Before merging this pull request:
- Review all AI-generated comments for accuracy and relevance.
- Complete and verify the table below. We need your feedback to measure the accuracy of these suggestions and the value they add. If you are rejecting a certain code suggestion, please mention the reason briefly in the suggestion for us to capture it.
Introduce a new Presentation Definition Management API module for Verifiable Presentations (VP). Adds two submodules: a common module (pom, service holder, constants) and a v1 API module (pom, JAX-RS resource, generated models, service interface/factory, core service implementation, API impl and OpenAPI YAML). The core service integrates with PresentationDefinitionService via PrivilegedCarbonContext, handles CRUD operations, model conversions, and maps VP exceptions to REST errors. Also updates the root pom.xml to include the new components.
Rename and move the vc.presentation.definition component to vp.template.management to reflect VP template management naming. Updated module and artifactIds, bumped API module version from 1.5.9-SNAPSHOT to 1.5.10-SNAPSHOT, and adjusted root pom module list and dependency references. Java packages, generated API classes, factories, service holder, and core/impl classes were renamed to org.wso2.carbon.identity.api.server.vp.template.management.*. The JAX-RS path and OpenAPI YAML were updated from /presentation-definitions to /vp/template.
Replace the generic 'definition' payload with a typed requested_credentials list: add RequestedCredentialModel, update PresentationDefinitionCreationModel and PresentationDefinitionUpdateModel to use requested_credentials, and update OpenAPI schema (PresentationDefinitions.yaml). ServerVPDefinitionManagementService now builds presentation definition JSON and input descriptors from requested_credentials (generates a UUID definitionId and uses PresentationDefinitionUtil) and removes the old serializeDefinition helper. This enables constructing presentation definitions from structured credential requests.
Replace JSON-based presentation definition handling with strongly-typed RequestedCredential lists. Removed ObjectMapper and PresentationDefinitionUtil usage; create/update now populate PresentationDefinition.requestedCredentials via new toRequestedCredentials converter, and responses map requestedCredentials back to API models via toCredentialModels. Also removed special-case VPException invalid-message handling. This simplifies model conversion and avoids constructing raw definition JSON in the API layer.
Update pom.xml to consolidate two dependencies into the VP template management API artifact. Removed org.wso2.carbon.identity.server.api:common and org.wso2.carbon.identity.server.api:v1 entries and replaced them with org.wso2.carbon.identity.api.server.vp.template.management.v1, setting its scope to provided to avoid bundling at runtime.
Rename model properties and JSON/OpenAPI fields from requested_credentials -> credentials and requested_claims -> claims. Updated generated models (PresentationDefinitionCreationModel, PresentationDefinitionUpdateModel, RequestedCredentialModel), service mapping code (ServerVPDefinitionManagementService) and the PresentationDefinitions.yaml spec. Adjusted getters/setters and internal conversions to use the new names. Note: this changes the public API JSON keys, so clients must be updated to the new field names.
Replace the generic `definition` field in PresentationDefinitionResponse with a typed `credentials` list of RequestedCredentialModel, updating getters/setters and the JSON property name. Update ServerVPDefinitionManagementService to populate `credentials` instead of `definition`. Also update PresentationDefinitions.yaml to require `credentials` and define it as an array of RequestedCredentialModel. This makes the API response and OpenAPI schema explicitly model the requested credentials instead of using an untyped object.
Replace references to the old openid4vc presentation module with the renamed presentation.management module. Updated pom.xml in the common and v1 modules to depend on org.wso2.carbon.identity.openid4vc:org.wso2.carbon.identity.openid4vc.presentation.management (provided scope). Updated Java imports in VPDefinitionManagementServiceHolder and ServerVPDefinitionManagementService to use org.wso2.carbon.identity.openid4vc.presentation.management.service.PresentationDefinitionService to match the new package/artifact name.
Update imports and dependency to use the org.wso2.carbon.identity.openid4vc.presentation.management module instead of presentation.common/presentation.definition. Adjusted imports in ServerVPDefinitionManagementService (PresentationDefinitionNotFoundException, PresentationDefinition, RequestedCredential) and updated the pom.xml artifactId to org.wso2.carbon.identity.openid4vc.presentation.management to match the renamed/relocated module.
c907649 to
a9a7b36
Compare
Bump copyright headers from 2025 to 2026 across the vp.template.management module. Updated poms and generated/source Java files (common, v1, and module root) to reflect the new copyright year.
848bbe4 to
99ae076
Compare
Purpose
This PR introduces the VP (Verifiable Presentation) Template Management API for WSO2 Identity Server, enabling administrators to manage Presentation Definitions used in OpenID4VP-based authentication flows.
Goals
/api/server/v1/vp/template) for full lifecycle management of Presentation Definitions.vc.template.management).Approach
Two new Maven modules are introduced under
components/org.wso2.carbon.identity.api.server.vp.template.management:vp.template.management.commonVPDefinitionManagementConstants— error codes and messages.VPDefinitionManagementServiceHolder— OSGi service holder forPresentationDefinitionService.vp.template.management.v1src/gen/java):PresentationDefinitionsApi, service interface, model classes (PresentationDefinitionCreationModel,PresentationDefinitionUpdateModel,PresentationDefinitionResponse,PresentationDefinitionList,PresentationDefinitionListItem,RequestedCredentialModel), andPresentationDefinitionsApiServiceFactory— all generated fromPresentationDefinitions.yaml.src/main/java):PresentationDefinitionsApiServiceImpl— delegates to the core service.ServerVPDefinitionManagementService— handles model mapping, error classification (404/409/400/500), and tenant resolution.pom.xmlofidentity-api-serveris updated to include the new module declaration and bothvp.template.management.commonandvp.template.management.v1dependency management entries.The API follows a standard REST pattern:
GET/vp/templatePOST/vp/templateGET/vp/template/{definitionId}PUT/vp/template/{definitionId}DELETE/vp/template/{definitionId}User stories
Developer Checklist (Mandatory)
product-isissue to track any behavioral change or migration impact.Release note
Introduces a new REST API (
/api/server/v1/vp/template) for managing OpenID4VP Presentation Definitions in WSO2 Identity Server. Administrators can now create, retrieve, update, and delete Presentation Definitions used in VP-based authentication flows.Test environment
1.5.10-SNAPSHOT)Summary by CodeRabbit