Skip to content

Commit

Permalink
⬆️ Upgrade to EDC 0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
agmangas committed May 10, 2024
1 parent 8aa0833 commit 6368b3a
Show file tree
Hide file tree
Showing 14 changed files with 97 additions and 89 deletions.
2 changes: 1 addition & 1 deletion connector/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ allprojects {
// configure which version of the annotation processor to use. defaults to the same version as the plugin
configure<org.eclipse.edc.plugins.autodoc.AutodocExtension> {
processorVersion.set(edcVersion)
outputDirectory.set(project.buildDir)
outputDirectory.set(project.layout.buildDirectory.asFile.get())
}

configure<org.eclipse.edc.plugins.edcbuild.extensions.BuildExtension> {
Expand Down
37 changes: 23 additions & 14 deletions connector/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@ format.version = "1.1"

[versions]
assertj = "3.25.3"
awaitility = "4.2.0"
edc = "0.4.1"
awaitility = "4.2.1"
edc = "0.6.0"
jakarta-json = "2.0.1"
junit-pioneer = "2.2.0"
jupiter = "5.10.2"
okhttp-mockwebserver = "5.0.0-alpha.12"
okhttp-mockwebserver = "5.0.0-alpha.14"
openTelemetry = "1.18.0"
restAssured = "5.4.0"
rsApi = "3.1.0"
testcontainers = "1.19.5"
kafkaClients = "3.6.1"
rsApi = "4.0.0"
testcontainers = "1.19.8"
kafkaClients = "3.7.0"
json = "20230227"
swaggerParser = "2.1.15"
slugify = "3.0.4"
postgresql = "42.7.3"
jwt = "0.12.5"
okhttp = "4.12.0"

[libraries]
assertj = { module = "org.assertj:assertj-core", version.ref = "assertj" }
awaitility = { module = "org.awaitility:awaitility", version.ref = "awaitility" }
edc-core-spi = { module = "org.eclipse.edc:core-spi", version.ref = "edc" }
edc-api-core = { module = "org.eclipse.edc:api-core", version.ref = "edc" }
edc-api-observability = { module = "org.eclipse.edc:api-observability", version.ref = "edc" }
edc-auth-tokenbased = { module = "org.eclipse.edc:auth-tokenbased", version.ref = "edc" }
Expand All @@ -34,15 +35,15 @@ edc-control-plane-api-client = { module = "org.eclipse.edc:control-plane-api-cli
edc-control-plane-api = { module = "org.eclipse.edc:control-plane-api", version.ref = "edc" }
edc-control-plane-core = { module = "org.eclipse.edc:control-plane-core", version.ref = "edc" }
edc-control-plane-spi = { module = "org.eclipse.edc:control-plane-spi", version.ref = "edc" }
edc-data-plane-api = { module = "org.eclipse.edc:data-plane-api", version.ref = "edc" }
edc-data-plane-control-api = { module = "org.eclipse.edc:data-plane-control-api", version.ref = "edc" }
edc-data-plane-public-api = { module = "org.eclipse.edc:data-plane-public-api", version.ref = "edc" }
edc-data-plane-aws-s3 = { module = "org.eclipse.edc:data-plane-aws-s3", version.ref = "edc" }
edc-data-plane-azure-storage = { module = "org.eclipse.edc:data-plane-azure-storage", version.ref = "edc" }
edc-data-plane-client = { module = "org.eclipse.edc:data-plane-client", version.ref = "edc" }
edc-data-plane-core = { module = "org.eclipse.edc:data-plane-core", version.ref = "edc" }
edc-data-plane-http = { module = "org.eclipse.edc:data-plane-http", version.ref = "edc" }
edc-data-plane-kafka = { module = "org.eclipse.edc:data-plane-kafka", version.ref = "edc" }
edc-data-plane-selector-api = { module = "org.eclipse.edc:data-plane-selector-api", version.ref = "edc" }
edc-data-plane-selector-client = { module = "org.eclipse.edc:data-plane-selector-client", version.ref = "edc" }
edc-data-plane-selector-core = { module = "org.eclipse.edc:data-plane-selector-core", version.ref = "edc" }
edc-data-plane-spi = { module = "org.eclipse.edc:data-plane-spi", version.ref = "edc" }
edc-data-plane-util = { module = "org.eclipse.edc:data-plane-util", version.ref = "edc" }
Expand All @@ -51,7 +52,8 @@ edc-http = { module = "org.eclipse.edc:http", version.ref = "edc" }
edc-iam-mock = { module = "org.eclipse.edc:iam-mock", version.ref = "edc" }
edc-jersey-micrometer = { module = "org.eclipse.edc:jersey-micrometer", version.ref = "edc" }
edc-jetty-micrometer = { module = "org.eclipse.edc:jetty-micrometer", version.ref = "edc" }
edc-json-ld = { module = "org.eclipse.edc:json-ld", version.ref = "edc" }
edc-json-ld-lib = { module = "org.eclipse.edc:json-ld-lib", version.ref = "edc" }
edc-json-ld-spi = { module = "org.eclipse.edc:json-ld-spi", version.ref = "edc" }
edc-junit = { module = "org.eclipse.edc:junit", version.ref = "edc" }
edc-management-api = { module = "org.eclipse.edc:management-api", version.ref = "edc" }
edc-micrometer-core = { module = "org.eclipse.edc:micrometer-core", version.ref = "edc" }
Expand All @@ -65,23 +67,26 @@ edc-transfer-pull-http-dynamic-receiver = { module = "org.eclipse.edc:transfer-p
edc-util = { module = "org.eclipse.edc:util", version.ref = "edc" }
edc-vault-azure = { module = "org.eclipse.edc:vault-azure", version.ref = "edc" }
edc-vault-filesystem = { module = "org.eclipse.edc:vault-filesystem", version.ref = "edc" }
edc-oauth2-client = { module = "org.eclipse.edc:oauth2-client", version.ref = "edc" }
edc-oauth2-core = { module = "org.eclipse.edc:oauth2-core", version.ref = "edc" }
edc-protocol-dsp = { module = "org.eclipse.edc:dsp", version.ref = "edc" }
jakarta-rsApi = { module = "jakarta.ws.rs:jakarta.ws.rs-api", version.ref = "rsApi" }
jakartaJson = { module = "org.glassfish:jakarta.json", version.ref = "jakarta-json" }
junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "jupiter" }
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "jupiter" }
junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "jupiter" }
junit-pioneer = { module = "org.junit-pioneer:junit-pioneer", version.ref = "junit-pioneer" }
okhttp-mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "okhttp-mockwebserver" }
opentelemetry-annotations = { module = "io.opentelemetry:opentelemetry-extension-annotations", version.ref = "openTelemetry" }
opentelemetry-annotations = { module = "io.opentelemetry:opentelemetry-extension-annotations", version = "1.18.0" }
opentelemetry-exporter-jaeger = { module = "io.opentelemetry:opentelemetry-exporter-jaeger", version = "1.34.1" }
opentelemetry-javaagent = { module = "io.opentelemetry.javaagent:opentelemetry-javaagent", version = "2.3.0" }
restAssured = { module = "io.rest-assured:rest-assured", version.ref = "restAssured" }
testcontainers = { module = "org.testcontainers:testcontainers", version.ref = "testcontainers" }
testcontainers-junit-jupiter = { module = "org.testcontainers:junit-jupiter", version.ref = "testcontainers" }
kafka-clients = { module = "org.apache.kafka:kafka-clients", version.ref = "kafkaClients" }
testcontainers-kafka = { module = "org.testcontainers:kafka", version.ref = "testcontainers" }
testcontainers-junit = { module = "org.testcontainers:junit-jupiter", version.ref = "testcontainers" }
opentelemetry = "io.opentelemetry.javaagent:opentelemetry-javaagent:2.1.0"
edc-oauth2-client = { module = "org.eclipse.edc:oauth2-client", version.ref = "edc" }
edc-oauth2-core = { module = "org.eclipse.edc:oauth2-core", version.ref = "edc" }
edc-core-spi = { module = "org.eclipse.edc:core-spi", version.ref = "edc" }
json = { module = "org.json:json", version.ref = "json" }
swaggerParser = { module = "io.swagger.parser.v3:swagger-parser", version.ref = "swaggerParser" }
slugify = { module = "com.github.slugify:slugify", version.ref = "slugify" }
Expand All @@ -90,6 +95,10 @@ edc-transaction-local = { module = "org.eclipse.edc:transaction-local", version.
edc-transaction-datasource-spi = { module = "org.eclipse.edc:transaction-datasource-spi", version.ref = "edc" }
edc-sql-control-plane-sql = { module = "org.eclipse.edc:control-plane-sql", version.ref = "edc" }
postgresql-postgresql = { module = "org.postgresql:postgresql", version.ref = "postgresql" }
jsonwebtoken-jjwt-api = { module = "io.jsonwebtoken:jjwt-api", version.ref = "jwt" }
jsonwebtoken-jjwt-impl = { module = "io.jsonwebtoken:jjwt-impl", version.ref = "jwt" }
jsonwebtoken-jjwt-jackson = { module = "io.jsonwebtoken:jjwt-jackson", version.ref = "jwt" }
okhttp3-okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }

