From aae5b43a47889a09491e0da8119e589cd6ca6834 Mon Sep 17 00:00:00 2001 From: Paul Latzelsperger <43503240+paullatzelsperger@users.noreply.github.com> Date: Wed, 6 Dec 2023 15:23:09 +0100 Subject: [PATCH] refactor: rename classes (#185) * refactor: rename classes to follow the spec * DEPENDENCIES --- DEPENDENCIES | 30 ++++++++++--------- .../api/PresentationApiExtension.java | 6 ++-- .../api/v1/PresentationApiController.java | 10 +++---- .../api/v1/PresentationApiControllerTest.java | 4 +-- .../core/CoreServicesExtension.java | 14 ++++----- .../core/PresentationCreatorRegistryImpl.java | 8 ++--- ...=> VerifiablePresentationServiceImpl.java} | 6 ++-- ...tor.java => JwtPresentationGenerator.java} | 12 ++++---- ...tor.java => LdpPresentationGenerator.java} | 14 ++++----- ...erifiablePresentationServiceImplTest.java} | 20 ++++++------- ...java => JwtPresentationGeneratorTest.java} | 20 ++++++------- ...java => LdpPresentationGeneratorTest.java} | 20 ++++++------- ...st.java => PresentationGeneratorTest.java} | 2 +- .../identity-and-trust-modules.md | 17 ++++++----- .../identity.hub.architecture.md | 12 ++++---- .../tests/ResolutionApiComponentTest.java | 6 ++-- .../PresentationCreatorRegistry.java | 6 ++-- ...reator.java => PresentationGenerator.java} | 8 ++--- ...ava => VerifiablePresentationService.java} | 2 +- 19 files changed, 111 insertions(+), 106 deletions(-) rename core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/{PresentationCreationServiceImpl.java => VerifiablePresentationServiceImpl.java} (93%) rename core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/creators/{JwtPresentationCreator.java => JwtPresentationGenerator.java} (90%) rename core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/creators/{LdpPresentationCreator.java => LdpPresentationGenerator.java} (91%) rename core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/{PresentationCreationServiceImplTest.java => VerifiablePresentationServiceImplTest.java} (90%) rename core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/{JwtPresentationCreatorTest.java => JwtPresentationGeneratorTest.java} (87%) rename core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/{LdpPresentationCreatorTest.java => LdpPresentationGeneratorTest.java} (88%) rename core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/{PresentationCreatorTest.java => PresentationGeneratorTest.java} (98%) rename spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/{PresentationCreator.java => PresentationGenerator.java} (91%) rename spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/{PresentationCreationService.java => VerifiablePresentationService.java} (97%) diff --git a/DEPENDENCIES b/DEPENDENCIES index b9a2a79fd..cd7b50306 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -11,6 +11,7 @@ maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.14.1, Apache maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.14.2, Apache-2.0, approved, #5303 maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.15.1, Apache-2.0, approved, #7947 maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.15.2, Apache-2.0, approved, #7947 +maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.15.3, Apache-2.0, approved, #7947 maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.16.0, Apache-2.0, approved, #11606 maven/mavencentral/com.fasterxml.jackson.core/jackson-core/2.14.1, Apache-2.0 AND MIT, approved, #4303 maven/mavencentral/com.fasterxml.jackson.core/jackson-core/2.14.2, Apache-2.0 AND MIT, approved, #4303 @@ -22,6 +23,7 @@ maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.14.1, Apache-2. maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.14.2, Apache-2.0, approved, #4105 maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.15.1, Apache-2.0, approved, #7934 maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.15.2, Apache-2.0, approved, #7934 +maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.15.3, Apache-2.0, approved, #7934 maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.16.0, Apache-2.0, approved, #11605 maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.14.0, Apache-2.0, approved, #5933 maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.15.1, Apache-2.0, approved, #8802 @@ -37,7 +39,7 @@ maven/mavencentral/com.fasterxml.jackson.jakarta.rs/jackson-jakarta-rs-base/2.16 maven/mavencentral/com.fasterxml.jackson.jakarta.rs/jackson-jakarta-rs-json-provider/2.15.1, Apache-2.0, approved, #9236 maven/mavencentral/com.fasterxml.jackson.jakarta.rs/jackson-jakarta-rs-json-provider/2.15.2, Apache-2.0, approved, #9236 maven/mavencentral/com.fasterxml.jackson.jakarta.rs/jackson-jakarta-rs-json-provider/2.16.0, , restricted, clearlydefined -maven/mavencentral/com.fasterxml.jackson.module/jackson-module-jakarta-xmlbind-annotations/2.14.1, Apache-2.0, approved, #5308 +maven/mavencentral/com.fasterxml.jackson.module/jackson-module-jakarta-xmlbind-annotations/2.15.3, Apache-2.0, approved, #9241 maven/mavencentral/com.fasterxml.jackson.module/jackson-module-jakarta-xmlbind-annotations/2.16.0, , restricted, clearlydefined maven/mavencentral/com.fasterxml.jackson/jackson-bom/2.15.1, Apache-2.0, approved, #7929 maven/mavencentral/com.fasterxml.jackson/jackson-bom/2.16.0, , restricted, clearlydefined @@ -284,20 +286,20 @@ maven/mavencentral/org.eclipse.jetty/jetty-servlet/11.0.18, EPL-2.0 OR Apache-2. maven/mavencentral/org.eclipse.jetty/jetty-util/11.0.18, EPL-2.0 OR Apache-2.0, approved, rt.jetty maven/mavencentral/org.eclipse.jetty/jetty-webapp/11.0.18, EPL-2.0 OR Apache-2.0, approved, rt.jetty maven/mavencentral/org.eclipse.jetty/jetty-xml/11.0.18, EPL-2.0 OR Apache-2.0, approved, rt.jetty -maven/mavencentral/org.glassfish.hk2.external/aopalliance-repackaged/3.0.4, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish -maven/mavencentral/org.glassfish.hk2/hk2-api/3.0.4, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish -maven/mavencentral/org.glassfish.hk2/hk2-locator/3.0.4, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish -maven/mavencentral/org.glassfish.hk2/hk2-utils/3.0.4, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish +maven/mavencentral/org.glassfish.hk2.external/aopalliance-repackaged/3.0.5, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish +maven/mavencentral/org.glassfish.hk2/hk2-api/3.0.5, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish +maven/mavencentral/org.glassfish.hk2/hk2-locator/3.0.5, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish +maven/mavencentral/org.glassfish.hk2/hk2-utils/3.0.5, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.glassfish maven/mavencentral/org.glassfish.hk2/osgi-resource-locator/1.0.3, CDDL-1.0, approved, CQ10889 -maven/mavencentral/org.glassfish.jersey.containers/jersey-container-servlet-core/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.containers/jersey-container-servlet/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.core/jersey-client/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.core/jersey-common/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.core/jersey-server/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.ext/jersey-entity-filtering/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.inject/jersey-hk2/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.media/jersey-media-json-jackson/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey -maven/mavencentral/org.glassfish.jersey.media/jersey-media-multipart/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey +maven/mavencentral/org.glassfish.jersey.containers/jersey-container-servlet-core/3.1.4, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey +maven/mavencentral/org.glassfish.jersey.containers/jersey-container-servlet/3.1.4, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey +maven/mavencentral/org.glassfish.jersey.core/jersey-client/3.1.4, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey +maven/mavencentral/org.glassfish.jersey.core/jersey-common/3.1.4, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey +maven/mavencentral/org.glassfish.jersey.core/jersey-server/3.1.4, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey +maven/mavencentral/org.glassfish.jersey.ext/jersey-entity-filtering/3.1.4, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey +maven/mavencentral/org.glassfish.jersey.inject/jersey-hk2/3.1.4, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey +maven/mavencentral/org.glassfish.jersey.media/jersey-media-json-jackson/3.1.4, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey +maven/mavencentral/org.glassfish.jersey.media/jersey-media-multipart/3.1.4, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey maven/mavencentral/org.glassfish/jakarta.json/2.0.1, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jsonp maven/mavencentral/org.hamcrest/hamcrest-core/1.3, BSD-2-Clause, approved, CQ11429 maven/mavencentral/org.hamcrest/hamcrest-core/2.2, BSD-3-Clause, approved, clearlydefined 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 e169ec60e..44c001940 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 @@ -16,7 +16,7 @@ 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.PresentationCreationService; +import org.eclipse.edc.identityhub.spi.generator.VerifiablePresentationService; import org.eclipse.edc.identityhub.spi.resolution.CredentialQueryResolver; import org.eclipse.edc.identityhub.spi.verification.AccessTokenVerifier; import org.eclipse.edc.identityservice.api.v1.PresentationApiController; @@ -58,7 +58,7 @@ public class PresentationApiExtension implements ServiceExtension { private CredentialQueryResolver credentialResolver; @Inject - private PresentationCreationService presentationCreationService; + private VerifiablePresentationService verifiablePresentationService; @Inject private JsonLd jsonLd; @@ -72,7 +72,7 @@ public void initialize(ServiceExtensionContext context) { validatorRegistry.register(PresentationQuery.PRESENTATION_QUERY_TYPE_PROPERTY, new PresentationQueryValidator()); - var controller = new PresentationApiController(validatorRegistry, typeTransformer, credentialResolver, accessTokenVerifier, presentationCreationService, context.getMonitor()); + var controller = new PresentationApiController(validatorRegistry, typeTransformer, credentialResolver, accessTokenVerifier, verifiablePresentationService, context.getMonitor()); var jsonLdMapper = typeManager.getMapper(JSON_LD); webService.registerResource(RESOLUTION_CONTEXT, new ObjectMapperProvider(jsonLdMapper)); 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 e30cabb93..0a5a6d8c1 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,7 +22,7 @@ import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.Response; -import org.eclipse.edc.identityhub.spi.generator.PresentationCreationService; +import org.eclipse.edc.identityhub.spi.generator.VerifiablePresentationService; import org.eclipse.edc.identityhub.spi.resolution.CredentialQueryResolver; import org.eclipse.edc.identityhub.spi.verification.AccessTokenVerifier; import org.eclipse.edc.identitytrust.model.credentialservice.PresentationQuery; @@ -53,16 +53,16 @@ public class PresentationApiController implements PresentationApi { private final TypeTransformerRegistry transformerRegistry; private final CredentialQueryResolver queryResolver; private final AccessTokenVerifier accessTokenVerifier; - private final PresentationCreationService presentationCreationService; + private final VerifiablePresentationService verifiablePresentationService; private final Monitor monitor; public PresentationApiController(JsonObjectValidatorRegistry validatorRegistry, TypeTransformerRegistry transformerRegistry, CredentialQueryResolver queryResolver, - AccessTokenVerifier accessTokenVerifier, PresentationCreationService presentationCreationService, Monitor monitor) { + AccessTokenVerifier accessTokenVerifier, VerifiablePresentationService verifiablePresentationService, Monitor monitor) { this.validatorRegistry = validatorRegistry; this.transformerRegistry = transformerRegistry; this.queryResolver = queryResolver; this.accessTokenVerifier = accessTokenVerifier; - this.presentationCreationService = presentationCreationService; + this.verifiablePresentationService = verifiablePresentationService; this.monitor = monitor; } @@ -91,7 +91,7 @@ public Response queryPresentation(JsonObject query, @HeaderParam(AUTHORIZATION) // package the credentials in a VP and sign var audience = getAudience(token); - var presentationResponse = presentationCreationService.createPresentation(credentials.toList(), presentationQuery.getPresentationDefinition(), audience) + var presentationResponse = verifiablePresentationService.createPresentation(credentials.toList(), presentationQuery.getPresentationDefinition(), audience) .orElseThrow(failure -> new EdcException("Error creating VerifiablePresentation: %s".formatted(failure.getFailureDetail()))); return Response.ok() .entity(presentationResponse) 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 025fdc36f..0734e8ee3 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 @@ -16,7 +16,7 @@ import com.nimbusds.jwt.JWTClaimsSet; import jakarta.json.JsonObject; -import org.eclipse.edc.identityhub.spi.generator.PresentationCreationService; +import org.eclipse.edc.identityhub.spi.generator.VerifiablePresentationService; import org.eclipse.edc.identityhub.spi.resolution.CredentialQueryResolver; import org.eclipse.edc.identityhub.spi.resolution.QueryResult; import org.eclipse.edc.identityhub.spi.verification.AccessTokenVerifier; @@ -71,7 +71,7 @@ class PresentationApiControllerTest extends RestControllerTestBase { private final TypeTransformerRegistry typeTransformerRegistry = mock(); private final CredentialQueryResolver queryResolver = mock(); private final AccessTokenVerifier accessTokenVerifier = mock(); - private final PresentationCreationService generator = mock(); + private final VerifiablePresentationService generator = mock(); @Test diff --git a/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/CoreServicesExtension.java b/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/CoreServicesExtension.java index f8292692f..9cc0d6c66 100644 --- a/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/CoreServicesExtension.java +++ b/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/CoreServicesExtension.java @@ -17,11 +17,11 @@ import org.eclipse.edc.iam.did.spi.key.PublicKeyWrapper; import org.eclipse.edc.iam.did.spi.resolution.DidPublicKeyResolver; import org.eclipse.edc.iam.identitytrust.validation.SelfIssuedIdTokenValidator; -import org.eclipse.edc.identityhub.core.creators.JwtPresentationCreator; -import org.eclipse.edc.identityhub.core.creators.LdpPresentationCreator; +import org.eclipse.edc.identityhub.core.creators.JwtPresentationGenerator; +import org.eclipse.edc.identityhub.core.creators.LdpPresentationGenerator; import org.eclipse.edc.identityhub.spi.ScopeToCriterionTransformer; -import org.eclipse.edc.identityhub.spi.generator.PresentationCreationService; import org.eclipse.edc.identityhub.spi.generator.PresentationCreatorRegistry; +import org.eclipse.edc.identityhub.spi.generator.VerifiablePresentationService; import org.eclipse.edc.identityhub.spi.model.IdentityHubConstants; import org.eclipse.edc.identityhub.spi.resolution.CredentialQueryResolver; import org.eclipse.edc.identityhub.spi.store.CredentialStore; @@ -135,18 +135,18 @@ public CredentialQueryResolver createCredentialQueryResolver() { public PresentationCreatorRegistry presentationCreatorRegistry(ServiceExtensionContext context) { if (presentationCreatorRegistry == null) { presentationCreatorRegistry = new PresentationCreatorRegistryImpl(); - presentationCreatorRegistry.addCreator(new JwtPresentationCreator(privateKeyResolver, clock, getOwnDid(context)), CredentialFormat.JWT); + presentationCreatorRegistry.addCreator(new JwtPresentationGenerator(privateKeyResolver, clock, getOwnDid(context)), CredentialFormat.JWT); var ldpIssuer = LdpIssuer.Builder.newInstance().jsonLd(jsonLd).monitor(context.getMonitor()).build(); - presentationCreatorRegistry.addCreator(new LdpPresentationCreator(privateKeyResolver, getOwnDid(context), signatureSuiteRegistry, defaultSuite, ldpIssuer, typeManager.getMapper(JSON_LD)), + presentationCreatorRegistry.addCreator(new LdpPresentationGenerator(privateKeyResolver, getOwnDid(context), signatureSuiteRegistry, defaultSuite, ldpIssuer, typeManager.getMapper(JSON_LD)), CredentialFormat.JSON_LD); } return presentationCreatorRegistry; } @Provider - public PresentationCreationService presentationGenerator(ServiceExtensionContext context) { - return new PresentationCreationServiceImpl(CredentialFormat.JSON_LD, presentationCreatorRegistry(context), context.getMonitor()); + public VerifiablePresentationService presentationGenerator(ServiceExtensionContext context) { + return new VerifiablePresentationServiceImpl(CredentialFormat.JSON_LD, presentationCreatorRegistry(context), context.getMonitor()); } diff --git a/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/PresentationCreatorRegistryImpl.java b/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/PresentationCreatorRegistryImpl.java index d5398ce4c..83f8bc88d 100644 --- a/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/PresentationCreatorRegistryImpl.java +++ b/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/PresentationCreatorRegistryImpl.java @@ -14,8 +14,8 @@ package org.eclipse.edc.identityhub.core; -import org.eclipse.edc.identityhub.spi.generator.PresentationCreator; import org.eclipse.edc.identityhub.spi.generator.PresentationCreatorRegistry; +import org.eclipse.edc.identityhub.spi.generator.PresentationGenerator; import org.eclipse.edc.identitytrust.model.CredentialFormat; import org.eclipse.edc.identitytrust.model.VerifiableCredentialContainer; import org.eclipse.edc.spi.EdcException; @@ -28,11 +28,11 @@ public class PresentationCreatorRegistryImpl implements PresentationCreatorRegistry { - private final Map> creators = new HashMap<>(); + private final Map> creators = new HashMap<>(); private final Map keyIds = new HashMap<>(); @Override - public void addCreator(PresentationCreator creator, CredentialFormat format) { + public void addCreator(PresentationGenerator creator, CredentialFormat format) { creators.put(format, creator); } @@ -41,7 +41,7 @@ public T createPresentation(List credentials, var creator = ofNullable(creators.get(format)).orElseThrow(() -> new EdcException("No PresentationCreator was found for CredentialFormat %s".formatted(format))); var keyId = ofNullable(keyIds.get(format)).orElseThrow(() -> new EdcException("No key ID was registered for CredentialFormat %s".formatted(format))); - return (T) creator.createPresentation(credentials, keyId, additionalData); + return (T) creator.generatePresentation(credentials, keyId, additionalData); } @Override diff --git a/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/PresentationCreationServiceImpl.java b/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/VerifiablePresentationServiceImpl.java similarity index 93% rename from core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/PresentationCreationServiceImpl.java rename to core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/VerifiablePresentationServiceImpl.java index 43e2849a2..f08a1e97d 100644 --- a/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/PresentationCreationServiceImpl.java +++ b/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/VerifiablePresentationServiceImpl.java @@ -15,8 +15,8 @@ package org.eclipse.edc.identityhub.core; import jakarta.json.JsonObject; -import org.eclipse.edc.identityhub.spi.generator.PresentationCreationService; import org.eclipse.edc.identityhub.spi.generator.PresentationCreatorRegistry; +import org.eclipse.edc.identityhub.spi.generator.VerifiablePresentationService; import org.eclipse.edc.identitytrust.model.CredentialFormat; import org.eclipse.edc.identitytrust.model.VerifiableCredentialContainer; import org.eclipse.edc.identitytrust.model.credentialservice.PresentationResponse; @@ -33,7 +33,7 @@ import static java.util.Optional.ofNullable; import static org.eclipse.edc.identitytrust.model.CredentialFormat.JSON_LD; -public class PresentationCreationServiceImpl implements PresentationCreationService { +public class VerifiablePresentationServiceImpl implements VerifiablePresentationService { private final CredentialFormat defaultFormatVp; private final PresentationCreatorRegistry registry; private final Monitor monitor; @@ -43,7 +43,7 @@ public class PresentationCreationServiceImpl implements PresentationCreationServ * * @param defaultFormatVp The default format for verifiable presentations. */ - public PresentationCreationServiceImpl(CredentialFormat defaultFormatVp, PresentationCreatorRegistry registry, Monitor monitor) { + public VerifiablePresentationServiceImpl(CredentialFormat defaultFormatVp, PresentationCreatorRegistry registry, Monitor monitor) { this.defaultFormatVp = defaultFormatVp; this.registry = registry; this.monitor = monitor; diff --git a/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/creators/JwtPresentationCreator.java b/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/creators/JwtPresentationGenerator.java similarity index 90% rename from core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/creators/JwtPresentationCreator.java rename to core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/creators/JwtPresentationGenerator.java index cb1d71a08..93284b66f 100644 --- a/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/creators/JwtPresentationCreator.java +++ b/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/creators/JwtPresentationGenerator.java @@ -21,7 +21,7 @@ import jakarta.json.Json; import jakarta.json.JsonArrayBuilder; import org.eclipse.edc.iam.did.spi.key.PrivateKeyWrapper; -import org.eclipse.edc.identityhub.spi.generator.PresentationCreator; +import org.eclipse.edc.identityhub.spi.generator.PresentationGenerator; import org.eclipse.edc.identitytrust.model.VerifiableCredentialContainer; import org.eclipse.edc.jsonld.spi.JsonLdKeywords; import org.eclipse.edc.spi.EdcException; @@ -46,7 +46,7 @@ * JwtPresentationCreator is an implementation of the PresentationCreator interface that generates Verifiable Presentations in JWT format. * VPs are returned as {@link String} */ -public class JwtPresentationCreator implements PresentationCreator { +public class JwtPresentationGenerator implements PresentationGenerator { private final PrivateKeyResolver privateKeyResolver; private final Clock clock; private final String issuerId; @@ -58,7 +58,7 @@ public class JwtPresentationCreator implements PresentationCreator { * @param clock The clock used for generating timestamps. * @param issuerId The ID of the issuer for the presentation. Could be a DID. */ - public JwtPresentationCreator(PrivateKeyResolver privateKeyResolver, Clock clock, String issuerId) { + public JwtPresentationGenerator(PrivateKeyResolver privateKeyResolver, Clock clock, String issuerId) { this.privateKeyResolver = privateKeyResolver; this.clock = clock; this.issuerId = issuerId; @@ -66,10 +66,10 @@ public JwtPresentationCreator(PrivateKeyResolver privateKeyResolver, Clock clock /** * Will always throw an {@link UnsupportedOperationException}. - * Please use {@link JwtPresentationCreator#createPresentation(List, String, Map)} instead. + * Please use {@link JwtPresentationGenerator#generatePresentation(List, String, Map)} instead. */ @Override - public String createPresentation(List credentials, String keyId) { + public String generatePresentation(List credentials, String keyId) { throw new UnsupportedOperationException("Must provide additional data: 'aud'"); } @@ -85,7 +85,7 @@ public String createPresentation(List credentials * @throws EdcException If signing the JWT fails. */ @Override - public String createPresentation(List credentials, String keyId, Map additionalData) { + public String generatePresentation(List credentials, String keyId, Map additionalData) { // check if expected data is there if (!additionalData.containsKey("aud")) { diff --git a/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/creators/LdpPresentationCreator.java b/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/creators/LdpPresentationGenerator.java similarity index 91% rename from core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/creators/LdpPresentationCreator.java rename to core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/creators/LdpPresentationGenerator.java index 88e4fd361..59861901d 100644 --- a/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/creators/LdpPresentationCreator.java +++ b/core/identity-hub-credentials/src/main/java/org/eclipse/edc/identityhub/core/creators/LdpPresentationGenerator.java @@ -25,7 +25,7 @@ import jakarta.json.JsonArrayBuilder; import jakarta.json.JsonObject; import org.eclipse.edc.iam.did.spi.key.PrivateKeyWrapper; -import org.eclipse.edc.identityhub.spi.generator.PresentationCreator; +import org.eclipse.edc.identityhub.spi.generator.PresentationGenerator; import org.eclipse.edc.identitytrust.model.CredentialFormat; import org.eclipse.edc.identitytrust.model.VerifiableCredentialContainer; import org.eclipse.edc.identitytrust.verification.SignatureSuiteRegistry; @@ -52,7 +52,7 @@ * LdpPresentationCreator is a class that implements the PresentationCreator interface to generate Verifiable Presentations based on Verifiable Credential Containers. * VPs are represented as {@link JsonObject}. */ -public class LdpPresentationCreator implements PresentationCreator { +public class LdpPresentationGenerator implements PresentationGenerator { public static final String ID_PROPERTY = "id"; public static final String TYPE_PROPERTY = "type"; @@ -65,8 +65,8 @@ public class LdpPresentationCreator implements PresentationCreator { private final LdpIssuer ldpIssuer; private final ObjectMapper mapper; - public LdpPresentationCreator(PrivateKeyResolver privateKeyResolver, String ownDid, - SignatureSuiteRegistry signatureSuiteRegistry, String defaultSignatureSuite, LdpIssuer ldpIssuer, ObjectMapper mapper) { + public LdpPresentationGenerator(PrivateKeyResolver privateKeyResolver, String ownDid, + SignatureSuiteRegistry signatureSuiteRegistry, String defaultSignatureSuite, LdpIssuer ldpIssuer, ObjectMapper mapper) { this.privateKeyResolver = privateKeyResolver; this.issuerId = ownDid; this.signatureSuiteRegistry = signatureSuiteRegistry; @@ -77,10 +77,10 @@ public LdpPresentationCreator(PrivateKeyResolver privateKeyResolver, String ownD /** * Will always throw an {@link UnsupportedOperationException}. - * Please use {@link LdpPresentationCreator#createPresentation(List, String, Map)} instead. + * Please use {@link LdpPresentationGenerator#generatePresentation(List, String, Map)} instead. */ @Override - public JsonObject createPresentation(List credentials, String keyId) { + public JsonObject generatePresentation(List credentials, String keyId) { throw new UnsupportedOperationException("Must provide additional data: 'types'"); } @@ -101,7 +101,7 @@ public JsonObject createPresentation(List credent * or if one or more VerifiableCredentials cannot be represented in the JSON-LD format. */ @Override - public JsonObject createPresentation(List credentials, String keyId, Map additionalData) { + public JsonObject generatePresentation(List credentials, String keyId, Map additionalData) { if (!additionalData.containsKey("types")) { throw new IllegalArgumentException("Must provide additional data: 'types'"); } diff --git a/core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/PresentationCreationServiceImplTest.java b/core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/VerifiablePresentationServiceImplTest.java similarity index 90% rename from core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/PresentationCreationServiceImplTest.java rename to core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/VerifiablePresentationServiceImplTest.java index 6082e8ad1..1220bca05 100644 --- a/core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/PresentationCreationServiceImplTest.java +++ b/core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/VerifiablePresentationServiceImplTest.java @@ -48,18 +48,18 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -class PresentationCreationServiceImplTest { +class VerifiablePresentationServiceImplTest { private final Monitor monitor = mock(); private final PresentationCreatorRegistry registry = mock(); private final ObjectMapper mapper = JacksonJsonLd.createObjectMapper(); - private PresentationCreationServiceImpl presentationGenerator; + private VerifiablePresentationServiceImpl presentationGenerator; @Test void generate_noCredentials() { when(registry.createPresentation(anyList(), eq(JSON_LD), any())).thenReturn(jsonObject(EMPTY_LDP_VP)); - presentationGenerator = new PresentationCreationServiceImpl(JSON_LD, registry, monitor); + presentationGenerator = new VerifiablePresentationServiceImpl(JSON_LD, registry, monitor); List ldpVcs = List.of(); var result = presentationGenerator.createPresentation(ldpVcs, null, null); @@ -69,7 +69,7 @@ void generate_noCredentials() { @Test void generate_defaultFormatLdp_containsOnlyLdpVc() { when(registry.createPresentation(any(), eq(JSON_LD), any())).thenReturn(jsonObject(LDP_VP_WITH_PROOF)); - presentationGenerator = new PresentationCreationServiceImpl(JSON_LD, registry, monitor); + presentationGenerator = new VerifiablePresentationServiceImpl(JSON_LD, registry, monitor); var credentials = List.of(createCredential(JSON_LD), createCredential(JSON_LD)); var result = presentationGenerator.createPresentation(credentials, null, null); @@ -82,7 +82,7 @@ void generate_defaultFormatLdp_containsOnlyLdpVc() { void generate_defaultFormatLdp_mixedVcs() { when(registry.createPresentation(any(), eq(JSON_LD), any())).thenReturn(jsonObject(LDP_VP_WITH_PROOF)); when(registry.createPresentation(any(), eq(JWT), any())).thenReturn(JWT_VP); - presentationGenerator = new PresentationCreationServiceImpl(JSON_LD, registry, monitor); + presentationGenerator = new VerifiablePresentationServiceImpl(JSON_LD, registry, monitor); var credentials = List.of(createCredential(JSON_LD), createCredential(JWT)); @@ -97,7 +97,7 @@ void generate_defaultFormatLdp_mixedVcs() { void generate_defaultFormatLdp_onlyJwtVcs() { when(registry.createPresentation(any(), eq(JWT), any())).thenReturn(JWT_VP); when(registry.createPresentation(any(), eq(JSON_LD), any())).thenReturn(jsonObject(EMPTY_LDP_VP)); - presentationGenerator = new PresentationCreationServiceImpl(JSON_LD, registry, monitor); + presentationGenerator = new VerifiablePresentationServiceImpl(JSON_LD, registry, monitor); var credentials = List.of(createCredential(JWT), createCredential(JWT)); @@ -112,7 +112,7 @@ void generate_defaultFormatLdp_onlyJwtVcs() { void generate_defaultFormatJwt_onlyJwtVcs() { when(registry.createPresentation(any(), eq(JWT), any())).thenReturn(JWT_VP); when(registry.createPresentation(any(), eq(JSON_LD), any())).thenReturn(jsonObject(EMPTY_LDP_VP)); - presentationGenerator = new PresentationCreationServiceImpl(JWT, registry, monitor); + presentationGenerator = new VerifiablePresentationServiceImpl(JWT, registry, monitor); var credentials = List.of(createCredential(JWT), createCredential(JWT)); @@ -126,7 +126,7 @@ void generate_defaultFormatJwt_onlyJwtVcs() { void generate_defaultFormatJwt_mixedVcs() { when(registry.createPresentation(any(), eq(JSON_LD), any())).thenReturn(jsonObject(LDP_VP_WITH_PROOF)); when(registry.createPresentation(any(), eq(JWT), any())).thenReturn(JWT_VP); - presentationGenerator = new PresentationCreationServiceImpl(JWT, registry, monitor); + presentationGenerator = new VerifiablePresentationServiceImpl(JWT, registry, monitor); var credentials = List.of(createCredential(JSON_LD), createCredential(JWT)); @@ -139,7 +139,7 @@ void generate_defaultFormatJwt_mixedVcs() { @Test void generate_defaultFormatJwt_onlyLdpVc() { when(registry.createPresentation(any(), eq(JWT), any())).thenReturn(JWT_VP); - presentationGenerator = new PresentationCreationServiceImpl(JWT, registry, monitor); + presentationGenerator = new VerifiablePresentationServiceImpl(JWT, registry, monitor); var credentials = List.of(createCredential(JSON_LD), createCredential(JSON_LD)); var result = presentationGenerator.createPresentation(credentials, null, null); @@ -151,7 +151,7 @@ void generate_defaultFormatJwt_onlyLdpVc() { @Test void generate_withPresentationDef_shouldLogWarning() { - presentationGenerator = new PresentationCreationServiceImpl(JSON_LD, registry, monitor); + presentationGenerator = new VerifiablePresentationServiceImpl(JSON_LD, registry, monitor); presentationGenerator.createPresentation(List.of(), PresentationDefinition.Builder.newInstance().id("test-id").build(), null); verify(monitor).warning(contains("A PresentationDefinition was submitted, but is currently ignored by the generator.")); diff --git a/core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/JwtPresentationCreatorTest.java b/core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/JwtPresentationGeneratorTest.java similarity index 87% rename from core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/JwtPresentationCreatorTest.java rename to core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/JwtPresentationGeneratorTest.java index 0ab74a8ec..9ae37d8b4 100644 --- a/core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/JwtPresentationCreatorTest.java +++ b/core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/JwtPresentationGeneratorTest.java @@ -41,17 +41,17 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -class JwtPresentationCreatorTest extends PresentationCreatorTest { +class JwtPresentationGeneratorTest extends PresentationGeneratorTest { public static final List REQUIRED_CLAIMS = asList("aud", "exp", "iat", "vp"); private final Map audClaim = Map.of("aud", "did:web:test-audience"); private final PrivateKeyResolver resolverMock = mock(); - private JwtPresentationCreator creator; + private JwtPresentationGenerator creator; @BeforeEach void setup() { var vpSigningKey = createKey(Curve.P_384, "vp-key"); when(resolverMock.resolvePrivateKey(eq(KEY_ID), any())).thenReturn(new EcPrivateKeyWrapper(vpSigningKey)); - creator = new JwtPresentationCreator(resolverMock, Clock.systemUTC(), "did:web:test-issuer"); + creator = new JwtPresentationGenerator(resolverMock, Clock.systemUTC(), "did:web:test-issuer"); } @Test @@ -61,7 +61,7 @@ void createPresentation_success() { var jwtVc = JwtCreationUtils.createJwt(vcSigningKey, TestConstants.CENTRAL_ISSUER_DID, "degreeSub", TestConstants.VP_HOLDER_ID, Map.of("vc", TestConstants.VC_CONTENT_DEGREE_EXAMPLE)); var vcc = new VerifiableCredentialContainer(jwtVc, CredentialFormat.JWT, createDummyCredential()); - var vpJwt = creator.createPresentation(List.of(vcc), KEY_ID, audClaim); + var vpJwt = creator.generatePresentation(List.of(vcc), KEY_ID, audClaim); assertThat(vpJwt).isNotNull(); assertThatNoException().isThrownBy(() -> SignedJWT.parse(vpJwt)); var claims = parseJwt(vpJwt); @@ -81,7 +81,7 @@ void create_whenVcsNotSameFormat() { var vc1 = new VerifiableCredentialContainer(jwtVc, CredentialFormat.JWT, createDummyCredential()); var vc2 = new VerifiableCredentialContainer(ldpVc, CredentialFormat.JSON_LD, createDummyCredential()); - var vpJwt = creator.createPresentation(List.of(vc1, vc2), KEY_ID, audClaim); + var vpJwt = creator.generatePresentation(List.of(vc1, vc2), KEY_ID, audClaim); assertThat(vpJwt).isNotNull(); assertThatNoException().isThrownBy(() -> SignedJWT.parse(vpJwt)); @@ -94,7 +94,7 @@ void create_whenVcsNotSameFormat() { @Test @DisplayName("Should create a valid VP with no credential") void create_whenVcsEmpty_shouldReturnEmptyVp() { - var vpJwt = creator.createPresentation(List.of(), KEY_ID, audClaim); + var vpJwt = creator.generatePresentation(List.of(), KEY_ID, audClaim); assertThat(vpJwt).isNotNull(); assertThatNoException().isThrownBy(() -> SignedJWT.parse(vpJwt)); @@ -109,7 +109,7 @@ void create_whenVcsEmpty_shouldReturnEmptyVp() { @DisplayName("Should throw an exception if no key is found for a key-id") void create_whenKeyNotFound() { var vcc = new VerifiableCredentialContainer("foobar", CredentialFormat.JWT, createDummyCredential()); - assertThatThrownBy(() -> creator.createPresentation(List.of(vcc), "not-exist", audClaim)).isInstanceOf(IllegalArgumentException.class); + assertThatThrownBy(() -> creator.generatePresentation(List.of(vcc), "not-exist", audClaim)).isInstanceOf(IllegalArgumentException.class); } @Test @@ -117,10 +117,10 @@ void create_whenKeyNotFound() { @Override void create_whenRequiredAdditionalDataMissing_throwsIllegalArgumentException() { var vcc = new VerifiableCredentialContainer("foobar", CredentialFormat.JWT, createDummyCredential()); - assertThatThrownBy(() -> creator.createPresentation(List.of(vcc), KEY_ID)) + assertThatThrownBy(() -> creator.generatePresentation(List.of(vcc), KEY_ID)) .describedAs("Expected exception when no additional data provided") .isInstanceOf(UnsupportedOperationException.class); - assertThatThrownBy(() -> creator.createPresentation(List.of(vcc), KEY_ID, Map.of())) + assertThatThrownBy(() -> creator.generatePresentation(List.of(vcc), KEY_ID, Map.of())) .describedAs("Expected exception when additional data does not contain expected value ('aud')") .isInstanceOf(IllegalArgumentException.class); } @@ -129,7 +129,7 @@ void create_whenRequiredAdditionalDataMissing_throwsIllegalArgumentException() { @DisplayName("Should return an empty JWT when no credentials are passed") void create_whenEmptyList() { - var vpJwt = creator.createPresentation(List.of(), KEY_ID, audClaim); + var vpJwt = creator.generatePresentation(List.of(), KEY_ID, audClaim); assertThat(vpJwt).isNotNull(); assertThatNoException().isThrownBy(() -> SignedJWT.parse(vpJwt)); var claims = parseJwt(vpJwt); diff --git a/core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/LdpPresentationCreatorTest.java b/core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/LdpPresentationGeneratorTest.java similarity index 88% rename from core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/LdpPresentationCreatorTest.java rename to core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/LdpPresentationGeneratorTest.java index 2d1266a05..5d1b005a1 100644 --- a/core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/LdpPresentationCreatorTest.java +++ b/core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/LdpPresentationGeneratorTest.java @@ -56,11 +56,11 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -class LdpPresentationCreatorTest extends PresentationCreatorTest { +class LdpPresentationGeneratorTest extends PresentationGeneratorTest { private final PrivateKeyResolver resolverMock = mock(); private final Map types = Map.of("types", List.of("VerifiablePresentation", "SomeOtherPresentationType")); - private LdpPresentationCreator creator; + private LdpPresentationGenerator creator; @BeforeEach void setup() throws URISyntaxException { @@ -72,7 +72,7 @@ void setup() throws URISyntaxException { .jsonLd(initializeJsonLd()) .monitor(mock()) .build(); - creator = new LdpPresentationCreator(resolverMock, "did:web:test-issuer", signatureSuiteRegistryMock, IdentityHubConstants.JWS_2020_SIGNATURE_SUITE, ldpIssuer, + creator = new LdpPresentationGenerator(resolverMock, "did:web:test-issuer", signatureSuiteRegistryMock, IdentityHubConstants.JWS_2020_SIGNATURE_SUITE, ldpIssuer, JacksonJsonLd.createObjectMapper()); } @@ -82,7 +82,7 @@ public void createPresentation_success() { var ldpVc = TestData.LDP_VC_WITH_PROOF; var vcc = new VerifiableCredentialContainer(ldpVc, CredentialFormat.JSON_LD, createDummyCredential()); - var result = creator.createPresentation(List.of(vcc), KEY_ID, types); + var result = creator.generatePresentation(List.of(vcc), KEY_ID, types); assertThat(result).isNotNull(); assertThat(result.get("https://w3id.org/security#proof")).isNotNull(); } @@ -97,7 +97,7 @@ public void create_whenVcsNotSameFormat() { var jwtVc = JwtCreationUtils.createJwt(vcSigningKey, TestConstants.CENTRAL_ISSUER_DID, "degreeSub", TestConstants.VP_HOLDER_ID, Map.of("vc", TestConstants.VC_CONTENT_DEGREE_EXAMPLE)); var vcc2 = new VerifiableCredentialContainer(jwtVc, CredentialFormat.JWT, createDummyCredential()); - assertThatThrownBy(() -> creator.createPresentation(List.of(vcc, vcc2), KEY_ID, types)) + assertThatThrownBy(() -> creator.generatePresentation(List.of(vcc, vcc2), KEY_ID, types)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("One or more VerifiableCredentials cannot be represented in the desired format %s".formatted(CredentialFormat.JSON_LD)); } @@ -105,7 +105,7 @@ public void create_whenVcsNotSameFormat() { @Override @Test public void create_whenVcsEmpty_shouldReturnEmptyVp() { - var result = creator.createPresentation(List.of(), KEY_ID, types); + var result = creator.generatePresentation(List.of(), KEY_ID, types); assertThat(result).isNotNull(); } @@ -114,7 +114,7 @@ public void create_whenVcsEmpty_shouldReturnEmptyVp() { public void create_whenKeyNotFound() { var ldpVc = TestData.LDP_VC_WITH_PROOF; var vcc = new VerifiableCredentialContainer(ldpVc, CredentialFormat.JSON_LD, createDummyCredential()); - assertThatThrownBy(() -> creator.createPresentation(List.of(vcc), "not-exists", types)) + assertThatThrownBy(() -> creator.generatePresentation(List.of(vcc), "not-exists", types)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("No key could be found with key ID 'not-exists'"); } @@ -124,10 +124,10 @@ public void create_whenKeyNotFound() { public void create_whenRequiredAdditionalDataMissing_throwsIllegalArgumentException() { var ldpVc = TestData.LDP_VC_WITH_PROOF; var vcc = new VerifiableCredentialContainer(ldpVc, CredentialFormat.JSON_LD, createDummyCredential()); - assertThatThrownBy(() -> creator.createPresentation(List.of(vcc), KEY_ID)).isInstanceOf(UnsupportedOperationException.class) + assertThatThrownBy(() -> creator.generatePresentation(List.of(vcc), KEY_ID)).isInstanceOf(UnsupportedOperationException.class) .hasMessage("Must provide additional data: 'types'"); - assertThatThrownBy(() -> creator.createPresentation(List.of(vcc), KEY_ID, Map.of("some-key", "some-value"))) + assertThatThrownBy(() -> creator.generatePresentation(List.of(vcc), KEY_ID, Map.of("some-key", "some-value"))) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Must provide additional data: 'types'"); } @@ -137,7 +137,7 @@ public void create_whenRequiredAdditionalDataMissing_throwsIllegalArgumentExcept @Override void create_whenEmptyList() { - var result = creator.createPresentation(List.of(), KEY_ID, types); + var result = creator.generatePresentation(List.of(), KEY_ID, types); assertThat(result).isNotNull(); assertThat(result.get("https://w3id.org/security#proof")).isNotNull(); } diff --git a/core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/PresentationCreatorTest.java b/core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/PresentationGeneratorTest.java similarity index 98% rename from core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/PresentationCreatorTest.java rename to core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/PresentationGeneratorTest.java index ad59470fd..dbf114ca7 100644 --- a/core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/PresentationCreatorTest.java +++ b/core/identity-hub-credentials/src/test/java/org/eclipse/edc/identityhub/core/creators/PresentationGeneratorTest.java @@ -27,7 +27,7 @@ import java.time.Instant; import java.util.Map; -abstract class PresentationCreatorTest { +abstract class PresentationGeneratorTest { public static final String KEY_ID = "https://test.com/test-keys#key-1"; diff --git a/docs/developer/architecture/identity-trust-protocol/identity-and-trust-modules.md b/docs/developer/architecture/identity-trust-protocol/identity-and-trust-modules.md index 192defa1b..f25b8fb11 100644 --- a/docs/developer/architecture/identity-trust-protocol/identity-and-trust-modules.md +++ b/docs/developer/architecture/identity-trust-protocol/identity-and-trust-modules.md @@ -4,15 +4,16 @@ ## VC Module -Contains the `PresentationCreationService` and a `CredentialManager`.
+Contains the `VerifiablePresentationService` and a `CredentialManager`.
Its job is to - - generate and serve VPs (through the [Hub API](#hub-api)) - - CRUD VCs, for example when the Issuer wants to write a VC via the [Hub API](#management-api) or - the [Management API](#management-api) - - run the `VerifiableCredentialManager` - - exchanges protocol messages with the Issuer, e.g. in response to a credential-offer - -`VerifiableCredentialManager`: it can be configured whether credentials are auto-renewed (default is `true`). Once a renewal +- generate and serve VPs (through the [Hub API](#hub-api)) +- CRUD VCs, for example when the Issuer wants to write a VC via the [Hub API](#management-api) or +the [Management API](#management-api) +- run the `VerifiableCredentialManager` +- exchanges protocol messages with the Issuer, e.g. in response to a credential-offer + +`VerifiableCredentialManager`: it can be configured whether credentials are auto-renewed (default is `true`). Once a +renewal is triggered , it moves into the `REISSUE_REQUESTING` state. Generally, renewals can be triggered by three events: 1. an incoming credential offer diff --git a/docs/developer/architecture/identity-trust-protocol/identity.hub.architecture.md b/docs/developer/architecture/identity-trust-protocol/identity.hub.architecture.md index 4d9aa0c96..8313305c6 100644 --- a/docs/developer/architecture/identity-trust-protocol/identity.hub.architecture.md +++ b/docs/developer/architecture/identity-trust-protocol/identity.hub.architecture.md @@ -35,7 +35,8 @@ Two deployment topologies will be supported: A participant context (PC) functions as a unit of management and control for `identity resources` in the Identity Hub. All resources are contained and accessed through a PC. Contexts are tied to the participant identity as defined in -the [DSP specifications](https://github.com/International-Data-Spaces-Association/ids-specification) and created through the [IH Management API](#311-elevated-privilege-operations). +the [DSP specifications](https://github.com/International-Data-Spaces-Association/ids-specification) and created through +the [IH Management API](#311-elevated-privilege-operations). Access control for public client API endpoints is scoped to a specific PC. For example, an access token as defined in the [Base Identity Protocol specification]() is associated with a specific context and may not be used to access @@ -56,7 +57,7 @@ participant. A `Verifiable Credential` (VC), `DID`, and `DID Document` are ident A `VerifiableCredentialResource` (VCR) is a type of `identity resource` and will be stored on the holder side: ```java -class VerifiableCredentialResource implements IdentityResource { +class VerifiableCredentialResource implements IdentityResource { String id; long timestamp; VcState state; @@ -68,7 +69,6 @@ class VerifiableCredentialResource implements IdentityResource { } ``` - The `issuerId` is a `URN`, typically a DID, that can be resolved to return the service endpoint of the Credential Issuer. @@ -79,6 +79,7 @@ The `state` and `timestamp` fields are used to determine when the resource enter the resource was requested. On the issuer the record for an already issued VC would look like this: + ```java class VerifiableCredentialRecord { VcState state; // @@ -389,9 +390,10 @@ persistence. All CRUD operations publish events. -### 3.5.2. VerifiablePresentationGenerator +### 3.5.2. VerifiablePresentationService -The `VerifiablePresentationGenerator` is responsible for generating Verifiable Presentations (VP) from a (VC). +The `VerifiablePresentationService` is responsible for delegating to generators, that generate Verifiable +Presentations (VP) from a (VC). ### 3.5.3. CredentialRequestManager 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 852af3f31..4d062241f 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 @@ -15,7 +15,7 @@ package org.eclipse.edc.identityhub.tests; import com.nimbusds.jose.jwk.ECKey; -import org.eclipse.edc.identityhub.spi.generator.PresentationCreationService; +import org.eclipse.edc.identityhub.spi.generator.VerifiablePresentationService; import org.eclipse.edc.identityhub.spi.resolution.CredentialQueryResolver; import org.eclipse.edc.identityhub.spi.resolution.QueryResult; import org.eclipse.edc.identityhub.spi.verification.AccessTokenVerifier; @@ -66,7 +66,7 @@ public class ResolutionApiComponentTest { .build(); // todo: these mocks should be replaced, once their respective implementations exist! private static final CredentialQueryResolver CREDENTIAL_QUERY_RESOLVER = mock(); - private static final PresentationCreationService PRESENTATION_GENERATOR = mock(); + private static final VerifiablePresentationService PRESENTATION_GENERATOR = mock(); private static final AccessTokenVerifier ACCESS_TOKEN_VERIFIER = mock(); @RegisterExtension @@ -75,7 +75,7 @@ public class ResolutionApiComponentTest { static { runtime = new EdcRuntimeExtension(":launcher", "identity-hub", IDENTITY_HUB_PARTICIPANT.controlPlaneConfiguration()); runtime.registerServiceMock(CredentialQueryResolver.class, CREDENTIAL_QUERY_RESOLVER); - runtime.registerServiceMock(PresentationCreationService.class, PRESENTATION_GENERATOR); + runtime.registerServiceMock(VerifiablePresentationService.class, PRESENTATION_GENERATOR); runtime.registerServiceMock(AccessTokenVerifier.class, ACCESS_TOKEN_VERIFIER); } diff --git a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/PresentationCreatorRegistry.java b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/PresentationCreatorRegistry.java index 55cf20a37..7879fcfb9 100644 --- a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/PresentationCreatorRegistry.java +++ b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/PresentationCreatorRegistry.java @@ -21,15 +21,15 @@ import java.util.Map; /** - * Registry that contains multiple {@link PresentationCreator} objects and assigns them a {@link CredentialFormat}. + * Registry that contains multiple {@link PresentationGenerator} objects and assigns them a {@link CredentialFormat}. * With this, it is possible to generate VerifiablePresentations in different formats. */ public interface PresentationCreatorRegistry { /** - * Registers a {@link PresentationCreator} for a particular {@link CredentialFormat} + * Registers a {@link PresentationGenerator} for a particular {@link CredentialFormat} */ - void addCreator(PresentationCreator creator, CredentialFormat format); + void addCreator(PresentationGenerator creator, CredentialFormat format); /** * Creates a VerifiablePresentation based on a list of verifiable credentials and a credential format. How the presentation will be represented diff --git a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/PresentationCreator.java b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/PresentationGenerator.java similarity index 91% rename from spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/PresentationCreator.java rename to spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/PresentationGenerator.java index 9f504731e..3654445e0 100644 --- a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/PresentationCreator.java +++ b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/PresentationGenerator.java @@ -25,7 +25,7 @@ * @param the type of the presentation */ @FunctionalInterface -public interface PresentationCreator { +public interface PresentationGenerator { /** * Generates a Verifiable Presentation based on a list of Verifiable Credential Containers and a key ID. Implementors must * use the key ID to resolve the private key used for signing. Recipients of the VP must use the key ID to resolve the public @@ -42,7 +42,7 @@ public interface PresentationCreator { * @throws IllegalArgumentException If not all VCs can be represented in one VP. * @throws UnsupportedOperationException If additional data is required by the implementation, or if specified key is not suitable for signing. */ - T createPresentation(List credentials, String keyId); + T generatePresentation(List credentials, String keyId); /** * Generates a Verifiable Presentation based on a list of Verifiable Credential Containers and a key ID. Implementors must @@ -59,7 +59,7 @@ public interface PresentationCreator { * @return The generated Verifiable Presentation. The concrete return type depends on the implementation. * @throws IllegalArgumentException If not all VCs can be represented in one VP, mandatory additional information was not given, or the specified key is not suitable for signing. */ - default T createPresentation(List credentials, String keyId, Map additionalData) { - return createPresentation(credentials, keyId); + default T generatePresentation(List credentials, String keyId, Map additionalData) { + return generatePresentation(credentials, keyId); } } diff --git a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/PresentationCreationService.java b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/VerifiablePresentationService.java similarity index 97% rename from spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/PresentationCreationService.java rename to spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/VerifiablePresentationService.java index 62d8e0af1..fa804ae08 100644 --- a/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/PresentationCreationService.java +++ b/spi/identity-hub-spi/src/main/java/org/eclipse/edc/identityhub/spi/generator/VerifiablePresentationService.java @@ -27,7 +27,7 @@ * and an optional presentation definition. */ @FunctionalInterface -public interface PresentationCreationService { +public interface VerifiablePresentationService { /** * Creates a presentation based on a list of verifiable credentials and an optional presentation definition. *