Skip to content

Commit

Permalink
refactor: further cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed Jan 31, 2025
1 parent 91a2423 commit 01b502d
Show file tree
Hide file tree
Showing 23 changed files with 80 additions and 718 deletions.
11 changes: 11 additions & 0 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ maven/mavencentral/io.rest-assured/xml-path/5.5.0, Apache-2.0, approved, clearly
maven/mavencentral/io.setl/rdf-urdna/1.1, Apache-2.0, approved, clearlydefined
maven/mavencentral/io.swagger.core.v3/swagger-annotations-jakarta/2.2.15, Apache-2.0, approved, #5947
maven/mavencentral/io.swagger.core.v3/swagger-annotations-jakarta/2.2.22, Apache-2.0, approved, #5947
maven/mavencentral/io.swagger.core.v3/swagger-annotations-jakarta/2.2.27, Apache-2.0, approved, #5947
maven/mavencentral/io.swagger.core.v3/swagger-annotations/2.2.15, Apache-2.0, approved, #11362
maven/mavencentral/io.swagger.core.v3/swagger-core-jakarta/2.2.15, Apache-2.0, approved, #5929
maven/mavencentral/io.swagger.core.v3/swagger-core-jakarta/2.2.22, Apache-2.0, approved, #5929
Expand Down Expand Up @@ -160,13 +161,15 @@ maven/mavencentral/org.codehaus.plexus/plexus-component-annotations/2.1.0, Apach
maven/mavencentral/org.codehaus.plexus/plexus-container-default/2.1.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/org.codehaus.plexus/plexus-utils/3.1.1, , approved, CQ16492
maven/mavencentral/org.codehaus.plexus/plexus-utils/3.3.0, , approved, CQ21066
maven/mavencentral/org.eclipse.edc/api-core/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/api-observability/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/auth-spi/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/auth-tokenbased/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/autodoc-processor/0.5.1, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/boot-lib/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/boot-spi/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/boot/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/connector-core/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/core-spi/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/crypto-common-lib/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/data-plane-selector-spi/0.11.0, Apache-2.0, approved, technology.edc
Expand All @@ -176,9 +179,11 @@ maven/mavencentral/org.eclipse.edc/http-spi/0.11.0, Apache-2.0, approved, techno
maven/mavencentral/org.eclipse.edc/identity-did-core/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/identity-did-spi/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/identity-did-web/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/identity-trust-core/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/identity-trust-issuers-configuration/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/identity-trust-service/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/identity-trust-spi/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/identity-trust-sts-embedded/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/identity-trust-transform/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/jersey-core/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/jersey-providers-lib/0.11.0, Apache-2.0, approved, technology.edc
Expand All @@ -189,14 +194,19 @@ maven/mavencentral/org.eclipse.edc/json-ld/0.11.0, Apache-2.0, approved, technol
maven/mavencentral/org.eclipse.edc/json-lib/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/junit-base/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/junit/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/jws2020-lib/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/jwt-signer-spi/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/jwt-spi/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/jwt-verifiable-credentials/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/keys-lib/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/keys-spi/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/ldp-verifiable-credentials/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/participant-spi/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/policy-engine-lib/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/policy-engine-spi/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/policy-evaluator-lib/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/policy-model/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/query-lib/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/request-policy-context-spi/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/runtime-metamodel/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/runtime-metamodel/0.5.1, Apache-2.0, approved, technology.edc
Expand All @@ -205,6 +215,7 @@ maven/mavencentral/org.eclipse.edc/sql-lease/0.11.0, Apache-2.0, approved, techn
maven/mavencentral/org.eclipse.edc/sql-lib/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/sql-pool-apache-commons/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/sql-test-fixtures/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/state-machine-lib/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/token-core/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/token-lib/0.11.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/token-spi/0.11.0, Apache-2.0, approved, technology.edc
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,17 @@
package org.eclipse.tractusx.bdrs.api.directory.authentication;

