diff --git a/core/identity-hub-api/build.gradle.kts b/core/identity-hub-api/build.gradle.kts index 93e182a96..1c9dfa50d 100644 --- a/core/identity-hub-api/build.gradle.kts +++ b/core/identity-hub-api/build.gradle.kts @@ -22,11 +22,11 @@ dependencies { api(libs.edc.spi.jsonld) api(libs.edc.spi.core) api(project(":spi:identity-hub-spi")) - implementation(project(":core:identity-hub-transform")) implementation(libs.edc.spi.validator) implementation(libs.edc.spi.web) implementation(libs.edc.core.jerseyproviders) implementation(libs.edc.core.transform) + implementation(libs.edc.iatp.transform) implementation(libs.jakarta.rsApi) testImplementation(libs.edc.junit) testImplementation(libs.edc.ext.jsonld) 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 cb0616abb..d1cdfe997 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 @@ -15,13 +15,13 @@ package org.eclipse.edc.identityservice.api; import org.eclipse.edc.core.transform.transformer.to.JsonValueToGenericTypeTransformer; +import org.eclipse.edc.iam.identitytrust.transform.to.JsonObjectToPresentationQueryTransformer; import org.eclipse.edc.identityhub.spi.generator.PresentationGenerator; -import org.eclipse.edc.identityhub.spi.model.PresentationQuery; import org.eclipse.edc.identityhub.spi.resolution.CredentialQueryResolver; import org.eclipse.edc.identityhub.spi.verification.AccessTokenVerifier; -import org.eclipse.edc.identityhub.transform.JsonObjectToPresentationQueryTransformer; import org.eclipse.edc.identityservice.api.v1.PresentationApiController; import org.eclipse.edc.identityservice.api.validation.PresentationQueryValidator; +import org.eclipse.edc.identitytrust.model.credentialservice.PresentationQuery; import org.eclipse.edc.jsonld.spi.JsonLd; import org.eclipse.edc.runtime.metamodel.annotation.Extension; import org.eclipse.edc.runtime.metamodel.annotation.Inject; @@ -79,7 +79,7 @@ public void initialize(ServiceExtensionContext context) { webService.registerResource(RESOLUTION_CONTEXT, new JerseyJsonLdInterceptor(jsonLd, jsonLdMapper, RESOLUTION_SCOPE)); webService.registerResource(RESOLUTION_CONTEXT, controller); - // register transformer + // register transformer -- remove once registration is handled in EDC typeTransformer.register(new JsonObjectToPresentationQueryTransformer(jsonLdMapper)); typeTransformer.register(new JsonValueToGenericTypeTransformer(jsonLdMapper)); } 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 30153348a..79073ae73 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 @@ -29,8 +29,8 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.json.JsonObject; import jakarta.ws.rs.core.Response; -import org.eclipse.edc.identityhub.spi.model.PresentationResponse; import org.eclipse.edc.identityservice.api.v1.ApiSchema.ApiErrorDetailSchema; +import org.eclipse.edc.identitytrust.model.credentialservice.PresentationResponse; @OpenAPIDefinition( info = @Info(description = "This represents the Presentation API as per IATP specification. It serves endpoints to query for specific VerifiablePresentations.", title = "Resolution API", diff --git a/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/v1/PresentationApiController.java b/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/v1/PresentationApiController.java index 700a91ecd..2291df06e 100644 --- a/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/v1/PresentationApiController.java +++ b/core/identity-hub-api/src/main/java/org/eclipse/edc/identityservice/api/v1/PresentationApiController.java @@ -22,9 +22,9 @@ import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.Response; import org.eclipse.edc.identityhub.spi.generator.PresentationGenerator; -import org.eclipse.edc.identityhub.spi.model.PresentationQuery; import org.eclipse.edc.identityhub.spi.resolution.CredentialQueryResolver; import org.eclipse.edc.identityhub.spi.verification.AccessTokenVerifier; +import org.eclipse.edc.identitytrust.model.credentialservice.PresentationQuery; import org.eclipse.edc.spi.EdcException; import org.eclipse.edc.spi.monitor.Monitor; import org.eclipse.edc.transform.spi.TypeTransformerRegistry; @@ -37,7 +37,7 @@ import static jakarta.ws.rs.core.HttpHeaders.AUTHORIZATION; import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; -import static org.eclipse.edc.identityhub.spi.model.PresentationQuery.PRESENTATION_QUERY_TYPE_PROPERTY; +import static org.eclipse.edc.identitytrust.model.credentialservice.PresentationQuery.PRESENTATION_QUERY_TYPE_PROPERTY; @Consumes(APPLICATION_JSON) @Produces(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 1095e652b..3031e0767 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 @@ -17,7 +17,7 @@ import jakarta.json.JsonArray; import jakarta.json.JsonObject; import jakarta.json.JsonValue; -import org.eclipse.edc.identityhub.spi.model.PresentationQuery; +import org.eclipse.edc.identitytrust.model.credentialservice.PresentationQuery; import org.eclipse.edc.jsonld.spi.JsonLdKeywords; import org.eclipse.edc.validator.spi.ValidationResult; import org.eclipse.edc.validator.spi.Validator; diff --git a/core/identity-hub-api/src/test/java/org/eclipse/edc/identityservice/api/v1/PresentationApiControllerTest.java b/core/identity-hub-api/src/test/java/org/eclipse/edc/identityservice/api/v1/PresentationApiControllerTest.java index 0b35c9471..990efb1f0 100644 --- a/core/identity-hub-api/src/test/java/org/eclipse/edc/identityservice/api/v1/PresentationApiControllerTest.java +++ b/core/identity-hub-api/src/test/java/org/eclipse/edc/identityservice/api/v1/PresentationApiControllerTest.java @@ -17,14 +17,14 @@ import com.nimbusds.jwt.JWTClaimsSet; import jakarta.json.JsonObject; import org.eclipse.edc.identityhub.spi.generator.PresentationGenerator; -import org.eclipse.edc.identityhub.spi.model.InputDescriptorMapping; -import org.eclipse.edc.identityhub.spi.model.PresentationQuery; -import org.eclipse.edc.identityhub.spi.model.PresentationResponse; -import org.eclipse.edc.identityhub.spi.model.PresentationSubmission; -import org.eclipse.edc.identityhub.spi.model.presentationdefinition.PresentationDefinition; import org.eclipse.edc.identityhub.spi.resolution.CredentialQueryResolver; import org.eclipse.edc.identityhub.spi.resolution.QueryResult; import org.eclipse.edc.identityhub.spi.verification.AccessTokenVerifier; +import org.eclipse.edc.identitytrust.model.credentialservice.InputDescriptorMapping; +import org.eclipse.edc.identitytrust.model.credentialservice.PresentationQuery; +import org.eclipse.edc.identitytrust.model.credentialservice.PresentationResponse; +import org.eclipse.edc.identitytrust.model.credentialservice.PresentationSubmission; +import org.eclipse.edc.identitytrust.model.presentationdefinition.PresentationDefinition; import org.eclipse.edc.junit.annotations.ApiTest; import org.eclipse.edc.spi.EdcException; import org.eclipse.edc.spi.result.Result; @@ -49,8 +49,8 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.eclipse.edc.identityhub.junit.testfixtures.VerifiableCredentialTestUtil.buildSignedJwt; import static org.eclipse.edc.identityhub.junit.testfixtures.VerifiableCredentialTestUtil.generateEcKey; -import static org.eclipse.edc.identityhub.spi.model.PresentationQuery.PRESENTATION_QUERY_TYPE_PROPERTY; import static org.eclipse.edc.identityhub.spi.resolution.QueryResult.success; +import static org.eclipse.edc.identitytrust.model.credentialservice.PresentationQuery.PRESENTATION_QUERY_TYPE_PROPERTY; import static org.eclipse.edc.validator.spi.ValidationResult.failure; import static org.eclipse.edc.validator.spi.ValidationResult.success; import static org.eclipse.edc.validator.spi.Violation.violation; 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 182c2b2ae..a3753fb36 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 @@ -19,11 +19,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.json.JsonArray; import jakarta.json.JsonObject; -import org.eclipse.edc.identityhub.spi.model.PresentationQuery; -import org.eclipse.edc.identityhub.spi.model.presentationdefinition.Constraints; -import org.eclipse.edc.identityhub.spi.model.presentationdefinition.Field; -import org.eclipse.edc.identityhub.spi.model.presentationdefinition.InputDescriptor; -import org.eclipse.edc.identityhub.spi.model.presentationdefinition.PresentationDefinition; +import org.eclipse.edc.identitytrust.model.credentialservice.PresentationQuery; +import org.eclipse.edc.identitytrust.model.presentationdefinition.Constraints; +import org.eclipse.edc.identitytrust.model.presentationdefinition.Field; +import org.eclipse.edc.identitytrust.model.presentationdefinition.InputDescriptor; +import org.eclipse.edc.identitytrust.model.presentationdefinition.PresentationDefinition; import org.eclipse.edc.jsonld.TitaniumJsonLd; import org.eclipse.edc.jsonld.spi.JsonLd; import org.eclipse.edc.jsonld.spi.JsonLdKeywords; diff --git a/core/identity-hub-core/src/main/java/org/eclipse/edc/identityhub/core/CredentialQueryResolverImpl.java b/core/identity-hub-core/src/main/java/org/eclipse/edc/identityhub/core/CredentialQueryResolverImpl.java index a82fcd705..40948bb01 100644 --- a/core/identity-hub-core/src/main/java/org/eclipse/edc/identityhub/core/CredentialQueryResolverImpl.java +++ b/core/identity-hub-core/src/main/java/org/eclipse/edc/identityhub/core/CredentialQueryResolverImpl.java @@ -15,11 +15,11 @@ package org.eclipse.edc.identityhub.core; import org.eclipse.edc.identityhub.spi.ScopeToCriterionTransformer; -import org.eclipse.edc.identityhub.spi.model.PresentationQuery; import org.eclipse.edc.identityhub.spi.resolution.CredentialQueryResolver; import org.eclipse.edc.identityhub.spi.resolution.QueryResult; import org.eclipse.edc.identityhub.spi.store.CredentialStore; import org.eclipse.edc.identityhub.spi.store.model.VerifiableCredentialResource; +import org.eclipse.edc.identitytrust.model.credentialservice.PresentationQuery; import org.eclipse.edc.spi.query.Criterion; import org.eclipse.edc.spi.query.QuerySpec; import org.eclipse.edc.spi.result.AbstractResult; diff --git a/core/identity-hub-core/src/main/java/org/eclipse/edc/identityhub/core/PresentationGeneratorImpl.java b/core/identity-hub-core/src/main/java/org/eclipse/edc/identityhub/core/PresentationGeneratorImpl.java index 924b8931e..b11c7e37a 100644 --- a/core/identity-hub-core/src/main/java/org/eclipse/edc/identityhub/core/PresentationGeneratorImpl.java +++ b/core/identity-hub-core/src/main/java/org/eclipse/edc/identityhub/core/PresentationGeneratorImpl.java @@ -18,10 +18,10 @@ import jakarta.json.JsonObject; import org.eclipse.edc.identityhub.spi.generator.PresentationCreatorRegistry; import org.eclipse.edc.identityhub.spi.generator.PresentationGenerator; -import org.eclipse.edc.identityhub.spi.model.PresentationResponse; -import org.eclipse.edc.identityhub.spi.model.presentationdefinition.PresentationDefinition; import org.eclipse.edc.identitytrust.model.CredentialFormat; import org.eclipse.edc.identitytrust.model.VerifiableCredentialContainer; +import org.eclipse.edc.identitytrust.model.credentialservice.PresentationResponse; +import org.eclipse.edc.identitytrust.model.presentationdefinition.PresentationDefinition; import org.eclipse.edc.spi.monitor.Monitor; import org.eclipse.edc.spi.result.Result; import org.jetbrains.annotations.Nullable; diff --git a/core/identity-hub-core/src/test/java/org/eclipse/edc/identityhub/core/CredentialQueryResolverImplTest.java b/core/identity-hub-core/src/test/java/org/eclipse/edc/identityhub/core/CredentialQueryResolverImplTest.java index 009373758..16e749765 100644 --- a/core/identity-hub-core/src/test/java/org/eclipse/edc/identityhub/core/CredentialQueryResolverImplTest.java +++ b/core/identity-hub-core/src/test/java/org/eclipse/edc/identityhub/core/CredentialQueryResolverImplTest.java @@ -16,8 +16,6 @@ import org.eclipse.edc.identityhub.defaults.EdcScopeToCriterionTransformer; -import org.eclipse.edc.identityhub.spi.model.PresentationQuery; -import org.eclipse.edc.identityhub.spi.model.presentationdefinition.PresentationDefinition; import org.eclipse.edc.identityhub.spi.resolution.QueryFailure; import org.eclipse.edc.identityhub.spi.store.CredentialStore; import org.eclipse.edc.identityhub.spi.store.model.VerifiableCredentialResource; @@ -26,6 +24,8 @@ import org.eclipse.edc.identitytrust.model.Issuer; import org.eclipse.edc.identitytrust.model.VerifiableCredential; import org.eclipse.edc.identitytrust.model.VerifiableCredentialContainer; +import org.eclipse.edc.identitytrust.model.credentialservice.PresentationQuery; +import org.eclipse.edc.identitytrust.model.presentationdefinition.PresentationDefinition; import org.eclipse.edc.spi.result.StoreResult; import org.jetbrains.annotations.Nullable; import org.junit.jupiter.api.Test; diff --git a/core/identity-hub-core/src/test/java/org/eclipse/edc/identityhub/core/PresentationGeneratorImplTest.java b/core/identity-hub-core/src/test/java/org/eclipse/edc/identityhub/core/PresentationGeneratorImplTest.java index f48eb7f26..f71ddba6e 100644 --- a/core/identity-hub-core/src/test/java/org/eclipse/edc/identityhub/core/PresentationGeneratorImplTest.java +++ b/core/identity-hub-core/src/test/java/org/eclipse/edc/identityhub/core/PresentationGeneratorImplTest.java @@ -18,12 +18,12 @@ import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.json.JsonObject; import org.eclipse.edc.identityhub.spi.generator.PresentationCreatorRegistry; -import org.eclipse.edc.identityhub.spi.model.presentationdefinition.PresentationDefinition; import org.eclipse.edc.identitytrust.model.CredentialFormat; import org.eclipse.edc.identitytrust.model.CredentialSubject; import org.eclipse.edc.identitytrust.model.Issuer; import org.eclipse.edc.identitytrust.model.VerifiableCredential; import org.eclipse.edc.identitytrust.model.VerifiableCredentialContainer; +import org.eclipse.edc.identitytrust.model.presentationdefinition.PresentationDefinition; import org.eclipse.edc.jsonld.util.JacksonJsonLd; import org.eclipse.edc.spi.monitor.Monitor; import org.junit.jupiter.api.Test; diff --git a/core/identity-hub-transform/build.gradle.kts b/core/identity-hub-transform/build.gradle.kts deleted file mode 100644 index c18e15bbb..000000000 --- a/core/identity-hub-transform/build.gradle.kts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * 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: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -plugins { - `java-library` - `maven-publish` -} - -dependencies { - api(project(":spi:identity-hub-spi")) - api(libs.edc.spi.jsonld) - api(libs.edc.spi.transform) - - testImplementation(libs.edc.ext.jsonld) - testImplementation(libs.edc.core.transform) - testImplementation(libs.edc.junit) -} \ No newline at end of file diff --git a/core/identity-hub-transform/src/main/java/org/eclipse/edc/identityhub/transform/JsonObjectToPresentationQueryTransformer.java b/core/identity-hub-transform/src/main/java/org/eclipse/edc/identityhub/transform/JsonObjectToPresentationQueryTransformer.java deleted file mode 100644 index abe4f1f10..000000000 --- a/core/identity-hub-transform/src/main/java/org/eclipse/edc/identityhub/transform/JsonObjectToPresentationQueryTransformer.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * 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: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.edc.identityhub.transform; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import jakarta.json.JsonArray; -import jakarta.json.JsonObject; -import jakarta.json.JsonValue; -import org.eclipse.edc.identityhub.spi.model.PresentationQuery; -import org.eclipse.edc.identityhub.spi.model.presentationdefinition.PresentationDefinition; -import org.eclipse.edc.jsonld.spi.JsonLdKeywords; -import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; -import org.eclipse.edc.transform.spi.TransformerContext; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Transforms a JsonObject into a PresentationQuery object. - */ -public class JsonObjectToPresentationQueryTransformer extends AbstractJsonLdTransformer { - - private final ObjectMapper mapper; - - public JsonObjectToPresentationQueryTransformer(ObjectMapper mapper) { - super(JsonObject.class, PresentationQuery.class); - this.mapper = mapper; - } - - @Override - public @Nullable PresentationQuery transform(@NotNull JsonObject jsonObject, @NotNull TransformerContext context) { - var bldr = PresentationQuery.Builder.newinstance(); - visitProperties(jsonObject, (k, v) -> { - switch (k) { - case PresentationQuery.PRESENTATION_QUERY_DEFINITION_PROPERTY -> bldr.presentationDefinition(readPresentationDefinition(v, context)); - case PresentationQuery.PRESENTATION_QUERY_SCOPE_PROPERTY -> transformArrayOrObject(v, Object.class, o -> bldr.scope(o.toString()), context); - default -> context.reportProblem("Unknown property '%s'".formatted(k)); - } - }); - - return bldr.build(); - } - - private PresentationDefinition readPresentationDefinition(JsonValue v, TransformerContext context) { - JsonObject jo; - if (v.getValueType() == JsonValue.ValueType.ARRAY && !((JsonArray) v).isEmpty()) { - jo = v.asJsonArray().getJsonObject(0); - } else { - jo = v.asJsonObject(); - } - var rawJson = jo.get(JsonLdKeywords.VALUE); - try { - return mapper.readValue(rawJson.toString(), PresentationDefinition.class); - } catch (JsonProcessingException e) { - context.reportProblem("Error reading JSON literal: %s".formatted(e.getMessage())); - return null; - } - } -} diff --git a/core/identity-hub-transform/src/test/java/org/eclipse/edc/identityhub/transform/JsonObjectToPresentationQueryTransformerTest.java b/core/identity-hub-transform/src/test/java/org/eclipse/edc/identityhub/transform/JsonObjectToPresentationQueryTransformerTest.java deleted file mode 100644 index ebd72f333..000000000 --- a/core/identity-hub-transform/src/test/java/org/eclipse/edc/identityhub/transform/JsonObjectToPresentationQueryTransformerTest.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * 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: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.edc.identityhub.transform; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import jakarta.json.JsonObject; -import org.eclipse.edc.core.transform.TransformerContextImpl; -import org.eclipse.edc.core.transform.TypeTransformerRegistryImpl; -import org.eclipse.edc.core.transform.transformer.to.JsonValueToGenericTypeTransformer; -import org.eclipse.edc.jsonld.TitaniumJsonLd; -import org.eclipse.edc.jsonld.spi.JsonLd; -import org.eclipse.edc.jsonld.util.JacksonJsonLd; -import org.eclipse.edc.junit.testfixtures.TestUtils; -import org.eclipse.edc.transform.spi.TransformerContext; -import org.eclipse.edc.transform.spi.TypeTransformerRegistry; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - -class JsonObjectToPresentationQueryTransformerTest { - private final ObjectMapper mapper = JacksonJsonLd.createObjectMapper(); - private final JsonObjectToPresentationQueryTransformer transformer = new JsonObjectToPresentationQueryTransformer(mapper); - private final JsonLd jsonLd = new TitaniumJsonLd(mock()); - private final TypeTransformerRegistry trr = new TypeTransformerRegistryImpl(); - private final TransformerContext context = new TransformerContextImpl(trr); - - - @BeforeEach - void setUp() { - jsonLd.registerCachedDocument("https://identity.foundation/presentation-exchange/submission/v1", TestUtils.getFileFromResourceName("presentation_ex.json").toURI()); - jsonLd.registerCachedDocument("https://w3id.org/tractusx-trust/v0.8", TestUtils.getFileFromResourceName("presentation_query.json").toURI()); - // delegate to the generic transformer - - trr.register(new JsonValueToGenericTypeTransformer(mapper)); - } - - @Test - void transform_withScopes() throws JsonProcessingException { - var obj = """ - { - "@context": [ - "https://identity.foundation/presentation-exchange/submission/v1", - "https://w3id.org/tractusx-trust/v0.8" - ], - "@type": "Query", - "scope": [ - "org.eclipse.edc.vc.type:TestCredential:read", - "org.eclipse.edc.vc.type:AnotherCredential:all" - ] - } - """; - var json = mapper.readValue(obj, JsonObject.class); - var jo = jsonLd.expand(json); - assertThat(jo.succeeded()).withFailMessage(jo::getFailureDetail).isTrue(); - - var query = transformer.transform(jo.getContent(), context); - assertThat(query).isNotNull(); - assertThat(query.getScopes()).hasSize(2) - .containsExactlyInAnyOrder( - "org.eclipse.edc.vc.type:TestCredential:read", - "org.eclipse.edc.vc.type:AnotherCredential:all"); - assertThat(query.getPresentationDefinition()).isNull(); - } - - @Test - void transform_withPresentationDefinition() throws JsonProcessingException { - var json = """ - { - "@context": [ - "https://identity.foundation/presentation-exchange/submission/v1", - "https://w3id.org/tractusx-trust/v0.8" - ], - "@type": "Query", - "presentationDefinition": { - "id": "first simple example", - "input_descriptors": [ - { - "id": "descriptor-id-1", - "name": "A specific type of VC", - "purpose": "We want a VC of this type", - "constraints": { - "fields": [ - { - "path": [ - "$.type" - ], - "filter": { - "type": "string", - "pattern": "" - } - } - ] - } - } - ] - } - } - """; - var jobj = mapper.readValue(json, JsonObject.class); - - var expansion = jsonLd.expand(jobj); - assertThat(expansion.succeeded()).withFailMessage(expansion::getFailureDetail).isTrue(); - - var query = transformer.transform(expansion.getContent(), context); - assertThat(query).isNotNull(); - assertThat(query.getScopes()).isNotNull().isEmpty(); - assertThat(query.getPresentationDefinition()).isNotNull(); - assertThat(query.getPresentationDefinition().getInputDescriptors()).isNotEmpty() - .allSatisfy(id -> assertThat(id.getId()).isEqualTo("descriptor-id-1")); - - } - - @Test - void transform_withScopesAndPresDef() throws JsonProcessingException { - var json = """ - { - "@context": [ - "https://identity.foundation/presentation-exchange/submission/v1", - "https://w3id.org/tractusx-trust/v0.8" - ], - "@type": "Query", - "scope": ["test-scope1"], - "presentationDefinition": { - "id": "first simple example", - "input_descriptors": [ - { - "id": "descriptor-id-1", - "name": "A specific type of VC", - "purpose": "We want a VC of this type", - "constraints": { - "fields": [ - { - "path": [ - "$.type" - ], - "filter": { - "type": "string", - "pattern": "" - } - } - ] - } - } - ] - } - } - """; - var jobj = mapper.readValue(json, JsonObject.class); - - var expansion = jsonLd.expand(jobj); - assertThat(expansion.succeeded()).withFailMessage(expansion::getFailureDetail).isTrue(); - - var query = transformer.transform(expansion.getContent(), context); - assertThat(query).isNotNull(); - assertThat(query.getScopes()).isNotNull().containsExactly("test-scope1"); - assertThat(query.getPresentationDefinition()).isNotNull(); - assertThat(query.getPresentationDefinition().getInputDescriptors()).isNotEmpty() - .allSatisfy(id -> assertThat(id.getId()).isEqualTo("descriptor-id-1")); - } -} \ No newline at end of file diff --git a/core/identity-hub-transform/src/test/resources/presentation_ex.json b/core/identity-hub-transform/src/test/resources/presentation_ex.json deleted file mode 100644 index 488925037..000000000 --- a/core/identity-hub-transform/src/test/resources/presentation_ex.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "@context": { - "@version": 1.1, - "PresentationSubmission": { - "@id": "https://identity.foundation/presentation-exchange/#presentation-submission", - "@context": { - "@version": 1.1, - "presentation_submission": { - "@id": "https://identity.foundation/presentation-exchange/#presentation-submission", - "@type": "@json" - } - } - } - } -} \ No newline at end of file diff --git a/core/identity-hub-transform/src/test/resources/presentation_query.json b/core/identity-hub-transform/src/test/resources/presentation_query.json deleted file mode 100644 index 740434b72..000000000 --- a/core/identity-hub-transform/src/test/resources/presentation_query.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "@context": { - "scope": { - "@id": "https://w3id.org/tractusx-trust/v0.8/scope", - "@container": "@set" - }, - "presentationDefinition": { - "@id": "https://w3id.org/tractusx-trust/v0.8/presentationDefinition", - "@type": "@json" - } - } -} \ No newline at end of file diff --git a/e2e-tests/api-tests/src/test/java/org/eclipse/edc/identityhub/tests/ResolutionApiComponentTest.java b/e2e-tests/api-tests/src/test/java/org/eclipse/edc/identityhub/tests/ResolutionApiComponentTest.java index 3296fac04..c4465aacc 100644 --- a/e2e-tests/api-tests/src/test/java/org/eclipse/edc/identityhub/tests/ResolutionApiComponentTest.java +++ b/e2e-tests/api-tests/src/test/java/org/eclipse/edc/identityhub/tests/ResolutionApiComponentTest.java @@ -16,14 +16,14 @@ import com.nimbusds.jose.jwk.ECKey; import org.eclipse.edc.identityhub.spi.generator.PresentationGenerator; -import org.eclipse.edc.identityhub.spi.model.InputDescriptorMapping; -import org.eclipse.edc.identityhub.spi.model.PresentationResponse; -import org.eclipse.edc.identityhub.spi.model.PresentationSubmission; import org.eclipse.edc.identityhub.spi.resolution.CredentialQueryResolver; import org.eclipse.edc.identityhub.spi.resolution.QueryResult; import org.eclipse.edc.identityhub.spi.verification.AccessTokenVerifier; import org.eclipse.edc.identityhub.tests.fixtures.IdentityHubRuntimeConfiguration; import org.eclipse.edc.identityhub.tests.fixtures.TestData; +import org.eclipse.edc.identitytrust.model.credentialservice.InputDescriptorMapping; +import org.eclipse.edc.identitytrust.model.credentialservice.PresentationResponse; +import org.eclipse.edc.identitytrust.model.credentialservice.PresentationSubmission; import org.eclipse.edc.junit.annotations.ComponentTest; import org.eclipse.edc.junit.extensions.EdcRuntimeExtension; import org.junit.jupiter.api.Test; diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bfdb1e6fa..a0ca250d9 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -49,6 +49,7 @@ edc-identity-did-core = { module = "org.eclipse.edc:identity-did-core", version. edc-identity-did-web = { module = "org.eclipse.edc:identity-did-web", version.ref = "edc" } edc-iatp-service = { module = "org.eclipse.edc:identity-trust-service", version.ref = "edc" } edc-iatp-core = { module = "org.eclipse.edc:identity-trust-core", version.ref = "edc" } +edc-iatp-transform = { module = "org.eclipse.edc:identity-trust-transform", version.ref = "edc" } edc-vc-jwt = { module = "org.eclipse.edc:jwt-verifiable-credentials", version.ref = "edc" } edc-vc-ldp = { module = "org.eclipse.edc:ldp-verifiable-credentials", version.ref = "edc" } edc-ext-http = { module = "org.eclipse.edc:http", version.ref = "edc" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 42da50a62..9cd0b8359 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -28,7 +28,6 @@ include(":spi:identity-hub-store-spi") // core modules include(":core:identity-hub-api") -include(":core:identity-hub-transform") include(":core:identity-hub-core") // extension modules diff --git a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/PresentationGenerator.java b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/PresentationGenerator.java index 175b974c5..5a2ecc0ba 100644 --- a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/PresentationGenerator.java +++ b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/PresentationGenerator.java @@ -14,9 +14,9 @@ package org.eclipse.edc.identityhub.spi.generator; -import org.eclipse.edc.identityhub.spi.model.PresentationResponse; -import org.eclipse.edc.identityhub.spi.model.presentationdefinition.PresentationDefinition; import org.eclipse.edc.identitytrust.model.VerifiableCredentialContainer; +import org.eclipse.edc.identitytrust.model.credentialservice.PresentationResponse; +import org.eclipse.edc.identitytrust.model.presentationdefinition.PresentationDefinition; import org.eclipse.edc.spi.result.Result; import org.jetbrains.annotations.Nullable; diff --git a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/IdentityHubConstants.java b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/IdentityHubConstants.java index bdf928f40..07a7e9a79 100644 --- a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/IdentityHubConstants.java +++ b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/IdentityHubConstants.java @@ -14,15 +14,7 @@ package org.eclipse.edc.identityhub.spi.model; -public interface IdentityHubConstants { - String IATP_CONTEXT_URL = "https://w3id.org/tractusx-trust/v0.8"; - String IATP_PREFIX = IATP_CONTEXT_URL + "/"; - String PRESENTATION_EXCHANGE_URL = "https://identity.foundation/presentation-exchange/submission/v1"; - String W3C_CREDENTIALS_URL = "https://www.w3.org/2018/credentials/v1"; - String VERIFIABLE_PRESENTATION_TYPE = "VerifiablePresentation"; - String JWS_2020_URL = "https://w3id.org/security/suites/jws-2020/v1"; - String DID_CONTEXT_URL = "https://www.w3.org/ns/did/v1"; - String PRESENTATION_SUBMISSION_URL = "https://identity.foundation/presentation-exchange/submission/v1/"; - String JWS_2020_SIGNATURE_SUITE = "JsonWebSignature2020"; - String ED25519_SIGNATURE_SUITE = "Ed25519Signature2020"; // not used right now +import org.eclipse.edc.identitytrust.VcConstants; + +public interface IdentityHubConstants extends VcConstants { } diff --git a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/InputDescriptorMapping.java b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/InputDescriptorMapping.java deleted file mode 100644 index ec4bf9f1d..000000000 --- a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/InputDescriptorMapping.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * 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: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.edc.identityhub.spi.model; - -/** - * Represents the {@code descriptor_map} of a Presentation Submission - */ -public record InputDescriptorMapping(String id, String format, String path) { -} diff --git a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/PresentationQuery.java b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/PresentationQuery.java deleted file mode 100644 index 5d05fd703..000000000 --- a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/PresentationQuery.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * 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: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.edc.identityhub.spi.model; - -import org.eclipse.edc.identityhub.spi.model.presentationdefinition.PresentationDefinition; - -import java.util.ArrayList; -import java.util.List; - -import static org.eclipse.edc.identityhub.spi.model.IdentityHubConstants.IATP_PREFIX; - - -/** - * Represents a query that is sent to a CredentialService. - * - * @see IATP Specification - */ -public class PresentationQuery { - public static final String PRESENTATION_QUERY_SCOPE_PROPERTY = IATP_PREFIX + "scope"; - public static final String PRESENTATION_QUERY_DEFINITION_PROPERTY = IATP_PREFIX + "presentationDefinition"; - public static final String PRESENTATION_QUERY_TYPE_PROPERTY = IATP_PREFIX + "Query"; - private List scopes = new ArrayList<>(); - private PresentationDefinition presentationDefinition; - - private PresentationQuery() { - } - - public List getScopes() { - return scopes; - } - - public PresentationDefinition getPresentationDefinition() { - return presentationDefinition; - } - - public static final class Builder { - private final PresentationQuery query; - - private Builder() { - query = new PresentationQuery(); - } - - public static Builder newinstance() { - return new Builder(); - } - - public Builder scopes(List scopes) { - this.query.scopes = scopes; - return this; - } - - public Builder scope(String scope) { - this.query.scopes.add(scope); - return this; - } - - public Builder presentationDefinition(PresentationDefinition presentationDefinition) { - this.query.presentationDefinition = presentationDefinition; - return this; - } - - public PresentationQuery build() { - return query; - } - } -} diff --git a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/PresentationResponse.java b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/PresentationResponse.java deleted file mode 100644 index 6dd2610ac..000000000 --- a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/PresentationResponse.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * 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: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.edc.identityhub.spi.model; - -/** - * A representation of a Presentation Response - * that the credential service sends back to the requester. - */ -public record PresentationResponse(String vpToken, PresentationSubmission presentationSubmission) { -} diff --git a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/PresentationSubmission.java b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/PresentationSubmission.java deleted file mode 100644 index b3b1fa4bb..000000000 --- a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/PresentationSubmission.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * 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: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.edc.identityhub.spi.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -/** - * Representation of a DIF Presentation Submission. - */ -public record PresentationSubmission(@JsonProperty("id") String id, - @JsonProperty("definition_id") String definitionId, - @JsonProperty("descriptor_map") List descriptorMap) { -} diff --git a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/presentationdefinition/Constraints.java b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/presentationdefinition/Constraints.java deleted file mode 100644 index 70772735c..000000000 --- a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/presentationdefinition/Constraints.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * 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: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.edc.identityhub.spi.model.presentationdefinition; - -import java.util.List; - -public record Constraints(List fields) { -} \ No newline at end of file diff --git a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/presentationdefinition/Field.java b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/presentationdefinition/Field.java deleted file mode 100644 index 32bb2f98e..000000000 --- a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/presentationdefinition/Field.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * 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: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.edc.identityhub.spi.model.presentationdefinition; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -public class Field { - private List paths = new ArrayList<>(); - private String id; - private String name; - private String purpose; - private FilterExpression expr; - - private Field() { - - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public String getPurpose() { - return purpose; - } - - public List getPaths() { - return paths; - } - - public FilterExpression getExpr() { - return expr; - } - - - public static final class Builder { - private final Field field; - - private Builder() { - field = new Field(); - } - - public static Builder newInstance() { - return new Builder(); - } - - public Builder paths(List paths) { - this.field.paths = paths; - return this; - } - - public Builder id(String id) { - this.field.id = id; - return this; - } - - public Builder name(String name) { - this.field.name = name; - return this; - } - - public Builder purpose(String purpose) { - this.field.purpose = purpose; - return this; - } - - public Builder expr(FilterExpression expr) { - this.field.expr = expr; - return this; - } - - public Field build() { - Objects.requireNonNull(field.paths, "Must contain a paths property."); - return field; - } - } -} diff --git a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/presentationdefinition/FilterExpression.java b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/presentationdefinition/FilterExpression.java deleted file mode 100644 index 6a70d87eb..000000000 --- a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/presentationdefinition/FilterExpression.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * 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: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.edc.identityhub.spi.model.presentationdefinition; - -public record FilterExpression(String type, String pattern) { -} diff --git a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/presentationdefinition/Format.java b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/presentationdefinition/Format.java deleted file mode 100644 index f6a23b506..000000000 --- a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/presentationdefinition/Format.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * 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: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.edc.identityhub.spi.model.presentationdefinition; - -public class Format { -} diff --git a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/presentationdefinition/InputDescriptor.java b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/presentationdefinition/InputDescriptor.java deleted file mode 100644 index 2e4840709..000000000 --- a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/presentationdefinition/InputDescriptor.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * 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: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.edc.identityhub.spi.model.presentationdefinition; - -import java.util.Objects; - -public class InputDescriptor { - private String id; - private String name; - private String purpose; - private Format format; - private Constraints constraints; - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public String getPurpose() { - return purpose; - } - - public Format getFormat() { - return format; - } - - public Constraints getConstraints() { - return constraints; - } - - public static final class Builder { - private final InputDescriptor descriptor; - - private Builder() { - descriptor = new InputDescriptor(); - } - - public static Builder newInstance() { - return new Builder(); - } - - public Builder id(String id) { - this.descriptor.id = id; - return this; - } - - public Builder name(String name) { - this.descriptor.name = name; - return this; - } - - public Builder purpose(String purpose) { - this.descriptor.purpose = purpose; - return this; - } - - public Builder format(Format format) { - this.descriptor.format = format; - return this; - } - - public Builder constraints(Constraints constraints) { - this.descriptor.constraints = constraints; - return this; - } - - public InputDescriptor build() { - Objects.requireNonNull(descriptor.id, "InputDescriptor must have an ID."); - Objects.requireNonNull(descriptor.constraints, "InputDescriptor must have a Constraints object."); - return descriptor; - } - } -} diff --git a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/presentationdefinition/PresentationDefinition.java b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/presentationdefinition/PresentationDefinition.java deleted file mode 100644 index 3346242d2..000000000 --- a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/model/presentationdefinition/PresentationDefinition.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * 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: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.edc.identityhub.spi.model.presentationdefinition; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; - -import java.util.List; -import java.util.Objects; - -/** - * Represents a DIF Presentation Definition - */ - -public class PresentationDefinition { - private String id; - private String name; - private String purpose; - @JsonProperty("input_descriptors") - private List inputDescriptors; - private Format format; - - private PresentationDefinition() { - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public String getPurpose() { - return purpose; - } - - public List getInputDescriptors() { - return inputDescriptors; - } - - public Format getFormat() { - return format; - } - - @JsonPOJOBuilder(withPrefix = "") - public static final class Builder { - private final PresentationDefinition presentationDefinition; - - private Builder() { - presentationDefinition = new PresentationDefinition(); - } - - @JsonCreator - public static Builder newInstance() { - return new Builder(); - } - - public Builder id(String id) { - this.presentationDefinition.id = id; - return this; - } - - public Builder name(String name) { - this.presentationDefinition.name = name; - return this; - } - - public Builder purpose(String purpose) { - this.presentationDefinition.purpose = purpose; - return this; - } - - public Builder inputDescriptors(List inputDescriptor) { - this.presentationDefinition.inputDescriptors = inputDescriptor; - return this; - } - - public Builder format(Format format) { - this.presentationDefinition.format = format; - return this; - } - - public PresentationDefinition build() { - Objects.requireNonNull(presentationDefinition.id, "PresentationDefinition must have an ID."); - return presentationDefinition; - } - } -} diff --git a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/resolution/CredentialQueryResolver.java b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/resolution/CredentialQueryResolver.java index 559159742..49e84d185 100644 --- a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/resolution/CredentialQueryResolver.java +++ b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/resolution/CredentialQueryResolver.java @@ -14,8 +14,8 @@ package org.eclipse.edc.identityhub.spi.resolution; -import org.eclipse.edc.identityhub.spi.model.PresentationQuery; import org.eclipse.edc.identitytrust.model.VerifiableCredentialContainer; +import org.eclipse.edc.identitytrust.model.credentialservice.PresentationQuery; import java.util.List; diff --git a/spi/identity-hub-spi/src/test/java/org/eclipse/edc/identityhub/spi/model/PresentationSubmissionSerDesTest.java b/spi/identity-hub-spi/src/test/java/org/eclipse/edc/identityhub/spi/model/PresentationSubmissionSerDesTest.java deleted file mode 100644 index 5aade13e4..000000000 --- a/spi/identity-hub-spi/src/test/java/org/eclipse/edc/identityhub/spi/model/PresentationSubmissionSerDesTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * 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: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.edc.identityhub.spi.model; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.Test; - -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; - -class PresentationSubmissionSerDesTest { - private final ObjectMapper mapper = new ObjectMapper(); - - @Test - void verifyDeserialization() throws JsonProcessingException { - var json = """ - { - "id": "a30e3b91-fb77-4d22-95fa-871689c322e2", - "definition_id": "32f54163-7166-48f1-93d8-ff217bdb0653", - "descriptor_map": [ - { - "id": "banking_input_2", - "format": "jwt_vc", - "path": "$.verifiableCredential[0]" - }, - { - "id": "employment_input", - "format": "ldp_vc", - "path": "$.verifiableCredential[1]" - }, - { - "id": "citizenship_input_1", - "format": "ldp_vc", - "path": "$.verifiableCredential[2]" - } - ] - } - """; - var pd = mapper.readValue(json, PresentationSubmission.class); - assertThat(pd).isNotNull(); - - assertThat(pd.id()).isEqualTo("a30e3b91-fb77-4d22-95fa-871689c322e2"); - assertThat(pd.definitionId()).isEqualTo("32f54163-7166-48f1-93d8-ff217bdb0653"); - assertThat(pd.descriptorMap()).hasSize(3); - } - - @Test - void verifySerialization() throws JsonProcessingException { - var pd = new PresentationSubmission("test-id", "test-def-id", List.of(new InputDescriptorMapping("test-input", "ldp_vc", "$.verifiableCredentials[0]"))); - var json = mapper.writeValueAsString(pd); - - var deser = mapper.readValue(json, PresentationSubmission.class); - assertThat(deser).usingRecursiveComparison().isEqualTo(pd); - } -} \ No newline at end of file