[plugins]
shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" }
2 changes: 1 addition & 1 deletion connector/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
11 changes: 4 additions & 7 deletions connector/iam/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@ plugins {
`java-library`
}

val okHttpVersion = "4.12.0"
val jwtVersion = "0.12.5"

dependencies {
implementation(libs.edc.connector.core)
implementation(libs.edc.control.plane.core)
implementation(libs.edc.data.plane.core)
implementation(libs.edc.core.spi)

implementation(libs.json)
implementation("com.squareup.okhttp3:okhttp:$okHttpVersion")
implementation("io.jsonwebtoken:jjwt-api:$jwtVersion")
runtimeOnly("io.jsonwebtoken:jjwt-impl:$jwtVersion")
runtimeOnly("io.jsonwebtoken:jjwt-jackson:$jwtVersion")
implementation(libs.okhttp3.okhttp)
implementation(libs.jsonwebtoken.jjwt.api)
runtimeOnly(libs.jsonwebtoken.jjwt.impl)
runtimeOnly(libs.jsonwebtoken.jjwt.jackson)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@

import org.eclipse.edc.runtime.metamodel.annotation.Extension;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.runtime.metamodel.annotation.Provider;
import org.eclipse.edc.runtime.metamodel.annotation.Provides;
import org.eclipse.edc.runtime.metamodel.annotation.Setting;
import org.eclipse.edc.spi.iam.AudienceResolver;
import org.eclipse.edc.spi.iam.IdentityService;
import org.eclipse.edc.spi.monitor.Monitor;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;
import org.eclipse.edc.spi.types.TypeManager;
import org.eclipse.edc.spi.types.domain.message.RemoteMessage;

/**
* This class represents the VCIdentityExtension, which is an implementation of
Expand Down Expand Up @@ -115,6 +118,15 @@ public void initialize(ServiceExtensionContext context) {
context.getMonitor().severe("Failed to initialize WaltIDIdentityServices", e);
System.exit(1);
}
}

/**
* Resolves the audience for the remote message.
*
* @return The counter party address of the remote message.
*/
@Provider
public AudienceResolver audienceResolver() {
return RemoteMessage::getCounterPartyAddress;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package eu.datacellar.iam;

import static java.lang.String.format;

import java.io.IOException;
import java.util.Objects;

import org.eclipse.edc.spi.iam.ClaimToken;
import org.eclipse.edc.spi.iam.IdentityService;
import org.eclipse.edc.spi.iam.TokenParameters;
import org.eclipse.edc.spi.iam.TokenRepresentation;
import org.eclipse.edc.spi.iam.VerificationContext;
import org.eclipse.edc.spi.monitor.Monitor;
import org.eclipse.edc.spi.result.Result;
import org.eclipse.edc.spi.types.TypeManager;
Expand Down Expand Up @@ -60,10 +58,10 @@ public VCIdentityService(Monitor monitor, TypeManager typeManager, String client

@Override
public Result<TokenRepresentation> obtainClientCredentials(TokenParameters parameters) {
String audience = parameters.getStringClaim("aud");

monitor.info(
String.format("obtainClientCredentials: (scope=%s) (audience=%s)",
parameters.getScope(),
parameters.getAudience()));
String.format("obtainClientCredentials: (audience=%s)", audience));

PresentationDefinition presentationDefinition = new PresentationDefinition(PRESENTED_VC_TYPE);
MatchCredentialsResponse matchCredentialsResponse;
Expand All @@ -90,7 +88,7 @@ public Result<TokenRepresentation> obtainClientCredentials(TokenParameters param

presentationBuilder
.addJwtCredential(jwtEncodedVC)
.setAudience(parameters.getAudience());
.setAudience(audience);

String jwtEncodedVP;

Expand All @@ -103,7 +101,7 @@ public Result<TokenRepresentation> obtainClientCredentials(TokenParameters param
monitor.debug("JWT-encoded Verifiable Presentation: %s".formatted(jwtEncodedVP));

var token = new VerifiablePresentationToken();
token.setAudience(parameters.getAudience());
token.setAudience(audience);
token.setClientId(clientId);
token.setJwtVerifiablePresentation(jwtEncodedVP);
token.setClientDid(presentationBuilder.getHolderDid());
Expand All @@ -116,16 +114,11 @@ public Result<TokenRepresentation> obtainClientCredentials(TokenParameters param
}

@Override
public Result<ClaimToken> verifyJwtToken(TokenRepresentation tokenRepresentation, String audience) {
public Result<ClaimToken> verifyJwtToken(TokenRepresentation tokenRepresentation, VerificationContext context) {
monitor.debug("verifyJwtToken.tokenRepresentation: %s".formatted(tokenRepresentation.getToken()));
monitor.debug("verifyJwtToken.audience: %s".formatted(audience));

var token = typeManager.readValue(tokenRepresentation.getToken(), VerifiablePresentationToken.class);

if (!Objects.equals(token.audience, audience)) {
return Result.failure(format("Mismatched audience: expected %s, got %s", audience, token.audience));
}

Jwk<?> anchorJwk;

try {
Expand Down
12 changes: 8 additions & 4 deletions connector/openapi-connector/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ plugins {
}

dependencies {
implementation(libs.edc.boot)
implementation(libs.edc.connector.core)
implementation(libs.edc.http)
implementation(libs.edc.control.plane.api.client)
implementation(libs.edc.control.plane.api)
implementation(libs.edc.control.plane.core)
Expand All @@ -14,12 +17,13 @@ dependencies {
implementation(libs.edc.management.api)
implementation(libs.edc.transfer.data.plane)
implementation(libs.edc.transfer.pull.http.receiver)
implementation(libs.edc.core.spi)

implementation(libs.edc.data.plane.selector.api)
implementation(libs.edc.data.plane.selector.core)
implementation(libs.edc.data.plane.selector.client)

implementation(libs.edc.data.plane.api)
implementation(libs.edc.data.plane.control.api)
implementation(libs.edc.data.plane.public.api)
implementation(libs.edc.data.plane.core)
implementation(libs.edc.data.plane.http)

Expand All @@ -43,6 +47,8 @@ dependencies {
}

implementation(libs.postgresql.postgresql)
implementation(libs.edc.transaction.datasource.spi)
implementation(libs.edc.transaction.local)

if (
project.hasProperty("useSQLStore") &&
Expand All @@ -51,8 +57,6 @@ dependencies {
// https://github.com/eclipse-edc/Connector/discussions/3242
implementation(libs.edc.sql.control.plane.sql)
implementation(libs.edc.sql.pool.apache.commons)
implementation(libs.edc.transaction.local)
implementation(libs.edc.transaction.datasource.spi)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public class CredentialConstraintFunction implements AtomicConstraintFunction<Pe

private Monitor monitor;

/**
* Constructs a new instance of the CredentialConstraintFunction class with the
* specified monitor.
*
* @param monitor The monitor used for tracking and logging.
*/
public CredentialConstraintFunction(Monitor monitor) {
this.monitor = monitor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import org.eclipse.edc.connector.contract.spi.offer.store.ContractDefinitionStore;
import org.eclipse.edc.connector.contract.spi.types.offer.ContractDefinition;
import org.eclipse.edc.connector.core.CoreServicesExtension;
import org.eclipse.edc.connector.dataplane.http.spi.HttpDataAddress;
import org.eclipse.edc.connector.dataplane.http.spi.HttpRequestParamsProvider;
import org.eclipse.edc.connector.dataplane.selector.spi.instance.DataPlaneInstance;
Expand Down Expand Up @@ -69,6 +68,7 @@ public class OpenAPICoreExtension implements ServiceExtension {
private static final String DATASOURCE_URL = "edc.datasource.default.url";
private static final String DATASOURCE_USER = "edc.datasource.default.user";
private static final String DATASOURCE_PASSWORD = "edc.datasource.default.password";
private static final String EDC_HOSTNAME = "edc.hostname";

/**
* The name of the extension.
Expand Down Expand Up @@ -126,7 +126,7 @@ public String name() {
private DataPlaneInstance buildDataPlaneInstance(ServiceExtensionContext context) {
Monitor monitor = context.getMonitor();

String hostname = context.getSetting(CoreServicesExtension.HOSTNAME_SETTING, DEFAULT_HOSTNAME);
String hostname = context.getSetting(EDC_HOSTNAME, DEFAULT_HOSTNAME);
String controlPort = context.getSetting(WEB_HTTP_CONTROL_PORT, String.valueOf(DEFAULT_WEB_HTTP_CONTROL_PORT));
String publicPort = context.getSetting(WEB_HTTP_PUBLIC_PORT, String.valueOf(DEFAULT_WEB_HTTP_PUBLIC_PORT));
String scheme = context.getSetting(HTTP_SCHEME, DEFAULT_HTTP_SCHEME);
Expand Down Expand Up @@ -204,9 +204,7 @@ private String extractCredentialTypePattern(Map<String, Object> presentationDefi
* @return The policy definition.
*/
private PolicyDefinition buildPolicyDefinition(Map<String, Object> presentationDefinition, Monitor monitor) {
final Action USE_ACTION = Action.Builder.newInstance().type("USE").build();

ruleBindingRegistry.bind(USE_ACTION.getType(), ALL_SCOPES);
ruleBindingRegistry.bind("use", ALL_SCOPES);

PolicyDefinition.Builder policyDefBuilder = PolicyDefinition.Builder.newInstance()
.id(UUID.randomUUID().toString());
Expand All @@ -230,7 +228,8 @@ private PolicyDefinition buildPolicyDefinition(Map<String, Object> presentationD
.operator(Operator.IN)
.rightExpression(new LiteralExpression(credentialTypePattern)).build();

var permission = Permission.Builder.newInstance().action(USE_ACTION).constraint(credentialConstraint)
var permission = Permission.Builder.newInstance().action(Action.Builder.newInstance().type("USE").build())
.constraint(credentialConstraint)
.build();

return policyDefBuilder
Expand Down
4 changes: 2 additions & 2 deletions dev-config/sql-store-schemas/contract-negotiation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ CREATE TABLE IF NOT EXISTS edc_contract_negotiation
callback_addresses JSON,
trace_context JSON,
pending BOOLEAN DEFAULT FALSE,
protocol_messages JSON,
lease_id VARCHAR
CONSTRAINT contract_negotiation_lease_lease_id_fk
REFERENCES edc_lease
ON DELETE SET NULL,
CONSTRAINT provider_correlation_id CHECK (type = '0' OR correlation_id IS NOT NULL)
ON DELETE SET NULL
);

COMMENT ON COLUMN edc_contract_negotiation.agreement_id IS 'ContractAgreement serialized as JSON';
Expand Down
1 change: 1 addition & 0 deletions dev-config/sql-store-schemas/policy-definition.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ CREATE TABLE IF NOT EXISTS edc_policydefinitions
assignee VARCHAR,
target VARCHAR,
policy_type VARCHAR NOT NULL,
private_properties JSON,
PRIMARY KEY (policy_id)
);

Expand Down
Loading

0 comments on commit 6368b3a

Please sign in to comment.