import org.eclipse.edc.api.auth.spi.AuthenticationRequestFilter;
import org.eclipse.edc.api.auth.spi.registry.ApiAuthenticationProviderRegistry;
import org.eclipse.edc.api.auth.spi.registry.ApiAuthenticationRegistry;
import org.eclipse.edc.iam.did.spi.resolution.DidPublicKeyResolver;
import org.eclipse.edc.iam.identitytrust.service.verification.MultiFormatPresentationVerifier;
import org.eclipse.edc.iam.identitytrust.transform.to.JwtToVerifiableCredentialTransformer;
import org.eclipse.edc.iam.identitytrust.transform.to.JwtToVerifiablePresentationTransformer;
import org.eclipse.edc.iam.identitytrust.spi.SecureTokenService;
import org.eclipse.edc.iam.verifiablecredentials.VerifiableCredentialValidationServiceImpl;
import org.eclipse.edc.iam.verifiablecredentials.revocation.bitstring.BitstringStatusListRevocationService;
import org.eclipse.edc.iam.verifiablecredentials.revocation.statuslist2021.StatusList2021RevocationService;
import org.eclipse.edc.iam.verifiablecredentials.spi.model.RevocationServiceRegistry;
import org.eclipse.edc.iam.verifiablecredentials.spi.model.revocation.bitstringstatuslist.BitstringStatusListStatus;
import org.eclipse.edc.iam.verifiablecredentials.spi.model.revocation.statuslist2021.StatusList2021Status;
import org.eclipse.edc.iam.verifiablecredentials.spi.validation.TrustedIssuerRegistry;
import org.eclipse.edc.jsonld.JsonLdConfiguration;
import org.eclipse.edc.jsonld.TitaniumJsonLd;
import org.eclipse.edc.runtime.metamodel.annotation.Extension;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.runtime.metamodel.annotation.Provider;
Expand All @@ -45,7 +41,6 @@
import org.eclipse.edc.spi.types.TypeManager;
import org.eclipse.edc.token.spi.TokenValidationRulesRegistry;
import org.eclipse.edc.token.spi.TokenValidationService;
import org.eclipse.edc.transform.TypeTransformerRegistryImpl;
import org.eclipse.edc.transform.spi.TypeTransformerRegistry;
import org.eclipse.edc.verifiablecredentials.jwt.JwtPresentationVerifier;
import org.eclipse.edc.web.spi.WebService;
Expand All @@ -60,12 +55,15 @@
*/
@Extension(NAME)
public class CredentialBasedAuthenticationExtension implements ServiceExtension {
public static final long DEFAULT_REVOCATION_CACHE_VALIDITY_MILLIS = 15 * 60 * 1000L;
@Setting(value = "Validity period of cached StatusList2021 credential entries in milliseconds.", defaultValue = DEFAULT_REVOCATION_CACHE_VALIDITY_MILLIS + "", type = "long")
public static final String REVOCATION_CACHE_VALIDITY = "edc.iam.credential.revocation.cache.validity";

public static final String NAME = "Directory API Authentication Extension";
public static final String MONITOR_PREFIX = "Presentation Transformation";

private static final long DEFAULT_REVOCATION_CACHE_VALIDITY_MILLIS = 15 * 60 * 1000L;
private static final String DIRECTORY_CONTEXT = "directory";

@Setting(value = "Validity period of cached StatusList2021 credential entries in milliseconds.", defaultValue = DEFAULT_REVOCATION_CACHE_VALIDITY_MILLIS + "", type = "long")
public static final String REVOCATION_CACHE_VALIDITY = "edc.iam.credential.revocation.cache.validity";

@Inject
private WebService webService;
@Inject
Expand All @@ -78,15 +76,14 @@ public class CredentialBasedAuthenticationExtension implements ServiceExtension
private DidPublicKeyResolver didPublicKeyResolver;
@Inject
private Clock clock;

@Inject
private ApiAuthenticationRegistry registry;

@Inject
private RevocationServiceRegistry revocationServiceRegistry;

@Inject
private TrustedIssuerRegistry trustedIssuerRegistry;
private TypeTransformerRegistryImpl typeTransformerRegistry;
@Inject
private TypeTransformerRegistry typeTransformerRegistry;

@Override
public String name() {
Expand All @@ -103,35 +100,16 @@ public void initialize(ServiceExtensionContext context) {
var validity = context.getConfig().getLong(REVOCATION_CACHE_VALIDITY, DEFAULT_REVOCATION_CACHE_VALIDITY_MILLIS);
revocationServiceRegistry.addService(StatusList2021Status.TYPE, new StatusList2021RevocationService(typeManager.getMapper(), validity));
revocationServiceRegistry.addService(BitstringStatusListStatus.TYPE, new BitstringStatusListRevocationService(typeManager.getMapper(), validity));
var validationService = new VerifiableCredentialValidationServiceImpl(presentationVerifier, createTrustedIssuerRegistry(), revocationServiceRegistry, clock);
var validationService = new VerifiableCredentialValidationServiceImpl(presentationVerifier, trustedIssuerRegistry, revocationServiceRegistry, clock);

var authService = new CredentialBasedAuthenticationService(context.getMonitor(), typeManager.getMapper(), validationService, typeTransformerRegistry(context));
var authService = new CredentialBasedAuthenticationService(context.getMonitor(), typeManager.getMapper(), validationService, typeTransformerRegistry);
registry.register(DIRECTORY_CONTEXT, authService);
webService.registerResource(DIRECTORY_CONTEXT, new AuthenticationRequestFilter(registry, DIRECTORY_CONTEXT));
}

// must provide this, so the TrustedIssuerRegistryConfigurationExtension can inject it
@Provider
public TrustedIssuerRegistry createTrustedIssuerRegistry() {
if (trustedIssuerRegistry == null) {
trustedIssuerRegistry = new TrustedIssuerRegistryImpl();
}
return trustedIssuerRegistry;
public SecureTokenService secureTokenService() {
return (map, s) -> null; // not really needed but requested by the runtime because of some tangles into trusted-issuer-core
}

@Provider
public TypeTransformerRegistry typeTransformerRegistry(ServiceExtensionContext context) {
if (typeTransformerRegistry == null) {
typeTransformerRegistry = new TypeTransformerRegistryImpl();
var monitor = context.getMonitor().withPrefix(MONITOR_PREFIX);
typeTransformerRegistry.register(new JwtToVerifiablePresentationTransformer(monitor, typeManager.getMapper(JSON_LD), new TitaniumJsonLd(monitor, JsonLdConfiguration.Builder.newInstance().build())));
typeTransformerRegistry.register(new JwtToVerifiableCredentialTransformer(monitor));
}
return typeTransformerRegistry;
}

@Provider
public ApiAuthenticationProviderRegistry apiAuthenticationProviderRegistry() {
return new ApiAuthenticationProviderRegistryImpl();
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@
# SPDX-License-Identifier: Apache-2.0
#
org.eclipse.tractusx.bdrs.api.directory.authentication.CredentialBasedAuthenticationExtension
org.eclipse.tractusx.bdrs.api.directory.authentication.KeyParserRegistryExtension
org.eclipse.tractusx.bdrs.api.directory.authentication.HttpClientExtension
Loading

0 comments on commit 01b502d

Please sign in to comment.