diff --git a/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.common/pom.xml new file mode 100644 index 0000000000..6bb5710dc8 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.common/pom.xml @@ -0,0 +1,45 @@ + + + + + 4.0.0 + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.vp.template.management + 1.5.10-SNAPSHOT + ../pom.xml + + + org.wso2.carbon.identity.api.server.vp.template.management.common + jar + WSO2 Carbon - VP Template Management API Common + + + + org.wso2.carbon + org.wso2.carbon.utils + + + org.wso2.carbon.identity.openid4vc + org.wso2.carbon.identity.openid4vc.presentation.management + provided + + + diff --git a/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.common/src/main/java/org/wso2/carbon/identity/api/server/vp/template/management/common/VPDefinitionManagementConstants.java b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.common/src/main/java/org/wso2/carbon/identity/api/server/vp/template/management/common/VPDefinitionManagementConstants.java new file mode 100644 index 0000000000..7773b94dc1 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.common/src/main/java/org/wso2/carbon/identity/api/server/vp/template/management/common/VPDefinitionManagementConstants.java @@ -0,0 +1,83 @@ +/* + * 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.server.vp.template.management.common; + +/** + * Constants for Presentation Definition Management API. + */ +public class VPDefinitionManagementConstants { + + private VPDefinitionManagementConstants() { + } + + public static final String VP_DEFINITION_MANAGEMENT_PATH_COMPONENT = "/presentation-definitions"; + + /** + * Enum for error messages. + */ + public enum ErrorMessage { + + // Client errors (60xxx). + ERROR_CODE_DEFINITION_NOT_FOUND("VPD-60001", "Presentation definition not found.", + "Unable to find a presentation definition with the id: %s"), + ERROR_CODE_INVALID_INPUT("VPD-60002", "Invalid input.", + "Provided input is invalid. %s"), + ERROR_CODE_DEFINITION_ALREADY_EXISTS("VPD-60003", "Presentation definition already exists.", + "A presentation definition with the given identifier already exists."), + + // Server errors (65xxx). + ERROR_CODE_ERROR_LISTING_DEFINITIONS("VPD-65001", "Error listing presentation definitions.", + "A system error occurred while listing presentation definitions."), + ERROR_CODE_ERROR_CREATING_DEFINITION("VPD-65002", "Error creating presentation definition.", + "A system error occurred while creating the presentation definition."), + ERROR_CODE_ERROR_RETRIEVING_DEFINITION("VPD-65003", "Error retrieving presentation definition.", + "A system error occurred while retrieving the presentation definition with id: %s"), + ERROR_CODE_ERROR_UPDATING_DEFINITION("VPD-65004", "Error updating presentation definition.", + "A system error occurred while updating the presentation definition with id: %s"), + ERROR_CODE_ERROR_DELETING_DEFINITION("VPD-65005", "Error deleting presentation definition.", + "A system error occurred while deleting the presentation definition with id: %s"); + + private final String code; + private final String message; + private final String description; + + ErrorMessage(String code, String message, String description) { + this.code = code; + this.message = message; + this.description = description; + } + + public String getCode() { + return code; + } + + public String getMessage() { + return message; + } + + public String getDescription() { + return description; + } + + @Override + public String toString() { + return code + " | " + message; + } + } +} diff --git a/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.common/src/main/java/org/wso2/carbon/identity/api/server/vp/template/management/common/VPDefinitionManagementServiceHolder.java b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.common/src/main/java/org/wso2/carbon/identity/api/server/vp/template/management/common/VPDefinitionManagementServiceHolder.java new file mode 100644 index 0000000000..fc84bd576b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.common/src/main/java/org/wso2/carbon/identity/api/server/vp/template/management/common/VPDefinitionManagementServiceHolder.java @@ -0,0 +1,44 @@ +/* + * 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.server.vp.template.management.common; + +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.identity.openid4vc.presentation.management.service.PresentationDefinitionService; + +/** + * Service holder for VP Definition Management. + * Obtains the PresentationDefinitionService OSGi service via PrivilegedCarbonContext. + */ +public class VPDefinitionManagementServiceHolder { + + private VPDefinitionManagementServiceHolder() { + } + + /** + * Get PresentationDefinitionService OSGi service. + * + * @return PresentationDefinitionService instance + */ + public static PresentationDefinitionService getPresentationDefinitionService() { + + return (PresentationDefinitionService) PrivilegedCarbonContext + .getThreadLocalCarbonContext() + .getOSGiService(PresentationDefinitionService.class, null); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/pom.xml new file mode 100644 index 0000000000..efac01cdca --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/pom.xml @@ -0,0 +1,132 @@ + + + + 4.0.0 + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.vp.template.management + 1.5.10-SNAPSHOT + ../pom.xml + + + WSO2 Identity Server - VP Template Management API + WSO2 IS - VP Template Management API + org.wso2.carbon.identity.api.server.vp.template.management.v1 + jar + + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + provided + + + org.apache.cxf + cxf-rt-frontend-jaxrs + provided + + + javax.ws.rs + javax.ws.rs-api + provided + + + io.swagger + swagger-jaxrs + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + javax.ws.rs + jsr311-api + + + com.google.guava + guava + + + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.common + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.vp.template.management.common + + + org.wso2.carbon.identity.openid4vc + org.wso2.carbon.identity.openid4vc.presentation.management + provided + + + org.wso2.carbon.identity.openid4vc + org.wso2.carbon.identity.openid4vc.presentation.common + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.plugin.version} + + 1.8 + 1.8 + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.8 + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + + + + diff --git a/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/Error.java b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/Error.java new file mode 100644 index 0000000000..8d81e797a3 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/Error.java @@ -0,0 +1,76 @@ +/* + * 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.server.vp.template.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * Error response model. + */ +@ApiModel(description = "Error response") +public class Error { + + private String code; + private String message; + private String description; + private String traceId; + + @ApiModelProperty(required = true, value = "Error code.") + @JsonProperty("code") + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + @ApiModelProperty(required = true, value = "Error message.") + @JsonProperty("message") + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + @ApiModelProperty(value = "Error description.") + @JsonProperty("description") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @ApiModelProperty(value = "Trace ID for debugging.") + @JsonProperty("traceId") + public String getTraceId() { + return traceId; + } + + public void setTraceId(String traceId) { + this.traceId = traceId; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionCreationModel.java b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionCreationModel.java new file mode 100644 index 0000000000..3ca66bebea --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionCreationModel.java @@ -0,0 +1,71 @@ +/* + * 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.server.vp.template.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; + +import javax.validation.constraints.NotNull; + +/** + * Creation model for presentation definition. + */ +@ApiModel(description = "Creation model for presentation definition") +public class PresentationDefinitionCreationModel { + + @NotNull + private String name; + private String description; + @NotNull + private List credentials; + + @ApiModelProperty(required = true, value = "Name of the presentation definition.") + @JsonProperty("name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @ApiModelProperty(value = "Description of the presentation definition.") + @JsonProperty("description") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @ApiModelProperty(required = true, value = "The requested credentials to construct the definition.") + @JsonProperty("credentials") + public List getCredentials() { + return credentials; + } + + public void setCredentials(List credentials) { + this.credentials = credentials; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionList.java b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionList.java new file mode 100644 index 0000000000..e0a2b2b3ab --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionList.java @@ -0,0 +1,57 @@ +/* + * 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.server.vp.template.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; + +/** + * List response model for presentation definitions. + */ +@ApiModel(description = "List of presentation definitions") +public class PresentationDefinitionList { + + private Integer totalResults; + private List presentationDefinitions = new ArrayList<>(); + + @ApiModelProperty(value = "Total number of presentation definitions.") + @JsonProperty("totalResults") + public Integer getTotalResults() { + return totalResults; + } + + public void setTotalResults(Integer totalResults) { + this.totalResults = totalResults; + } + + @ApiModelProperty(value = "List of presentation definitions.") + @JsonProperty("presentationDefinitions") + public List getPresentationDefinitions() { + return presentationDefinitions; + } + + public void setPresentationDefinitions(List presentationDefinitions) { + this.presentationDefinitions = presentationDefinitions; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionListItem.java b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionListItem.java new file mode 100644 index 0000000000..eeba242490 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionListItem.java @@ -0,0 +1,65 @@ +/* + * 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.server.vp.template.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * List item model for presentation definitions. + */ +@ApiModel(description = "Presentation definition list item") +public class PresentationDefinitionListItem { + + private String id; + private String name; + private String description; + + @ApiModelProperty(value = "Unique identifier of the presentation definition.") + @JsonProperty("id") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @ApiModelProperty(value = "Name of the presentation definition.") + @JsonProperty("name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @ApiModelProperty(value = "Description of the presentation definition.") + @JsonProperty("description") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionResponse.java b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionResponse.java new file mode 100644 index 0000000000..8fc84deb10 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionResponse.java @@ -0,0 +1,76 @@ +/* + * 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.server.vp.template.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * Presentation definition response model. + */ +@ApiModel(description = "Presentation definition response") +public class PresentationDefinitionResponse { + + private String id; + private String name; + private String description; + private java.util.List credentials; + + @ApiModelProperty(value = "Unique identifier of the presentation definition.") + @JsonProperty("id") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @ApiModelProperty(value = "Name of the presentation definition.") + @JsonProperty("name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @ApiModelProperty(value = "Description of the presentation definition.") + @JsonProperty("description") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @ApiModelProperty(value = "The list of requested credentials in this presentation definition.") + @JsonProperty("credentials") + public java.util.List getCredentials() { + return credentials; + } + + public void setCredentials(java.util.List credentials) { + this.credentials = credentials; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionUpdateModel.java b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionUpdateModel.java new file mode 100644 index 0000000000..6e97b5433d --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionUpdateModel.java @@ -0,0 +1,67 @@ +/* + * 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.server.vp.template.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; + +/** + * Update model for presentation definition. + */ +@ApiModel(description = "Update model for presentation definition") +public class PresentationDefinitionUpdateModel { + + private String name; + private String description; + private List credentials; + + @ApiModelProperty(value = "Name of the presentation definition.") + @JsonProperty("name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @ApiModelProperty(value = "Description of the presentation definition.") + @JsonProperty("description") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @ApiModelProperty(value = "The requested credentials to construct the definition.") + @JsonProperty("credentials") + public List getCredentials() { + return credentials; + } + + public void setCredentials(List credentials) { + this.credentials = credentials; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionsApi.java b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionsApi.java new file mode 100644 index 0000000000..8ce62fb1b8 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionsApi.java @@ -0,0 +1,141 @@ +/* + * 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.server.vp.template.management.v1; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import org.wso2.carbon.identity.api.server.vp.template.management.v1.factories.PresentationDefinitionsApiServiceFactory; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +/** + * JAX-RS resource for Presentation Definition management. + */ +@Path("/vp/template") +@Api(value = "/vp/template", description = "Presentation Definition Management API") +public class PresentationDefinitionsApi { + + private final PresentationDefinitionsApiService delegate = + PresentationDefinitionsApiServiceFactory.getPresentationDefinitionsApi(); + + @GET + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "List Presentation Definitions", response = PresentationDefinitionList.class) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = PresentationDefinitionList.class), + @ApiResponse(code = 401, message = "Unauthorized"), + @ApiResponse(code = 403, message = "Forbidden"), + @ApiResponse(code = 500, message = "Internal Server Error", response = Error.class) + }) + public Response listPresentationDefinitions() { + + return delegate.listPresentationDefinitions(); + } + + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Create a Presentation Definition", + response = PresentationDefinitionResponse.class) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Created", response = PresentationDefinitionResponse.class), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized"), + @ApiResponse(code = 403, message = "Forbidden"), + @ApiResponse(code = 409, message = "Conflict", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error", response = Error.class) + }) + public Response createPresentationDefinition( + @ApiParam(value = "Presentation definition to create", required = true) + PresentationDefinitionCreationModel presentationDefinitionCreationModel) { + + return delegate.createPresentationDefinition(presentationDefinitionCreationModel); + } + + @GET + @Path("/{definition-id}") + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Get a Presentation Definition", + response = PresentationDefinitionResponse.class) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = PresentationDefinitionResponse.class), + @ApiResponse(code = 401, message = "Unauthorized"), + @ApiResponse(code = 403, message = "Forbidden"), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error", response = Error.class) + }) + public Response getPresentationDefinition( + @ApiParam(value = "Unique identifier of the presentation definition.", required = true) + @PathParam("definition-id") String definitionId) { + + return delegate.getPresentationDefinition(definitionId); + } + + @PUT + @Path("/{definition-id}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Update a Presentation Definition", + response = PresentationDefinitionResponse.class) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = PresentationDefinitionResponse.class), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized"), + @ApiResponse(code = 403, message = "Forbidden"), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error", response = Error.class) + }) + public Response updatePresentationDefinition( + @ApiParam(value = "Unique identifier of the presentation definition.", required = true) + @PathParam("definition-id") String definitionId, + @ApiParam(value = "Updated presentation definition", required = true) + PresentationDefinitionUpdateModel presentationDefinitionUpdateModel) { + + return delegate.updatePresentationDefinition(definitionId, presentationDefinitionUpdateModel); + } + + @DELETE + @Path("/{definition-id}") + @ApiOperation(value = "Delete a Presentation Definition") + @ApiResponses(value = { + @ApiResponse(code = 204, message = "No Content"), + @ApiResponse(code = 401, message = "Unauthorized"), + @ApiResponse(code = 403, message = "Forbidden"), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error", response = Error.class) + }) + public Response deletePresentationDefinition( + @ApiParam(value = "Unique identifier of the presentation definition.", required = true) + @PathParam("definition-id") String definitionId) { + + return delegate.deletePresentationDefinition(definitionId); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionsApiService.java b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionsApiService.java new file mode 100644 index 0000000000..58e41bda62 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/PresentationDefinitionsApiService.java @@ -0,0 +1,39 @@ +/* + * 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.server.vp.template.management.v1; + +import javax.ws.rs.core.Response; + +/** + * Service interface for Presentation Definitions API. + */ +public abstract class PresentationDefinitionsApiService { + + public abstract Response listPresentationDefinitions(); + + public abstract Response createPresentationDefinition( + PresentationDefinitionCreationModel presentationDefinitionCreationModel); + + public abstract Response getPresentationDefinition(String definitionId); + + public abstract Response updatePresentationDefinition(String definitionId, + PresentationDefinitionUpdateModel presentationDefinitionUpdateModel); + + public abstract Response deletePresentationDefinition(String definitionId); +} diff --git a/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/RequestedCredentialModel.java b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/RequestedCredentialModel.java new file mode 100644 index 0000000000..7471d589e6 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/RequestedCredentialModel.java @@ -0,0 +1,61 @@ +package org.wso2.carbon.identity.api.server.vp.template.management.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * Requested Credential Model. + */ +@ApiModel(description = "Requested Credential Model") +public class RequestedCredentialModel { + + @NotNull + private String type; + private String purpose; + private String issuer; + private List claims; + + @ApiModelProperty(required = true, value = "Type of the requested credential.") + @JsonProperty("type") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @ApiModelProperty(value = "Purpose of requesting the credential.") + @JsonProperty("purpose") + public String getPurpose() { + return purpose; + } + + public void setPurpose(String purpose) { + this.purpose = purpose; + } + + @ApiModelProperty(value = "The trusted issuer for this credential.") + @JsonProperty("issuer") + public String getIssuer() { + return issuer; + } + + public void setIssuer(String issuer) { + this.issuer = issuer; + } + + @ApiModelProperty(value = "List of claims requested from this credential.") + @JsonProperty("claims") + public List getClaims() { + return claims; + } + + public void setClaims(List claims) { + this.claims = claims; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/factories/PresentationDefinitionsApiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/factories/PresentationDefinitionsApiServiceFactory.java new file mode 100644 index 0000000000..f9c8f39378 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/factories/PresentationDefinitionsApiServiceFactory.java @@ -0,0 +1,35 @@ +/* + * 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.server.vp.template.management.v1.factories; + +import org.wso2.carbon.identity.api.server.vp.template.management.v1.PresentationDefinitionsApiService; +import org.wso2.carbon.identity.api.server.vp.template.management.v1.impl.PresentationDefinitionsApiServiceImpl; + +/** + * Factory class for PresentationDefinitionsApiService. + */ +public class PresentationDefinitionsApiServiceFactory { + + private static final PresentationDefinitionsApiService SERVICE = + new PresentationDefinitionsApiServiceImpl(); + + public static PresentationDefinitionsApiService getPresentationDefinitionsApi() { + return SERVICE; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/main/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/core/ServerVPDefinitionManagementService.java b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/main/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/core/ServerVPDefinitionManagementService.java new file mode 100644 index 0000000000..e40e477906 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/main/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/core/ServerVPDefinitionManagementService.java @@ -0,0 +1,317 @@ +/* + * 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.server.vp.template.management.v1.core; + +import org.wso2.carbon.identity.api.server.common.ContextLoader; +import org.wso2.carbon.identity.api.server.vp.template.management.common.VPDefinitionManagementConstants.ErrorMessage; +import org.wso2.carbon.identity.api.server.vp.template.management.common.VPDefinitionManagementServiceHolder; +import org.wso2.carbon.identity.api.server.vp.template.management.v1.Error; +import org.wso2.carbon.identity.api.server.vp.template.management.v1.PresentationDefinitionCreationModel; +import org.wso2.carbon.identity.api.server.vp.template.management.v1.PresentationDefinitionList; +import org.wso2.carbon.identity.api.server.vp.template.management.v1.PresentationDefinitionListItem; +import org.wso2.carbon.identity.api.server.vp.template.management.v1.PresentationDefinitionResponse; +import org.wso2.carbon.identity.api.server.vp.template.management.v1.PresentationDefinitionUpdateModel; +import org.wso2.carbon.identity.api.server.vp.template.management.v1.RequestedCredentialModel; +import org.wso2.carbon.identity.openid4vc.presentation.common.exception.VPException; +import org.wso2.carbon.identity.openid4vc.presentation.management.exception.PresentationDefinitionNotFoundException; +import org.wso2.carbon.identity.openid4vc.presentation.management.model.PresentationDefinition; +import org.wso2.carbon.identity.openid4vc.presentation.management.model.PresentationDefinition.RequestedCredential; +import org.wso2.carbon.identity.openid4vc.presentation.management.service.PresentationDefinitionService; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; +import javax.ws.rs.core.Response; + +/** + * Core service for VP Presentation Definition Management API. + * Handles business logic, model conversion, and error mapping. + */ +public class ServerVPDefinitionManagementService { + + /** + * List all presentation definitions for the current tenant. + * + * @return PresentationDefinitionList + */ + public PresentationDefinitionList listPresentationDefinitions() { + + try { + int tenantId = getTenantId(); + PresentationDefinitionService service = getService(); + + List definitions = service.getAllPresentationDefinitions(tenantId); + + PresentationDefinitionList listResponse = new PresentationDefinitionList(); + listResponse.setTotalResults(definitions.size()); + listResponse.setPresentationDefinitions( + definitions.stream() + .map(this::toListItem) + .collect(Collectors.toList())); + return listResponse; + } catch (VPException e) { + throw handleServerError(ErrorMessage.ERROR_CODE_ERROR_LISTING_DEFINITIONS, e); + } + } + + /** + * Create a new presentation definition. + * + * @param creationModel The creation model + * @return Created PresentationDefinitionResponse + */ + public PresentationDefinitionResponse createPresentationDefinition( + PresentationDefinitionCreationModel creationModel) { + + try { + int tenantId = getTenantId(); + PresentationDefinitionService service = getService(); + + String definitionId = UUID.randomUUID().toString(); + + PresentationDefinition definition = new PresentationDefinition.Builder() + .definitionId(definitionId) + .name(creationModel.getName()) + .description(creationModel.getDescription()) + .requestedCredentials(toRequestedCredentials(creationModel.getCredentials())) + .tenantId(tenantId) + .build(); + + PresentationDefinition created = service.createPresentationDefinition(definition, tenantId); + return toResponse(created); + } catch (VPException e) { + if (e.getMessage() != null && e.getMessage().contains("already exists")) { + throw handleClientError(ErrorMessage.ERROR_CODE_DEFINITION_ALREADY_EXISTS, e, + Response.Status.CONFLICT); + } + if (e.getMessage() != null && (e.getMessage().contains("Invalid") || + e.getMessage().contains("required"))) { + throw handleClientError(ErrorMessage.ERROR_CODE_INVALID_INPUT, e, + Response.Status.BAD_REQUEST, e.getMessage()); + } + throw handleServerError(ErrorMessage.ERROR_CODE_ERROR_CREATING_DEFINITION, e); + } + } + + /** + * Get a presentation definition by ID. + * + * @param definitionId The definition ID + * @return PresentationDefinitionResponse + */ + public PresentationDefinitionResponse getPresentationDefinition(String definitionId) { + + try { + int tenantId = getTenantId(); + PresentationDefinitionService service = getService(); + + PresentationDefinition definition = service.getPresentationDefinitionById( + definitionId, tenantId); + return toResponse(definition); + } catch (PresentationDefinitionNotFoundException e) { + throw handleNotFound(definitionId); + } catch (VPException e) { + throw handleServerError(ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_DEFINITION, e, + definitionId); + } + } + + /** + * Update a presentation definition. + * + * @param definitionId The definition ID + * @param updateModel The update model + * @return Updated PresentationDefinitionResponse + */ + public PresentationDefinitionResponse updatePresentationDefinition( + String definitionId, PresentationDefinitionUpdateModel updateModel) { + + try { + int tenantId = getTenantId(); + PresentationDefinitionService service = getService(); + + List credentials = updateModel.getCredentials() != null + ? toRequestedCredentials(updateModel.getCredentials()) + : null; + + PresentationDefinition definition = new PresentationDefinition.Builder() + .definitionId(definitionId) + .name(updateModel.getName()) + .description(updateModel.getDescription()) + .requestedCredentials(credentials) + .tenantId(tenantId) + .build(); + + PresentationDefinition updated = service.updatePresentationDefinition( + definition, tenantId); + return toResponse(updated); + } catch (PresentationDefinitionNotFoundException e) { + throw handleNotFound(definitionId); + } catch (VPException e) { + throw handleServerError(ErrorMessage.ERROR_CODE_ERROR_UPDATING_DEFINITION, e, + definitionId); + } + } + + /** + * Delete a presentation definition. + * + * @param definitionId The definition ID + */ + public void deletePresentationDefinition(String definitionId) { + + try { + int tenantId = getTenantId(); + PresentationDefinitionService service = getService(); + + service.deletePresentationDefinition(definitionId, tenantId); + } catch (PresentationDefinitionNotFoundException e) { + throw handleNotFound(definitionId); + } catch (VPException e) { + throw handleServerError(ErrorMessage.ERROR_CODE_ERROR_DELETING_DEFINITION, e, + definitionId); + } + } + + // --- Conversion helpers --- + + /** + * Convert API RequestedCredentialModel list to domain RequestedCredential list. + */ + private List toRequestedCredentials( + List apiModels) { + + if (apiModels == null) { + return null; + } + List result = new ArrayList<>(); + for (RequestedCredentialModel apiModel : apiModels) { + RequestedCredential cred = new RequestedCredential(); + cred.setType(apiModel.getType()); + cred.setPurpose(apiModel.getPurpose()); + cred.setIssuer(apiModel.getIssuer()); + cred.setClaims(apiModel.getClaims()); + result.add(cred); + } + return result; + } + + /** + * Convert domain RequestedCredential list to API RequestedCredentialModel list. + */ + private List toCredentialModels( + List domainCredentials) { + + if (domainCredentials == null) { + return null; + } + List result = new ArrayList<>(); + for (RequestedCredential cred : domainCredentials) { + RequestedCredentialModel model = new RequestedCredentialModel(); + model.setType(cred.getType()); + model.setPurpose(cred.getPurpose()); + model.setIssuer(cred.getIssuer()); + model.setClaims(cred.getClaims()); + result.add(model); + } + return result; + } + + private PresentationDefinitionResponse toResponse(PresentationDefinition definition) { + + PresentationDefinitionResponse response = new PresentationDefinitionResponse(); + response.setId(definition.getDefinitionId()); + response.setName(definition.getName()); + response.setDescription(definition.getDescription()); + response.setCredentials(toCredentialModels(definition.getRequestedCredentials())); + return response; + } + + private PresentationDefinitionListItem toListItem(PresentationDefinition definition) { + + PresentationDefinitionListItem item = new PresentationDefinitionListItem(); + item.setId(definition.getDefinitionId()); + item.setName(definition.getName()); + item.setDescription(definition.getDescription()); + return item; + } + + // --- Error handling --- + + private javax.ws.rs.WebApplicationException handleNotFound(String definitionId) { + + Error error = new Error(); + error.setCode(ErrorMessage.ERROR_CODE_DEFINITION_NOT_FOUND.getCode()); + error.setMessage(ErrorMessage.ERROR_CODE_DEFINITION_NOT_FOUND.getMessage()); + error.setDescription( + String.format(ErrorMessage.ERROR_CODE_DEFINITION_NOT_FOUND.getDescription(), + definitionId)); + return new javax.ws.rs.WebApplicationException( + Response.status(Response.Status.NOT_FOUND).entity(error).build()); + } + + private javax.ws.rs.WebApplicationException handleClientError( + ErrorMessage errorMessage, Exception e, Response.Status status, String... args) { + + Error error = new Error(); + error.setCode(errorMessage.getCode()); + error.setMessage(errorMessage.getMessage()); + error.setDescription(args.length > 0 + ? String.format(errorMessage.getDescription(), (Object[]) args) + : errorMessage.getDescription()); + return new javax.ws.rs.WebApplicationException( + Response.status(status).entity(error).build()); + } + + private javax.ws.rs.WebApplicationException handleServerError( + ErrorMessage errorMessage, Exception e, String... args) { + + Error error = new Error(); + error.setCode(errorMessage.getCode()); + error.setMessage(errorMessage.getMessage()); + error.setDescription(args.length > 0 + ? String.format(errorMessage.getDescription(), (Object[]) args) + : errorMessage.getDescription()); + return new javax.ws.rs.WebApplicationException( + Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build()); + } + + // --- Utility --- + + private int getTenantId() { + + return ContextLoader.getTenantDomainFromContext() != null + ? org.wso2.carbon.context.PrivilegedCarbonContext + .getThreadLocalCarbonContext().getTenantId() + : -1234; // Super-tenant default + } + + private PresentationDefinitionService getService() { + + PresentationDefinitionService service = + VPDefinitionManagementServiceHolder.getPresentationDefinitionService(); + if (service == null) { + throw new javax.ws.rs.WebApplicationException( + Response.status(Response.Status.INTERNAL_SERVER_ERROR) + .entity("PresentationDefinitionService is not available").build()); + } + return service; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/main/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/impl/PresentationDefinitionsApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/main/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/impl/PresentationDefinitionsApiServiceImpl.java new file mode 100644 index 0000000000..f785f7653d --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/main/java/org/wso2/carbon/identity/api/server/vp/template/management/v1/impl/PresentationDefinitionsApiServiceImpl.java @@ -0,0 +1,79 @@ +/* + * 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.server.vp.template.management.v1.impl; + +import org.wso2.carbon.identity.api.server.vp.template.management.common.VPDefinitionManagementConstants; +import org.wso2.carbon.identity.api.server.vp.template.management.v1.PresentationDefinitionCreationModel; +import org.wso2.carbon.identity.api.server.vp.template.management.v1.PresentationDefinitionResponse; +import org.wso2.carbon.identity.api.server.vp.template.management.v1.PresentationDefinitionUpdateModel; +import org.wso2.carbon.identity.api.server.vp.template.management.v1.PresentationDefinitionsApiService; +import org.wso2.carbon.identity.api.server.vp.template.management.v1.core.ServerVPDefinitionManagementService; + +import java.net.URI; +import javax.ws.rs.core.Response; + +/** + * Implementation of PresentationDefinitionsApiService. + * Delegates all operations to ServerVPDefinitionManagementService and wraps in JAX-RS Response. + */ +public class PresentationDefinitionsApiServiceImpl extends PresentationDefinitionsApiService { + + private static final ServerVPDefinitionManagementService CORE_SERVICE = + new ServerVPDefinitionManagementService(); + + @Override + public Response listPresentationDefinitions() { + + return Response.ok().entity(CORE_SERVICE.listPresentationDefinitions()).build(); + } + + @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 getPresentationDefinition(String definitionId) { + + return Response.ok().entity(CORE_SERVICE.getPresentationDefinition(definitionId)).build(); + } + + @Override + public Response updatePresentationDefinition(String definitionId, + PresentationDefinitionUpdateModel presentationDefinitionUpdateModel) { + + return Response.ok().entity( + CORE_SERVICE.updatePresentationDefinition(definitionId, + presentationDefinitionUpdateModel)).build(); + } + + @Override + public Response deletePresentationDefinition(String definitionId) { + + CORE_SERVICE.deletePresentationDefinition(definitionId); + return Response.noContent().build(); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/main/resources/PresentationDefinitions.yaml b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/main/resources/PresentationDefinitions.yaml new file mode 100644 index 0000000000..c04a8e24b8 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.vp.template.management/org.wso2.carbon.identity.api.server.vp.template.management.v1/src/main/resources/PresentationDefinitions.yaml @@ -0,0 +1,357 @@ +openapi: 3.0.0 +info: + title: "WSO2 IS Presentation Definition Management API" + version: "v1" + description: "Admin API for managing presentation definitions in WSO2 Identity Server." + contact: + name: WSO2 + url: 'http://wso2.com/products/identity-server/' + email: architecture@wso2.org + license: + name: Apache 2.0 + url: 'http://www.apache.org/licenses/LICENSE-2.0.html' + +servers: + - url: 'https://{server-url}/t/{tenant-domain}/api/server/v1' + variables: + server-url: + default: localhost:9443 + tenant-domain: + default: carbon.super + +security: + - OAuth2: [] + - BasicAuth: [] + +paths: + /vp/template: + get: + tags: + - Presentation Definitions + summary: List Presentation Definitions + description: | + Returns a list of all presentation definitions for the tenant. + operationId: listPresentationDefinitions + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/PresentationDefinitionList' + '401': + description: Unauthorized + '403': + description: Forbidden + '500': + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + tags: + - Presentation Definitions + summary: Create a Presentation Definition + description: | + Creates a new presentation definition. + operationId: createPresentationDefinition + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PresentationDefinitionCreationModel' + required: true + responses: + '201': + description: Created + headers: + Location: + description: URI of the created resource. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/PresentationDefinitionResponse' + '400': + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '401': + description: Unauthorized + '403': + description: Forbidden + '409': + description: Conflict + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '500': + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + + /vp/template/{definition-id}: + get: + tags: + - Presentation Definitions + summary: Get a Presentation Definition + description: | + Retrieves a presentation definition by its ID. + operationId: getPresentationDefinition + parameters: + - $ref: '#/components/parameters/definitionIdPathParam' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/PresentationDefinitionResponse' + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '500': + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + put: + tags: + - Presentation Definitions + summary: Update a Presentation Definition + description: | + Updates an existing presentation definition. + operationId: updatePresentationDefinition + parameters: + - $ref: '#/components/parameters/definitionIdPathParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PresentationDefinitionUpdateModel' + required: true + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/PresentationDefinitionResponse' + '400': + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '500': + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + delete: + tags: + - Presentation Definitions + summary: Delete a Presentation Definition + description: | + Deletes a presentation definition by its ID. + operationId: deletePresentationDefinition + parameters: + - $ref: '#/components/parameters/definitionIdPathParam' + responses: + '204': + description: No Content + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '500': + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + +components: + parameters: + definitionIdPathParam: + name: definition-id + in: path + description: Unique identifier of the presentation definition. + required: true + schema: + type: string + + schemas: + PresentationDefinitionResponse: + type: object + required: + - id + - name + - credentials + properties: + id: + type: string + description: Unique identifier of the presentation definition. + example: "pd-001" + name: + type: string + description: Name of the presentation definition. + example: "Employee Credential Verification" + description: + type: string + description: Description of the presentation definition. + example: "Verifies employee credentials" + credentials: + type: array + description: The list of requested credentials in this presentation definition. + items: + $ref: '#/components/schemas/RequestedCredentialModel' + + RequestedCredentialModel: + type: object + required: + - type + properties: + type: + type: string + description: Type of the requested credential. + example: "EmployeeBadge" + purpose: + type: string + description: Purpose of requesting the credential. + example: "Please share your employee badge to prove employment." + issuer: + type: string + description: The trusted issuer for this credential. + claims: + type: array + description: List of claims requested from this credential. + items: + type: string + example: "email" + + PresentationDefinitionCreationModel: + type: object + required: + - name + - credentials + properties: + name: + type: string + description: Name of the presentation definition. + example: "Employee Credential Verification" + description: + type: string + description: Description of the presentation definition. + example: "Verifies employee credentials" + credentials: + type: array + description: The requested credentials to construct the definition. + items: + $ref: '#/components/schemas/RequestedCredentialModel' + + PresentationDefinitionUpdateModel: + type: object + properties: + name: + type: string + description: Name of the presentation definition. + example: "Updated Employee Credential Verification" + description: + type: string + description: Description of the presentation definition. + credentials: + type: array + description: The requested credentials to construct the definition. + items: + $ref: '#/components/schemas/RequestedCredentialModel' + + PresentationDefinitionList: + type: object + properties: + totalResults: + type: integer + description: Total number of presentation definitions. + example: 2 + presentationDefinitions: + type: array + items: + $ref: '#/components/schemas/PresentationDefinitionListItem' + + PresentationDefinitionListItem: + type: object + properties: + id: + type: string + description: Unique identifier of the presentation definition. + example: "pd-001" + name: + type: string + description: Name of the presentation definition. + example: "Employee Credential Verification" + description: + type: string + description: Description of the presentation definition. + + Error: + type: object + required: + - code + - message + properties: + code: + type: string + example: "VPD-60001" + message: + type: string + example: "Some error message" + description: + type: string + example: "Some error description" + traceId: + type: string + example: "e0fbcfeb-3617-43c4-8dd0-7b7d38e13047" + + securitySchemes: + BasicAuth: + type: http + scheme: basic + OAuth2: + type: oauth2 + flows: + authorizationCode: + authorizationUrl: 'https://localhost:9443/oauth2/authorize' + tokenUrl: 'https://localhost:9443/oauth2/token' + scopes: {} diff --git a/components/org.wso2.carbon.identity.api.server.vp.template.management/pom.xml b/components/org.wso2.carbon.identity.api.server.vp.template.management/pom.xml new file mode 100644 index 0000000000..51f1d2d485 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.vp.template.management/pom.xml @@ -0,0 +1,37 @@ + + + + + 4.0.0 + + + org.wso2.carbon.identity.server.api + identity-api-server + 1.5.10-SNAPSHOT + ../../pom.xml + + + org.wso2.carbon.identity.api.server.vp.template.management + pom + + + org.wso2.carbon.identity.api.server.vp.template.management.v1 + org.wso2.carbon.identity.api.server.vp.template.management.common + + diff --git a/pom.xml b/pom.xml index a52b007991..8132c87086 100644 --- a/pom.xml +++ b/pom.xml @@ -812,13 +812,9 @@ org.wso2.carbon.identity.server.api - common - ${project.version} - - - org.wso2.carbon.identity.server.api - v1 + org.wso2.carbon.identity.api.server.vp.template.management.v1 ${project.version} + provided org.wso2.carbon.identity.inbound.auth.oauth2 @@ -907,6 +903,24 @@ ${project.version} provided + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.vp.template.management.common + ${project.version} + provided + + + org.wso2.carbon.identity.openid4vc + org.wso2.carbon.identity.openid4vc.presentation.management + ${carbon.identity.openid4vc.version} + provided + + + org.wso2.carbon.identity.openid4vc + org.wso2.carbon.identity.openid4vc.presentation.common + ${carbon.identity.openid4vc.version} + provided + org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.credential.management.common @@ -1104,6 +1118,7 @@ 1.1.5 + 6.9.10 5.14.2 @@ -1155,6 +1170,7 @@ components/org.wso2.carbon.identity.api.server.workflow components/org.wso2.carbon.identity.api.server.asynchronous.operation.status.management components/org.wso2.carbon.identity.api.server.vc.template.management + components/org.wso2.carbon.identity.api.server.vp.template.management components/org.wso2.carbon.identity.api.server.credential.management