diff --git a/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/PresentationApiExtension.java b/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/PresentationApiExtension.java index 5beb0a2c9..cb0616abb 100644 --- a/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/PresentationApiExtension.java +++ b/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/PresentationApiExtension.java @@ -34,10 +34,6 @@ import org.eclipse.edc.web.jersey.jsonld.ObjectMapperProvider; import org.eclipse.edc.web.spi.WebService; -import java.net.URISyntaxException; - -import static org.eclipse.edc.identityhub.spi.model.IdentityHubConstants.IATP_CONTEXT_URL; -import static org.eclipse.edc.identityhub.spi.model.IdentityHubConstants.PRESENTATION_EXCHANGE_URL; import static org.eclipse.edc.spi.CoreConstants.JSON_LD; @Extension(value = "Presentation API Extension") @@ -45,8 +41,7 @@ public class PresentationApiExtension implements ServiceExtension { public static final String RESOLUTION_SCOPE = "resolution-scope"; public static final String RESOLUTION_CONTEXT = "resolution"; - public static final String PRESENTATION_EXCHANGE_V_1_JSON = "presentation-exchange.v1.json"; - public static final String PRESENTATION_QUERY_V_08_JSON = "presentation-query.v08.json"; + @Inject private TypeTransformerRegistry typeTransformer; @@ -77,8 +72,6 @@ public void initialize(ServiceExtensionContext context) { validatorRegistry.register(PresentationQuery.PRESENTATION_QUERY_TYPE_PROPERTY, new PresentationQueryValidator()); - // Setup API - cacheContextDocuments(getClass().getClassLoader()); var controller = new PresentationApiController(validatorRegistry, typeTransformer, credentialResolver, accessTokenVerifier, presentationGenerator, context.getMonitor()); var jsonLdMapper = typeManager.getMapper(JSON_LD); @@ -91,12 +84,5 @@ public void initialize(ServiceExtensionContext context) { typeTransformer.register(new JsonValueToGenericTypeTransformer(jsonLdMapper)); } - private void cacheContextDocuments(ClassLoader classLoader) { - try { - jsonLd.registerCachedDocument(PRESENTATION_EXCHANGE_URL, classLoader.getResource(PRESENTATION_EXCHANGE_V_1_JSON).toURI()); - jsonLd.registerCachedDocument(IATP_CONTEXT_URL, classLoader.getResource(PRESENTATION_QUERY_V_08_JSON).toURI()); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } + } diff --git a/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/v1/ApiSchema.java b/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/v1/ApiSchema.java index 55cbdfe13..551f9fba9 100644 --- a/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/v1/ApiSchema.java +++ b/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/v1/ApiSchema.java @@ -49,7 +49,7 @@ record PresentationQuerySchema( String type, @Schema(name = "scope", requiredMode = NOT_REQUIRED) List scope, - @Schema(name = "presentation_definition", requiredMode = NOT_REQUIRED) + @Schema(name = "presentationDefinition", requiredMode = NOT_REQUIRED) PresentationDefinitionSchema presentationDefinitionSchema ) { @@ -60,7 +60,7 @@ record PresentationQuerySchema( "https://identity.foundation/presentation-exchange/submission/v1" ], "@type": "Query", - "presentation_definition": null, + "presentationDefinition": null, "scope": [ "org.eclipse.edc.vc.type:SomeCredential_0.3.5:write, "org.eclipse.edc.vc.type:SomeOtherCredential:read, @@ -83,7 +83,7 @@ record PresentationDefinitionSchema() { private static final String EXAMPLE = """ { "comment": "taken from https://identity.foundation/presentation-exchange/spec/v2.0.0/#presentation-definition" - "presentation_definition": { + "presentationDefinition": { "id": "first simple example", "input_descriptors": [ { diff --git a/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/v1/PresentationApi.java b/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/v1/PresentationApi.java index 56be59050..30153348a 100644 --- a/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/v1/PresentationApi.java +++ b/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/v1/PresentationApi.java @@ -49,14 +49,14 @@ public interface PresentationApi { responses = { @ApiResponse(responseCode = "200", description = "The query was successfully processed, the response contains the VerifiablePresentation", content = @Content(schema = @Schema(implementation = PresentationResponse.class), mediaType = "application/ld+json")), - @ApiResponse(responseCode = "400", description = "Request body was malformed, for example when both scope and presentation_definition are given", + @ApiResponse(responseCode = "400", description = "Request body was malformed, for example when both scope and presentationDefinition are given", content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiErrorDetailSchema.class)), mediaType = "application/json")), @ApiResponse(responseCode = "401", description = "No Authorization header was given.", content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiErrorDetailSchema.class)), mediaType = "application/json")), @ApiResponse(responseCode = "403", description = "The given authentication token could not be validated. This can happen, when the request body " + "calls for a broader query scope than the granted scope in the auth token", content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiErrorDetailSchema.class)), mediaType = "application/json")), - @ApiResponse(responseCode = "501", description = "When the request contained a presentation_definition object, but the implementation does not support it.", + @ApiResponse(responseCode = "501", description = "When the request contained a presentationDefinition object, but the implementation does not support it.", content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiErrorDetailSchema.class)), mediaType = "application/json")) } ) diff --git a/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/validation/PresentationQueryValidator.java b/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/validation/PresentationQueryValidator.java index 67b43cbb5..03cfb6e34 100644 --- a/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/validation/PresentationQueryValidator.java +++ b/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/validation/PresentationQueryValidator.java @@ -25,7 +25,7 @@ /** * Validates, that a JsonObject representing a {@link PresentationQuery} contains either a {@code scope} property, - * or a {@code presentation_definition} query. + * or a {@code presentationDefinition} query. */ public class PresentationQueryValidator implements Validator { @Override @@ -35,11 +35,11 @@ public ValidationResult validate(JsonObject input) { var presentationDef = input.get(PresentationQuery.PRESENTATION_QUERY_DEFINITION_PROPERTY); if (scope == null && presentationDef == null) { - return failure(violation("Must contain either a 'scope' or a 'presentation_definition' property.", null)); + return failure(violation("Must contain either a 'scope' or a 'presentationDefinition' property.", null)); } if (scope != null && presentationDef != null) { - return failure(violation("Must contain either a 'scope' or a 'presentation_definition', not both.", null)); + return failure(violation("Must contain either a 'scope' or a 'presentationDefinition', not both.", null)); } return success(); diff --git a/core/identity-hub-api/src/main/resources/presentation-query.v08.json b/core/identity-hub-api/src/main/resources/presentation-query.v08.json deleted file mode 100644 index ee45d6f63..000000000 --- a/core/identity-hub-api/src/main/resources/presentation-query.v08.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "@context": { - "scope": { - "@id": "https://w3id.org/tractusx-trust/v0.8/scope", - "@container": "@set" - }, - "presentation_definition":{ - "@id": "https://w3id.org/tractusx-trust/v0.8/presentation_definition", - "@type": "@json" - } - } -} \ No newline at end of file diff --git a/core/identity-hub-api/src/test/java/org/eclipse/edc/identityservice/api/validation/PresentationQueryValidatorTest.java b/core/identity-hub-api/src/test/java/org/eclipse/edc/identityservice/api/validation/PresentationQueryValidatorTest.java index 1e1fde340..182c2b2ae 100644 --- a/core/identity-hub-api/src/test/java/org/eclipse/edc/identityservice/api/validation/PresentationQueryValidatorTest.java +++ b/core/identity-hub-api/src/test/java/org/eclipse/edc/identityservice/api/validation/PresentationQueryValidatorTest.java @@ -70,7 +70,7 @@ void validate_withPresentationDefinition_success() throws JsonProcessingExceptio @Test void validate_withNone_fails() { var jo = createObjectBuilder().build(); - assertThat(validator.validate(jo)).isFailed().detail().contains("Must contain either a 'scope' or a 'presentation_definition' property."); + assertThat(validator.validate(jo)).isFailed().detail().contains("Must contain either a 'scope' or a 'presentationDefinition' property."); } @Test @@ -84,7 +84,7 @@ void validate_withBoth_fails() throws JsonProcessingException { .add(PresentationQuery.PRESENTATION_QUERY_DEFINITION_PROPERTY, createPresentationDefArray(presDef)) .build(); - assertThat(validator.validate(jo)).isFailed().detail().contains("Must contain either a 'scope' or a 'presentation_definition', not both."); + assertThat(validator.validate(jo)).isFailed().detail().contains("Must contain either a 'scope' or a 'presentationDefinition', not both."); } private JsonArray createScopeArray() { diff --git a/core/identity-hub-core/build.gradle.kts b/core/identity-hub-core/build.gradle.kts index 4495ec2b6..f6a88c71b 100644 --- a/core/identity-hub-core/build.gradle.kts +++ b/core/identity-hub-core/build.gradle.kts @@ -4,6 +4,7 @@ plugins { dependencies { api(project(":spi:identity-hub-spi")) + implementation(libs.edc.spi.jsonld) implementation(libs.edc.iatp.service) // JWT validator implementation(libs.edc.core.crypto) // JWT verifier implementation(libs.nimbus.jwt) diff --git a/core/identity-hub-core/src/main/java/org/eclipse/edc/identityhub/core/CoreServicesExtension.java b/core/identity-hub-core/src/main/java/org/eclipse/edc/identityhub/core/CoreServicesExtension.java index fc6d44c65..36db996cb 100644 --- a/core/identity-hub-core/src/main/java/org/eclipse/edc/identityhub/core/CoreServicesExtension.java +++ b/core/identity-hub-core/src/main/java/org/eclipse/edc/identityhub/core/CoreServicesExtension.java @@ -21,6 +21,7 @@ import org.eclipse.edc.identityhub.token.verification.AccessTokenVerifierImpl; import org.eclipse.edc.identitytrust.validation.JwtValidator; import org.eclipse.edc.identitytrust.verification.JwtVerifier; +import org.eclipse.edc.jsonld.spi.JsonLd; import org.eclipse.edc.runtime.metamodel.annotation.Extension; import org.eclipse.edc.runtime.metamodel.annotation.Inject; import org.eclipse.edc.runtime.metamodel.annotation.Provider; @@ -29,6 +30,11 @@ import org.eclipse.edc.spi.system.ServiceExtensionContext; import org.eclipse.edc.verification.jwt.SelfIssuedIdTokenVerifier; +import java.net.URISyntaxException; + +import static org.eclipse.edc.identityhub.spi.model.IdentityHubConstants.IATP_CONTEXT_URL; +import static org.eclipse.edc.identityhub.spi.model.IdentityHubConstants.PRESENTATION_EXCHANGE_URL; + /** * This extension provides some core services for the IdentityHub, such as: *