-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: introduce messages and JSON-LD transformers for DCP issuer #551
Merged
wolf4ood
merged 1 commit into
eclipse-edc:main
from
wolf4ood:feat/544_dcp_issuance_messages
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
182 changes: 182 additions & 0 deletions
182
...src/main/java/org/eclipse/edc/identityhub/protocols/dcp/issuer/api/v1alpha/ApiSchema.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
/* | ||
* Copyright (c) 2025 Cofinity-X | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Cofinity-X - initial API and implementation | ||
* | ||
*/ | ||
|
||
package org.eclipse.edc.identityhub.protocols.dcp.issuer.api.v1alpha; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
import java.util.List; | ||
|
||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | ||
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.CONTEXT; | ||
|
||
public interface ApiSchema { | ||
@Schema(name = "ApiErrorDetail", example = ApiErrorDetailSchema.API_ERROR_EXAMPLE) | ||
record ApiErrorDetailSchema( | ||
String message, | ||
String type, | ||
String path, | ||
String invalidValue | ||
) { | ||
public static final String API_ERROR_EXAMPLE = """ | ||
{ | ||
"message": "error message", | ||
"type": "ErrorType", | ||
"path": "object.error.path", | ||
"invalidValue": "this value is not valid" | ||
} | ||
"""; | ||
} | ||
|
||
@Schema(name = "CredentialRequestMessage", example = CredentialRequestMessageSchema.RESPONSE_EXAMPLE) | ||
record CredentialRequestMessageSchema( | ||
@Schema(name = CONTEXT, requiredMode = REQUIRED) | ||
Object context, | ||
@Schema(requiredMode = REQUIRED) | ||
List<CredentialRequestSchema> credentials | ||
) { | ||
|
||
public static final String RESPONSE_EXAMPLE = """ | ||
{ | ||
"@context": [ | ||
"https://w3id.org/dspace-dcp/v1.0/dcp.jsonld" | ||
], | ||
"type": "CredentialRequestMessage", | ||
"credentials": [ | ||
{ | ||
"credentialType": "MembershipCredential", | ||
"format": "vcdm11_jwt" | ||
}, | ||
{ | ||
"credentialType": "OrganizationCredential", | ||
"format": "vcdm11_ld" | ||
}, | ||
{ | ||
"credentialType": "Iso9001Credential", | ||
"format": "vcdm20_jose" | ||
} | ||
] | ||
} | ||
"""; | ||
} | ||
|
||
@Schema(name = "CredentialRequest", example = CredentialRequestSchema.EXAMPLE) | ||
record CredentialRequestSchema( | ||
@Schema(name = "credentialType", requiredMode = REQUIRED) | ||
String credentialType, | ||
@Schema(name = "format", requiredMode = REQUIRED) | ||
String format | ||
) { | ||
public static final String EXAMPLE = """ | ||
{ | ||
"credentialType": "MembershipCredential", | ||
"format": "vcdm11_jwt" | ||
} | ||
"""; | ||
} | ||
|
||
@Schema(name = "CredentialStatus", example = CredentialStatusSchema.RESPONSE_EXAMPLE) | ||
record CredentialStatusSchema( | ||
@Schema(name = CONTEXT, requiredMode = REQUIRED) | ||
Object context, | ||
@Schema(name = "type", requiredMode = REQUIRED) | ||
String type, | ||
@Schema(name = "status", requiredMode = REQUIRED) | ||
String status | ||
) { | ||
|
||
public static final String RESPONSE_EXAMPLE = """ | ||
{ | ||
"@context": [ | ||
"https://w3id.org/dspace-dcp/v1.0/dcp.jsonld" | ||
], | ||
"type": "CredentialStatus", | ||
"requestId": "requestId", | ||
"status": "RECEIVED" | ||
} | ||
"""; | ||
} | ||
|
||
@Schema(name = "IssuerMetadata", example = IssuerMetadataSchema.RESPONSE_EXAMPLE) | ||
record IssuerMetadataSchema( | ||
@Schema(name = CONTEXT, requiredMode = REQUIRED) | ||
Object context, | ||
@Schema(name = "type", requiredMode = REQUIRED) | ||
String type, | ||
@Schema(name = "credentialIssuer", requiredMode = REQUIRED) | ||
String credentialIssuer, | ||
@Schema(name = "status", requiredMode = REQUIRED) | ||
String status | ||
) { | ||
|
||
public static final String RESPONSE_EXAMPLE = """ | ||
{ | ||
"@context": [ | ||
"https://w3id.org/dspace-dcp/v1.0/dcp.jsonld" | ||
], | ||
"type": "IssuerMetadata", | ||
"credentialIssuer": "did:web:issuer-url", | ||
"credentialsSupported": [ | ||
{ | ||
"type": "CredentialObject", | ||
"credentialType": "MembershipCredential", | ||
"offerReason": "reissue", | ||
"bindingMethods": [ | ||
"did:web" | ||
], | ||
"profiles": [ | ||
"vc20-bssl/jwt", "vc10-sl2021/jwt", "..." | ||
], | ||
"issuancePolicy": { | ||
"id": "Scalable trust example", | ||
"input_descriptors": [ | ||
{ | ||
"id": "pd-id", | ||
"constraints": { | ||
"fields": [ | ||
{ | ||
"path": [ | ||
"$.vc.type" | ||
], | ||
"filter": { | ||
"type": "string", | ||
"pattern": "^AttestationCredential$" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
"""; | ||
} | ||
|
||
@Schema(name = "CredentialObject", example = CredentialObjectSchema.EXAMPLE) | ||
record CredentialObjectSchema( | ||
@Schema(name = "credentialType", requiredMode = REQUIRED) | ||
String credentialType, | ||
@Schema(name = "format", requiredMode = REQUIRED) | ||
String format | ||
) { | ||
public static final String EXAMPLE = """ | ||
{ | ||
"credentialType": "MembershipCredential", | ||
"format": "vcdm11_jwt" | ||
} | ||
"""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should utilize the
externalDoc
functionality of OpenAPI to directly reference relevant parts of the DCP specification...for a separate PR of course, but that would guarantee consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also remove the
OpenApi
docs and use directly the specification as we do forDSP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm OK with either