Changesets · Branches · Tags · Compare
| Changeset | b3b58d6bb3bc8025b69d097fe60db3f0f876823d9dfd78883f83d69af7ba2566 |
|---|---|
| Author | Paul Latzelsperger <43503240+paullatzelsperger@users.noreply.github.com> · 2024-07-11 16:28 +02:00 |
| Committer | GitHub <noreply@github.com> · 2024-07-11 16:28 +02:00 |
| Parents | d3b34c182bea |
16 files changed
modified core/control-plane/control-plane-aggregate-services/src/main/java/org/eclipse/edc/connector/controlplane/services/catalog/CatalogServiceImpl.java +2 −1
| @@ -33,12 +33,13 @@ | ||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | @Override |
| 36 | - public CompletableFuture<StatusResult<byte[]>> requestCatalog(String counterPartyId, String counterPartyAddress, String protocol, QuerySpec querySpec) { | |
| 36 | + public CompletableFuture<StatusResult<byte[]>> requestCatalog(String counterPartyId, String counterPartyAddress, String protocol, QuerySpec querySpec, String... additionalScopes) { | |
| 37 | 37 | var request = CatalogRequestMessage.Builder.newInstance() |
| 38 | 38 | .protocol(protocol) |
| 39 | 39 | .counterPartyId(counterPartyId) |
| 40 | 40 | .counterPartyAddress(counterPartyAddress) |
| 41 | 41 | .querySpec(querySpec) |
| 42 | + .additionalScopes(additionalScopes) | |
| 42 | 43 | .build(); |
| 43 | 44 | |
| 44 | 45 | return dispatcher.dispatch(byte[].class, request); |
modified data-protocols/dsp/dsp-http-core/src/main/java/org/eclipse/edc/protocol/dsp/http/dispatcher/DspHttpRemoteMessageDispatcherImpl.java +6 −0
| @@ -16,6 +16,7 @@ | ||
| 16 | 16 | |
| 17 | 17 | import okhttp3.Response; |
| 18 | 18 | import okhttp3.ResponseBody; |
| 19 | +import org.eclipse.edc.connector.controlplane.catalog.spi.CatalogRequestMessage; | |
| 19 | 20 | import org.eclipse.edc.http.spi.EdcHttpClient; |
| 20 | 21 | import org.eclipse.edc.policy.engine.spi.PolicyContextImpl; |
| 21 | 22 | import org.eclipse.edc.policy.engine.spi.PolicyEngine; |
| @@ -108,6 +109,11 @@ | ||
| 108 | 109 | var policyProvider = (Function<M, Policy>) policyScope.policyProvider; |
| 109 | 110 | policyEngine.evaluate(policyScope.scope, policyProvider.apply(message), context); |
| 110 | 111 | |
| 112 | + // catalog request messages can carry additional, user-supplied scopes | |
| 113 | + if (message instanceof CatalogRequestMessage catalogRequestMessage) { | |
| 114 | + catalogRequestMessage.getAdditionalScopes().forEach(requestScopeBuilder::scope); | |
| 115 | + } | |
| 116 | + | |
| 111 | 117 | var scopes = requestScopeBuilder.build().getScopes(); |
| 112 | 118 | |
| 113 | 119 | // Only add the scope claim if there are scopes returned from the policy engine evaluation |
modified data-protocols/dsp/dsp-http-core/src/test/java/org/eclipse/edc/protocol/dsp/http/dispatcher/DspHttpRemoteMessageDispatcherImplTest.java +45 −0
| @@ -18,6 +18,7 @@ | ||
| 18 | 18 | import okhttp3.Protocol; |
| 19 | 19 | import okhttp3.Request; |
| 20 | 20 | import okhttp3.ResponseBody; |
| 21 | +import org.eclipse.edc.connector.controlplane.catalog.spi.CatalogRequestMessage; | |
| 21 | 22 | import org.eclipse.edc.http.spi.EdcHttpClient; |
| 22 | 23 | import org.eclipse.edc.policy.engine.spi.PolicyContext; |
| 23 | 24 | import org.eclipse.edc.policy.engine.spi.PolicyEngine; |
| @@ -271,6 +272,50 @@ | ||
| 271 | 272 | verifyNoInteractions(policyEngine); |
| 272 | 273 | } |
| 273 | 274 | |
| 275 | + @Test | |
| 276 | + void dispatch_whenCatalogRequestMessage_shouldExtractScopes() { | |
| 277 | + var authToken = "token"; | |
| 278 | + Map<String, Object> additional = Map.of("foo", "bar"); | |
| 279 | + var policy = Policy.Builder.newInstance().build(); | |
| 280 | + DspHttpRequestFactory<CatalogRequestMessage> rqFactory = mock(); | |
| 281 | + when(audienceResolver.resolve(any())).thenReturn(Result.success(AUDIENCE_VALUE)); | |
| 282 | + when(tokenDecorator.decorate(any())).thenAnswer(a -> a.getArgument(0, TokenParameters.Builder.class).claims(additional)); | |
| 283 | + when(rqFactory.createRequest(any())).thenReturn(new Request.Builder().url("http://url").build()); | |
| 284 | + when(httpClient.executeAsync(any(), isA(List.class))).thenReturn(completedFuture(dummyResponse(200))); | |
| 285 | + when(identityService.obtainClientCredentials(any())) | |
| 286 | + .thenReturn(Result.success(TokenRepresentation.Builder.newInstance().token(authToken).build())); | |
| 287 | + | |
| 288 | + dispatcher.registerPolicyScope(CatalogRequestMessage.class, "scope.test", (m) -> policy); | |
| 289 | + | |
| 290 | + when(policyEngine.evaluate(eq("scope.test"), eq(policy), any())).thenAnswer(a -> { | |
| 291 | + PolicyContext context = a.getArgument(2); | |
| 292 | + var builder = context.getContextData(RequestScope.Builder.class); | |
| 293 | + builder.scope("policy-test-scope"); | |
| 294 | + return Result.success(); | |
| 295 | + }); | |
| 296 | + | |
| 297 | + dispatcher.registerMessage(CatalogRequestMessage.class, rqFactory, mock()); | |
| 298 | + | |
| 299 | + var message = CatalogRequestMessage.Builder.newInstance().additionalScopes("scope1", "scope2").build(); | |
| 300 | + var result = dispatcher.dispatch(String.class, message); | |
| 301 | + | |
| 302 | + assertThat(result).succeedsWithin(timeout); | |
| 303 | + | |
| 304 | + var captor = ArgumentCaptor.forClass(TokenParameters.class); | |
| 305 | + verify(identityService).obtainClientCredentials(captor.capture()); | |
| 306 | + verify(httpClient).executeAsync(argThat(r -> authToken.equals(r.headers().get("Authorization"))), isA(List.class)); | |
| 307 | + verify(rqFactory).createRequest(message); | |
| 308 | + verify(policyEngine).evaluate(any(), any(), argThat(ctx -> { | |
| 309 | + var requestContext = ctx.getContextData(RequestContext.class); | |
| 310 | + return requestContext.getMessage().getClass().equals(CatalogRequestMessage.class) && requestContext.getDirection().equals(RequestContext.Direction.Egress); | |
| 311 | + })); | |
| 312 | + assertThat(captor.getValue()).satisfies(tr -> { | |
| 313 | + assertThat(tr.getStringClaim(SCOPE_CLAIM)).isEqualTo("policy-test-scope scope1 scope2"); | |
| 314 | + assertThat(tr.getStringClaim(AUDIENCE_CLAIM)).isEqualTo(AUDIENCE_VALUE); | |
| 315 | + assertThat(tr.getClaims()).containsAllEntriesOf(additional); | |
| 316 | + }); | |
| 317 | + } | |
| 318 | + | |
| 274 | 319 | @Test |
| 275 | 320 | void dispatch_shouldEvaluatePolicy() { |
| 276 | 321 | var policy = Policy.Builder.newInstance().build(); |
modified extensions/common/api/management-api-configuration/src/main/resources/management-api-version.json +1 −1
| @@ -8,7 +8,7 @@ | ||
| 8 | 8 | { |
| 9 | 9 | "version": "3.1.0-alpha", |
| 10 | 10 | "urlPath": "/v3.1alpha", |
| 11 | - "lastUpdated": "2024-07-09T09:17:00Z", | |
| 11 | + "lastUpdated": "2024-07-10T09:17:00Z", | |
| 12 | 12 | "maturity": "alpha" |
| 13 | 13 | } |
| 14 | 14 | ] |
modified extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/catalog/BaseCatalogApiController.java +2 −1
| @@ -50,7 +50,8 @@ | ||
| 50 | 50 | var request = transformerRegistry.transform(requestBody, CatalogRequest.class) |
| 51 | 51 | .orElseThrow(InvalidRequestException::new); |
| 52 | 52 | |
| 53 | - service.requestCatalog(request.getCounterPartyId(), request.getCounterPartyAddress(), request.getProtocol(), request.getQuerySpec()) | |
| 53 | + var scopes = request.getAdditionalScopes().toArray(new String[0]); | |
| 54 | + service.requestCatalog(request.getCounterPartyId(), request.getCounterPartyAddress(), request.getProtocol(), request.getQuerySpec(), scopes) | |
| 54 | 55 | .whenComplete((result, throwable) -> { |
| 55 | 56 | try { |
| 56 | 57 | response.resume(toResponse(result, throwable)); |
modified extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/catalog/CatalogApiExtension.java +2 −0
| @@ -18,6 +18,7 @@ | ||
| 18 | 18 | import org.eclipse.edc.connector.controlplane.api.management.catalog.transform.JsonObjectToDatasetRequestTransformer; |
| 19 | 19 | import org.eclipse.edc.connector.controlplane.api.management.catalog.v2.CatalogApiV2Controller; |
| 20 | 20 | import org.eclipse.edc.connector.controlplane.api.management.catalog.v3.CatalogApiV3Controller; |
| 21 | +import org.eclipse.edc.connector.controlplane.api.management.catalog.v31alpha.CatalogApiV31AlphaController; | |
| 21 | 22 | import org.eclipse.edc.connector.controlplane.api.management.catalog.validation.CatalogRequestValidator; |
| 22 | 23 | import org.eclipse.edc.connector.controlplane.api.management.catalog.validation.DatasetRequestValidator; |
| 23 | 24 | import org.eclipse.edc.connector.controlplane.services.spi.catalog.CatalogService; |
| @@ -67,6 +68,7 @@ | ||
| 67 | 68 | var managementApiTransformerRegistry = transformerRegistry.forContext("management-api"); |
| 68 | 69 | webService.registerResource(ApiContext.MANAGEMENT, new CatalogApiV2Controller(service, managementApiTransformerRegistry, validatorRegistry, context.getMonitor())); |
| 69 | 70 | webService.registerResource(ApiContext.MANAGEMENT, new CatalogApiV3Controller(service, managementApiTransformerRegistry, validatorRegistry)); |
| 71 | + webService.registerResource(ApiContext.MANAGEMENT, new CatalogApiV31AlphaController(service, managementApiTransformerRegistry, validatorRegistry)); | |
| 70 | 72 | |
| 71 | 73 | validatorRegistry.register(CATALOG_REQUEST_TYPE, CatalogRequestValidator.instance(criterionOperatorRegistry)); |
| 72 | 74 | validatorRegistry.register(DATASET_REQUEST_TYPE, DatasetRequestValidator.instance()); |
modified extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/catalog/transform/JsonObjectToCatalogRequestTransformer.java +12 −8
| @@ -22,8 +22,8 @@ | ||
| 22 | 22 | import org.jetbrains.annotations.NotNull; |
| 23 | 23 | import org.jetbrains.annotations.Nullable; |
| 24 | 24 | |
| 25 | -import java.util.Optional; | |
| 26 | - | |
| 25 | +import static java.util.Optional.ofNullable; | |
| 26 | +import static org.eclipse.edc.connector.controlplane.catalog.spi.CatalogRequest.CATALOG_REQUEST_ADDITIONAL_SCOPES; | |
| 27 | 27 | import static org.eclipse.edc.connector.controlplane.catalog.spi.CatalogRequest.CATALOG_REQUEST_COUNTER_PARTY_ADDRESS; |
| 28 | 28 | import static org.eclipse.edc.connector.controlplane.catalog.spi.CatalogRequest.CATALOG_REQUEST_COUNTER_PARTY_ID; |
| 29 | 29 | import static org.eclipse.edc.connector.controlplane.catalog.spi.CatalogRequest.CATALOG_REQUEST_PROTOCOL; |
| @@ -40,21 +40,25 @@ | ||
| 40 | 40 | var counterPartyAddress = transformString(object.get(CATALOG_REQUEST_COUNTER_PARTY_ADDRESS), context); |
| 41 | 41 | |
| 42 | 42 | // For backward compatibility if the ID is not sent, fallback to the counterPartyAddress |
| 43 | - var counterPartyId = Optional.ofNullable(object.get(CATALOG_REQUEST_COUNTER_PARTY_ID)) | |
| 43 | + var counterPartyId = ofNullable(object.get(CATALOG_REQUEST_COUNTER_PARTY_ID)) | |
| 44 | 44 | .map(it -> transformString(it, context)) |
| 45 | 45 | .orElse(counterPartyAddress); |
| 46 | 46 | |
| 47 | - var querySpec = Optional.of(object) | |
| 48 | - .map(it -> it.get(CATALOG_REQUEST_QUERY_SPEC)) | |
| 47 | + var querySpec = ofNullable(object.get(CATALOG_REQUEST_QUERY_SPEC)) | |
| 49 | 48 | .map(it -> transformObject(it, QuerySpec.class, context)) |
| 50 | 49 | .orElse(null); |
| 51 | 50 | |
| 52 | - return CatalogRequest.Builder.newInstance() | |
| 51 | + var builder = CatalogRequest.Builder.newInstance() | |
| 53 | 52 | .protocol(transformString(object.get(CATALOG_REQUEST_PROTOCOL), context)) |
| 54 | 53 | .counterPartyAddress(counterPartyAddress) |
| 55 | 54 | .counterPartyId(counterPartyId) |
| 56 | - .querySpec(querySpec) | |
| 57 | - .build(); | |
| 55 | + .querySpec(querySpec); | |
| 56 | + | |
| 57 | + | |
| 58 | + ofNullable(object.getJsonArray(CATALOG_REQUEST_ADDITIONAL_SCOPES)) | |
| 59 | + .ifPresent(ja -> builder.additionalScopes(ja.stream().map(this::nodeValue).toList())); | |
| 60 | + | |
| 61 | + return builder.build(); | |
| 58 | 62 | } |
| 59 | 63 | |
| 60 | 64 | } |
added extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/catalog/v31alpha/CatalogApiV31AlphaController.java +52 −0
| @@ -0,0 +1,52 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | |
| 3 | + * | |
| 4 | + * This program and the accompanying materials are made available under the | |
| 5 | + * terms of the Apache License, Version 2.0 which is available at | |
| 6 | + * https://www.apache.org/licenses/LICENSE-2.0 | |
| 7 | + * | |
| 8 | + * SPDX-License-Identifier: Apache-2.0 | |
| 9 | + * | |
| 10 | + * Contributors: | |
| 11 | + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation | |
| 12 | + * | |
| 13 | + */ | |
| 14 | + | |
| 15 | +package org.eclipse.edc.connector.controlplane.api.management.catalog.v31alpha; | |
| 16 | + | |
| 17 | +import jakarta.json.JsonObject; | |
| 18 | +import jakarta.ws.rs.Consumes; | |
| 19 | +import jakarta.ws.rs.POST; | |
| 20 | +import jakarta.ws.rs.Path; | |
| 21 | +import jakarta.ws.rs.Produces; | |
| 22 | +import jakarta.ws.rs.container.AsyncResponse; | |
| 23 | +import jakarta.ws.rs.container.Suspended; | |
| 24 | +import org.eclipse.edc.connector.controlplane.api.management.catalog.BaseCatalogApiController; | |
| 25 | +import org.eclipse.edc.connector.controlplane.services.spi.catalog.CatalogService; | |
| 26 | +import org.eclipse.edc.transform.spi.TypeTransformerRegistry; | |
| 27 | +import org.eclipse.edc.validator.spi.JsonObjectValidatorRegistry; | |
| 28 | + | |
| 29 | +import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; | |
| 30 | + | |
| 31 | +@Consumes(APPLICATION_JSON) | |
| 32 | +@Produces(APPLICATION_JSON) | |
| 33 | +@Path("/v3.1alpha/catalog") | |
| 34 | +public class CatalogApiV31AlphaController extends BaseCatalogApiController implements CatalogApiV31alpha { | |
| 35 | + public CatalogApiV31AlphaController(CatalogService service, TypeTransformerRegistry transformerRegistry, JsonObjectValidatorRegistry validatorRegistry) { | |
| 36 | + super(service, transformerRegistry, validatorRegistry); | |
| 37 | + } | |
| 38 | + | |
| 39 | + @POST | |
| 40 | + @Path("/request") | |
| 41 | + @Override | |
| 42 | + public void requestCatalogV31alpha(JsonObject request, @Suspended AsyncResponse response) { | |
| 43 | + requestCatalog(request, response); | |
| 44 | + } | |
| 45 | + | |
| 46 | + @POST | |
| 47 | + @Path("dataset/request") | |
| 48 | + @Override | |
| 49 | + public void getDatasetV31alpha(JsonObject request, @Suspended AsyncResponse response) { | |
| 50 | + getDataset(request, response); | |
| 51 | + } | |
| 52 | +} |
added extensions/control-plane/api/management-api/catalog-api/src/main/java/org/eclipse/edc/connector/controlplane/api/management/catalog/v31alpha/CatalogApiV31alpha.java +252 −0
| @@ -0,0 +1,252 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | |
| 3 | + * | |
| 4 | + * This program and the accompanying materials are made available under the | |
| 5 | + * terms of the Apache License, Version 2.0 which is available at | |
| 6 | + * https://www.apache.org/licenses/LICENSE-2.0 | |
| 7 | + * | |
| 8 | + * SPDX-License-Identifier: Apache-2.0 | |
| 9 | + * | |
| 10 | + * Contributors: | |
| 11 | + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation | |
| 12 | + * | |
| 13 | + */ | |
| 14 | + | |
| 15 | +package org.eclipse.edc.connector.controlplane.api.management.catalog.v31alpha; | |
| 16 | + | |
| 17 | +import io.swagger.v3.oas.annotations.OpenAPIDefinition; | |
| 18 | +import io.swagger.v3.oas.annotations.Operation; | |
| 19 | +import io.swagger.v3.oas.annotations.info.Info; | |
| 20 | +import io.swagger.v3.oas.annotations.media.Content; | |
| 21 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 22 | +import io.swagger.v3.oas.annotations.parameters.RequestBody; | |
| 23 | +import io.swagger.v3.oas.annotations.responses.ApiResponse; | |
| 24 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 25 | +import jakarta.json.JsonObject; | |
| 26 | +import jakarta.ws.rs.container.AsyncResponse; | |
| 27 | +import jakarta.ws.rs.container.Suspended; | |
| 28 | +import org.eclipse.edc.api.model.ApiCoreSchema; | |
| 29 | + | |
| 30 | +import java.util.List; | |
| 31 | + | |
| 32 | +import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.NOT_REQUIRED; | |
| 33 | +import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | |
| 34 | +import static org.eclipse.edc.connector.controlplane.catalog.spi.CatalogRequest.CATALOG_REQUEST_TYPE; | |
| 35 | +import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.CONTEXT; | |
| 36 | +import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; | |
| 37 | + | |
| 38 | +@OpenAPIDefinition(info = @Info(version = "v3")) | |
| 39 | +@Tag(name = "Catalog V3") | |
| 40 | +public interface CatalogApiV31alpha { | |
| 41 | + | |
| 42 | + @Operation( | |
| 43 | + requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = CatalogRequestSchema.class))), | |
| 44 | + responses = { @ApiResponse( | |
| 45 | + content = @Content( | |
| 46 | + mediaType = "application/json", | |
| 47 | + schema = @Schema(implementation = CatalogSchema.class) | |
| 48 | + ), | |
| 49 | + description = "Gets contract offers (=catalog) of a single connector") } | |
| 50 | + ) | |
| 51 | + void requestCatalogV31alpha(JsonObject request, @Suspended AsyncResponse response); | |
| 52 | + | |
| 53 | + @Operation( | |
| 54 | + requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = DatasetRequestSchema.class))), | |
| 55 | + responses = { @ApiResponse( | |
| 56 | + content = @Content( | |
| 57 | + mediaType = "application/json", | |
| 58 | + schema = @Schema(implementation = DatasetSchema.class) | |
| 59 | + ), | |
| 60 | + description = "Gets single dataset from a connector") } | |
| 61 | + ) | |
| 62 | + void getDatasetV31alpha(JsonObject request, @Suspended AsyncResponse response); | |
| 63 | + | |
| 64 | + @Schema(name = "CatalogRequest", example = CatalogRequestSchema.CATALOG_REQUEST_EXAMPLE) | |
| 65 | + record CatalogRequestSchema( | |
| 66 | + @Schema(name = CONTEXT, requiredMode = REQUIRED) | |
| 67 | + Object context, | |
| 68 | + @Schema(name = TYPE, example = CATALOG_REQUEST_TYPE) | |
| 69 | + String type, | |
| 70 | + @Schema(requiredMode = REQUIRED) | |
| 71 | + String counterPartyAddress, | |
| 72 | + // Switch to required in the next API iteration | |
| 73 | + @Schema(requiredMode = NOT_REQUIRED) | |
| 74 | + String counterPartyId, | |
| 75 | + @Schema(requiredMode = REQUIRED) | |
| 76 | + String protocol, | |
| 77 | + @Schema(requiredMode = NOT_REQUIRED) | |
| 78 | + List<String> additionalScopes, | |
| 79 | + ApiCoreSchema.QuerySpecSchema querySpec) { | |
| 80 | + | |
| 81 | + public static final String CATALOG_REQUEST_EXAMPLE = """ | |
| 82 | + { | |
| 83 | + "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, | |
| 84 | + "@type": "CatalogRequest", | |
| 85 | + "counterPartyAddress": "http://provider-address", | |
| 86 | + "counterPartyId": "providerId", | |
| 87 | + "protocol": "dataspace-protocol-http", | |
| 88 | + "additionalScopes": [ "org.eclipse.edc.vc.type:SomeCredential:read", "org.eclipse.edc.vc.type:AnotherCredential:write" ], | |
| 89 | + "querySpec": { | |
| 90 | + "offset": 0, | |
| 91 | + "limit": 50, | |
| 92 | + "sortOrder": "DESC", | |
| 93 | + "sortField": "fieldName", | |
| 94 | + "filterExpression": [] | |
| 95 | + } | |
| 96 | + } | |
| 97 | + """; | |
| 98 | + } | |
| 99 | + | |
| 100 | + @Schema(name = "DatasetRequest", example = DatasetRequestSchema.DATASET_REQUEST_EXAMPLE) | |
| 101 | + record DatasetRequestSchema( | |
| 102 | + @Schema(name = TYPE, example = CATALOG_REQUEST_TYPE) | |
| 103 | + String type, | |
| 104 | + String counterPartyAddress, | |
| 105 | + String counterPartyId, | |
| 106 | + String protocol, | |
| 107 | + ApiCoreSchema.QuerySpecSchema querySpec) { | |
| 108 | + | |
| 109 | + public static final String DATASET_REQUEST_EXAMPLE = """ | |
| 110 | + { | |
| 111 | + "@context": { "@vocab": "https://w3id.org/edc/v0.0.1/ns/" }, | |
| 112 | + "@type": "DatasetRequest", | |
| 113 | + "@id": "dataset-id", | |
| 114 | + "counterPartyAddress": "http://counter-party-address", | |
| 115 | + "counterPartyId": "counter-party-id", | |
| 116 | + "protocol": "dataspace-protocol-http" | |
| 117 | + } | |
| 118 | + """; | |
| 119 | + } | |
| 120 | + | |
| 121 | + @Schema(name = "Catalog", description = "DCAT catalog", example = CatalogSchema.CATALOG_EXAMPLE) | |
| 122 | + record CatalogSchema( | |
| 123 | + ) { | |
| 124 | + public static final String CATALOG_EXAMPLE = """ | |
| 125 | + { | |
| 126 | + "@id": "7df65569-8c59-4013-b1c0-fa14f6641bf2", | |
| 127 | + "@type": "dcat:Catalog", | |
| 128 | + "dcat:dataset": { | |
| 129 | + "@id": "bcca61be-e82e-4da6-bfec-9716a56cef35", | |
| 130 | + "@type": "dcat:Dataset", | |
| 131 | + "odrl:hasPolicy": { | |
| 132 | + "@id": "OGU0ZTMzMGMtODQ2ZS00ZWMxLThmOGQtNWQxNWM0NmI2NmY4:YmNjYTYxYmUtZTgyZS00ZGE2LWJmZWMtOTcxNmE1NmNlZjM1:NDY2ZTZhMmEtNjQ1Yy00ZGQ0LWFlZDktMjdjNGJkZTU4MDNj", | |
| 133 | + "@type": "odrl:Set", | |
| 134 | + "odrl:permission": { | |
| 135 | + "odrl:target": "bcca61be-e82e-4da6-bfec-9716a56cef35", | |
| 136 | + "odrl:action": { | |
| 137 | + "odrl:type": "http://www.w3.org/ns/odrl/2/use" | |
| 138 | + }, | |
| 139 | + "odrl:constraint": { | |
| 140 | + "odrl:and": [ | |
| 141 | + { | |
| 142 | + "odrl:leftOperand": "https://w3id.org/edc/v0.0.1/ns/inForceDate", | |
| 143 | + "odrl:operator": { | |
| 144 | + "@id": "odrl:gteq" | |
| 145 | + }, | |
| 146 | + "odrl:rightOperand": "2023-07-07T07:19:58.585601395Z" | |
| 147 | + }, | |
| 148 | + { | |
| 149 | + "odrl:leftOperand": "https://w3id.org/edc/v0.0.1/ns/inForceDate", | |
| 150 | + "odrl:operator": { | |
| 151 | + "@id": "odrl:lteq" | |
| 152 | + }, | |
| 153 | + "odrl:rightOperand": "2023-07-12T07:19:58.585601395Z" | |
| 154 | + } | |
| 155 | + ] | |
| 156 | + } | |
| 157 | + }, | |
| 158 | + "odrl:prohibition": [], | |
| 159 | + "odrl:obligation": [] | |
| 160 | + }, | |
| 161 | + "dcat:distribution": [ | |
| 162 | + { | |
| 163 | + "@type": "dcat:Distribution", | |
| 164 | + "dct:format": { | |
| 165 | + "@id": "HttpData" | |
| 166 | + }, | |
| 167 | + "dcat:accessService": "5e839777-d93e-4785-8972-1005f51cf367" | |
| 168 | + } | |
| 169 | + ], | |
| 170 | + "description": "description", | |
| 171 | + "id": "bcca61be-e82e-4da6-bfec-9716a56cef35" | |
| 172 | + }, | |
| 173 | + "dcat:service": { | |
| 174 | + "@id": "5e839777-d93e-4785-8972-1005f51cf367", | |
| 175 | + "@type": "dcat:DataService", | |
| 176 | + "dct:terms": "connector", | |
| 177 | + "dct:endpointUrl": "http://localhost:16806/protocol" | |
| 178 | + }, | |
| 179 | + "dspace:participantId": "urn:connector:provider", | |
| 180 | + "@context": { | |
| 181 | + "@vocab": "https://w3id.org/edc/v0.0.1/ns/", | |
| 182 | + "dct": "http://purl.org/dc/terms/", | |
| 183 | + "edc": "https://w3id.org/edc/v0.0.1/ns/", | |
| 184 | + "dcat": "http://www.w3.org/ns/dcat#", | |
| 185 | + "odrl": "http://www.w3.org/ns/odrl/2/", | |
| 186 | + "dspace": "https://w3id.org/dspace/v0.8/" | |
| 187 | + } | |
| 188 | + } | |
| 189 | + """; | |
| 190 | + } | |
| 191 | + | |
| 192 | + @Schema(name = "Dataset", description = "DCAT dataset", example = DatasetSchema.DATASET_EXAMPLE) | |
| 193 | + record DatasetSchema( | |
| 194 | + ) { | |
| 195 | + public static final String DATASET_EXAMPLE = """ | |
| 196 | + { | |
| 197 | + "@id": "bcca61be-e82e-4da6-bfec-9716a56cef35", | |
| 198 | + "@type": "dcat:Dataset", | |
| 199 | + "odrl:hasPolicy": { | |
| 200 | + "@id": "OGU0ZTMzMGMtODQ2ZS00ZWMxLThmOGQtNWQxNWM0NmI2NmY4:YmNjYTYxYmUtZTgyZS00ZGE2LWJmZWMtOTcxNmE1NmNlZjM1:NDY2ZTZhMmEtNjQ1Yy00ZGQ0LWFlZDktMjdjNGJkZTU4MDNj", | |
| 201 | + "@type": "odrl:Set", | |
| 202 | + "odrl:permission": { | |
| 203 | + "odrl:target": "bcca61be-e82e-4da6-bfec-9716a56cef35", | |
| 204 | + "odrl:action": { | |
| 205 | + "odrl:type": "http://www.w3.org/ns/odrl/2/use" | |
| 206 | + }, | |
| 207 | + "odrl:constraint": { | |
| 208 | + "odrl:and": [ | |
| 209 | + { | |
| 210 | + "odrl:leftOperand": "https://w3id.org/edc/v0.0.1/ns/inForceDate", | |
| 211 | + "odrl:operator": { | |
| 212 | + "@id": "odrl:gteq" | |
| 213 | + }, | |
| 214 | + "odrl:rightOperand": "2023-07-07T07:19:58.585601395Z" | |
| 215 | + }, | |
| 216 | + { | |
| 217 | + "odrl:leftOperand": "https://w3id.org/edc/v0.0.1/ns/inForceDate", | |
| 218 | + "odrl:operator": { | |
| 219 | + "@id": "odrl:lteq" | |
| 220 | + }, | |
| 221 | + "odrl:rightOperand": "2023-07-12T07:19:58.585601395Z" | |
| 222 | + } | |
| 223 | + ] | |
| 224 | + } | |
| 225 | + }, | |
| 226 | + "odrl:prohibition": [], | |
| 227 | + "odrl:obligation": [], | |
| 228 | + "odrl:target": "bcca61be-e82e-4da6-bfec-9716a56cef35" | |
| 229 | + }, | |
| 230 | + "dcat:distribution": [ | |
| 231 | + { | |
| 232 | + "@type": "dcat:Distribution", | |
| 233 | + "dct:format": { | |
| 234 | + "@id": "HttpData" | |
| 235 | + }, | |
| 236 | + "dcat:accessService": "5e839777-d93e-4785-8972-1005f51cf367" | |
| 237 | + } | |
| 238 | + ], | |
| 239 | + "description": "description", | |
| 240 | + "id": "bcca61be-e82e-4da6-bfec-9716a56cef35", | |
| 241 | + "@context": { | |
| 242 | + "@vocab": "https://w3id.org/edc/v0.0.1/ns/", | |
| 243 | + "dct": "http://purl.org/dc/terms/", | |
| 244 | + "edc": "https://w3id.org/edc/v0.0.1/ns/", | |
| 245 | + "dcat": "http://www.w3.org/ns/dcat#", | |
| 246 | + "odrl": "http://www.w3.org/ns/odrl/2/", | |
| 247 | + "dspace": "https://w3id.org/dspace/v0.8/" | |
| 248 | + } | |
| 249 | + } | |
| 250 | + """; | |
| 251 | + } | |
| 252 | +} |
modified extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/catalog/CatalogApiExtensionTest.java +2 −0
| @@ -16,6 +16,7 @@ | ||
| 16 | 16 | |
| 17 | 17 | import org.eclipse.edc.connector.controlplane.api.management.catalog.v2.CatalogApiV2Controller; |
| 18 | 18 | import org.eclipse.edc.connector.controlplane.api.management.catalog.v3.CatalogApiV3Controller; |
| 19 | +import org.eclipse.edc.connector.controlplane.api.management.catalog.v31alpha.CatalogApiV31AlphaController; | |
| 19 | 20 | import org.eclipse.edc.junit.extensions.DependencyInjectionExtension; |
| 20 | 21 | import org.eclipse.edc.spi.system.ServiceExtensionContext; |
| 21 | 22 | import org.eclipse.edc.validator.spi.JsonObjectValidatorRegistry; |
| @@ -58,5 +59,6 @@ | ||
| 58 | 59 | |
| 59 | 60 | verify(webService).registerResource(any(), isA(CatalogApiV2Controller.class)); |
| 60 | 61 | verify(webService).registerResource(any(), isA(CatalogApiV3Controller.class)); |
| 62 | + verify(webService).registerResource(any(), isA(CatalogApiV31AlphaController.class)); | |
| 61 | 63 | } |
| 62 | 64 | } |
modified extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/catalog/transform/JsonObjectToCatalogRequestTransformerTest.java +54 −0
| @@ -14,6 +14,7 @@ | ||
| 14 | 14 | |
| 15 | 15 | package org.eclipse.edc.connector.controlplane.api.management.catalog.transform; |
| 16 | 16 | |
| 17 | +import com.apicatalog.jsonld.document.JsonDocument; | |
| 17 | 18 | import jakarta.json.Json; |
| 18 | 19 | import jakarta.json.JsonObject; |
| 19 | 20 | import org.eclipse.edc.connector.controlplane.catalog.spi.CatalogRequest; |
| @@ -21,7 +22,11 @@ | ||
| 21 | 22 | import org.eclipse.edc.transform.spi.TransformerContext; |
| 22 | 23 | import org.junit.jupiter.api.Test; |
| 23 | 24 | |
| 25 | +import java.util.List; | |
| 26 | + | |
| 27 | +import static com.apicatalog.jsonld.JsonLd.expand; | |
| 24 | 28 | import static org.assertj.core.api.Assertions.assertThat; |
| 29 | +import static org.eclipse.edc.connector.controlplane.catalog.spi.CatalogRequest.CATALOG_REQUEST_ADDITIONAL_SCOPES; | |
| 25 | 30 | import static org.eclipse.edc.connector.controlplane.catalog.spi.CatalogRequest.CATALOG_REQUEST_COUNTER_PARTY_ADDRESS; |
| 26 | 31 | import static org.eclipse.edc.connector.controlplane.catalog.spi.CatalogRequest.CATALOG_REQUEST_COUNTER_PARTY_ID; |
| 27 | 32 | import static org.eclipse.edc.connector.controlplane.catalog.spi.CatalogRequest.CATALOG_REQUEST_PROTOCOL; |
| @@ -91,6 +96,48 @@ | ||
| 91 | 96 | verify(context).transform(querySpecJson, QuerySpec.class); |
| 92 | 97 | } |
| 93 | 98 | |
| 99 | + @Test | |
| 100 | + void transform_withAdditionalScopes() { | |
| 101 | + var querySpec = QuerySpec.Builder.newInstance().build(); | |
| 102 | + var querySpecJson = Json.createObjectBuilder().build(); | |
| 103 | + when(context.transform(any(), eq(QuerySpec.class))).thenReturn(querySpec); | |
| 104 | + var json = Json.createObjectBuilder() | |
| 105 | + .add(TYPE, CATALOG_REQUEST_TYPE) | |
| 106 | + .add(CATALOG_REQUEST_PROTOCOL, "protocol") | |
| 107 | + .add(CATALOG_REQUEST_COUNTER_PARTY_ADDRESS, "http://provider/url") | |
| 108 | + .add(CATALOG_REQUEST_COUNTER_PARTY_ID, "counterPartyId") | |
| 109 | + .add(CATALOG_REQUEST_QUERY_SPEC, querySpecJson) | |
| 110 | + .add(CATALOG_REQUEST_ADDITIONAL_SCOPES, Json.createArrayBuilder(List.of("scope1", "scope2")).build()) | |
| 111 | + .build(); | |
| 112 | + | |
| 113 | + var result = transformer.transform(getExpanded(json), context); | |
| 114 | + | |
| 115 | + assertThat(result).isNotNull(); | |
| 116 | + assertThat(result.getAdditionalScopes()).containsExactlyInAnyOrder("scope1", "scope2"); | |
| 117 | + verify(context).transform(querySpecJson, QuerySpec.class); | |
| 118 | + } | |
| 119 | + | |
| 120 | + @Test | |
| 121 | + void transform_withAdditionalScopes_singleObject() { | |
| 122 | + var querySpec = QuerySpec.Builder.newInstance().build(); | |
| 123 | + var querySpecJson = Json.createObjectBuilder().build(); | |
| 124 | + when(context.transform(any(), eq(QuerySpec.class))).thenReturn(querySpec); | |
| 125 | + var json = Json.createObjectBuilder() | |
| 126 | + .add(TYPE, CATALOG_REQUEST_TYPE) | |
| 127 | + .add(CATALOG_REQUEST_PROTOCOL, "protocol") | |
| 128 | + .add(CATALOG_REQUEST_COUNTER_PARTY_ADDRESS, "http://provider/url") | |
| 129 | + .add(CATALOG_REQUEST_COUNTER_PARTY_ID, "counterPartyId") | |
| 130 | + .add(CATALOG_REQUEST_QUERY_SPEC, querySpecJson) | |
| 131 | + .add(CATALOG_REQUEST_ADDITIONAL_SCOPES, "scope1") | |
| 132 | + .build(); | |
| 133 | + | |
| 134 | + var result = transformer.transform(getExpanded(json), context); | |
| 135 | + | |
| 136 | + assertThat(result).isNotNull(); | |
| 137 | + assertThat(result.getAdditionalScopes()).containsExactly("scope1"); | |
| 138 | + verify(context).transform(querySpecJson, QuerySpec.class); | |
| 139 | + } | |
| 140 | + | |
| 94 | 141 | @Test |
| 95 | 142 | void transform_shouldHandleEmptyQuerySpec() { |
| 96 | 143 | var json = Json.createObjectBuilder() |
| @@ -106,4 +153,11 @@ | ||
| 106 | 153 | verifyNoInteractions(context); |
| 107 | 154 | } |
| 108 | 155 | |
| 156 | + private JsonObject getExpanded(JsonObject message) { | |
| 157 | + try { | |
| 158 | + return expand(JsonDocument.of(message)).get().asJsonArray().getJsonObject(0); | |
| 159 | + } catch (Exception e) { | |
| 160 | + throw new AssertionError(e); | |
| 161 | + } | |
| 162 | + } | |
| 109 | 163 | } |
added extensions/control-plane/api/management-api/catalog-api/src/test/java/org/eclipse/edc/connector/controlplane/api/management/catalog/v31alpha/CatalogApiV31AlphaControllerTest.java +76 −0
| @@ -0,0 +1,76 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | |
| 3 | + * | |
| 4 | + * This program and the accompanying materials are made available under the | |
| 5 | + * terms of the Apache License, Version 2.0 which is available at | |
| 6 | + * https://www.apache.org/licenses/LICENSE-2.0 | |
| 7 | + * | |
| 8 | + * SPDX-License-Identifier: Apache-2.0 | |
| 9 | + * | |
| 10 | + * Contributors: | |
| 11 | + * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation | |
| 12 | + * | |
| 13 | + */ | |
| 14 | + | |
| 15 | +package org.eclipse.edc.connector.controlplane.api.management.catalog.v31alpha; | |
| 16 | + | |
| 17 | +import jakarta.json.Json; | |
| 18 | +import jakarta.json.JsonObject; | |
| 19 | +import org.eclipse.edc.connector.controlplane.api.management.catalog.BaseCatalogApiControllerTest; | |
| 20 | +import org.eclipse.edc.connector.controlplane.catalog.spi.CatalogRequest; | |
| 21 | +import org.eclipse.edc.spi.response.StatusResult; | |
| 22 | +import org.eclipse.edc.spi.result.Result; | |
| 23 | +import org.eclipse.edc.validator.spi.ValidationResult; | |
| 24 | +import org.junit.jupiter.api.Test; | |
| 25 | +import org.mockito.ArgumentCaptor; | |
| 26 | + | |
| 27 | +import java.util.List; | |
| 28 | + | |
| 29 | +import static io.restassured.RestAssured.given; | |
| 30 | +import static io.restassured.http.ContentType.JSON; | |
| 31 | +import static java.util.concurrent.CompletableFuture.completedFuture; | |
| 32 | +import static org.assertj.core.api.Assertions.assertThat; | |
| 33 | +import static org.mockito.ArgumentMatchers.any; | |
| 34 | +import static org.mockito.ArgumentMatchers.argThat; | |
| 35 | +import static org.mockito.ArgumentMatchers.eq; | |
| 36 | +import static org.mockito.Mockito.verify; | |
| 37 | +import static org.mockito.Mockito.when; | |
| 38 | + | |
| 39 | +class CatalogApiV31AlphaControllerTest extends BaseCatalogApiControllerTest { | |
| 40 | + | |
| 41 | + @Test | |
| 42 | + void requestCatalog_withAdditionalScopes() { | |
| 43 | + var request = CatalogRequest.Builder.newInstance().counterPartyAddress("http://url").build(); | |
| 44 | + when(validatorRegistry.validate(any(), any())).thenReturn(ValidationResult.success()); | |
| 45 | + when(transformerRegistry.transform(argThat(o -> o instanceof JsonObject jo && jo.containsKey(CatalogRequest.CATALOG_REQUEST_ADDITIONAL_SCOPES)), eq(CatalogRequest.class))).thenReturn(Result.success(request)); | |
| 46 | + when(service.requestCatalog(any(), any(), any(), any())).thenReturn(completedFuture(StatusResult.success("{}".getBytes()))); | |
| 47 | + var requestBody = Json.createObjectBuilder() | |
| 48 | + .add(CatalogRequest.CATALOG_REQUEST_PROTOCOL, "any") | |
| 49 | + .add(CatalogRequest.CATALOG_REQUEST_ADDITIONAL_SCOPES, Json.createArrayBuilder(List.of("scope1", "scope2")).build()) | |
| 50 | + .build(); | |
| 51 | + | |
| 52 | + given() | |
| 53 | + .port(port) | |
| 54 | + .contentType(JSON) | |
| 55 | + .body(requestBody) | |
| 56 | + .post(baseUrl() + "/request") | |
| 57 | + .then() | |
| 58 | + .statusCode(200) | |
| 59 | + .contentType(JSON); | |
| 60 | + var captor = ArgumentCaptor.forClass(JsonObject.class); | |
| 61 | + verify(transformerRegistry).transform(captor.capture(), eq(CatalogRequest.class)); | |
| 62 | + | |
| 63 | + var jo = captor.getValue(); | |
| 64 | + assertThat(jo).containsKey(CatalogRequest.CATALOG_REQUEST_ADDITIONAL_SCOPES); | |
| 65 | + } | |
| 66 | + | |
| 67 | + @Override | |
| 68 | + protected String baseUrl() { | |
| 69 | + return "/v3.1alpha/catalog"; | |
| 70 | + } | |
| 71 | + | |
| 72 | + @Override | |
| 73 | + protected Object controller() { | |
| 74 | + return new CatalogApiV31AlphaController(service, transformerRegistry, validatorRegistry); | |
| 75 | + } | |
| 76 | +} | |
| No newline at the end of the file |
modified spi/common/core-spi/src/main/java/org/eclipse/edc/spi/iam/RequestScope.java +2 −3
| @@ -24,11 +24,10 @@ | ||
| 24 | 24 | */ |
| 25 | 25 | public class RequestScope { |
| 26 | 26 | |
| 27 | - private RequestScope() { | |
| 28 | - } | |
| 29 | - | |
| 30 | 27 | private Set<String> scopes = new HashSet<>(); |
| 31 | 28 | |
| 29 | + private RequestScope() { | |
| 30 | + } | |
| 32 | 31 | |
| 33 | 32 | public Set<String> getScopes() { |
| 34 | 33 | return scopes; |
modified spi/control-plane/catalog-spi/src/main/java/org/eclipse/edc/connector/controlplane/catalog/spi/CatalogRequest.java +19 −1
| @@ -18,6 +18,9 @@ | ||
| 18 | 18 | import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; |
| 19 | 19 | import org.eclipse.edc.spi.query.QuerySpec; |
| 20 | 20 | |
| 21 | +import java.util.ArrayList; | |
| 22 | +import java.util.List; | |
| 23 | + | |
| 21 | 24 | import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE; |
| 22 | 25 | |
| 23 | 26 | public class CatalogRequest { |
| @@ -27,7 +30,8 @@ | ||
| 27 | 30 | public static final String CATALOG_REQUEST_COUNTER_PARTY_ADDRESS = EDC_NAMESPACE + "counterPartyAddress"; |
| 28 | 31 | public static final String CATALOG_REQUEST_COUNTER_PARTY_ID = EDC_NAMESPACE + "counterPartyId"; |
| 29 | 32 | public static final String CATALOG_REQUEST_QUERY_SPEC = EDC_NAMESPACE + "querySpec"; |
| 30 | - | |
| 33 | + public static final String CATALOG_REQUEST_ADDITIONAL_SCOPES = EDC_NAMESPACE + "additionalScopes"; | |
| 34 | + private List<String> additionalScopes = new ArrayList<>(); | |
| 31 | 35 | private QuerySpec querySpec; |
| 32 | 36 | private String counterPartyAddress; |
| 33 | 37 | private String counterPartyId; |
| @@ -36,6 +40,10 @@ | ||
| 36 | 40 | private CatalogRequest() { |
| 37 | 41 | } |
| 38 | 42 | |
| 43 | + public List<String> getAdditionalScopes() { | |
| 44 | + return additionalScopes; | |
| 45 | + } | |
| 46 | + | |
| 39 | 47 | public String getCounterPartyAddress() { |
| 40 | 48 | return counterPartyAddress; |
| 41 | 49 | } |
| @@ -85,6 +93,16 @@ | ||
| 85 | 93 | return this; |
| 86 | 94 | } |
| 87 | 95 | |
| 96 | + public Builder additionalScopes(List<String> additionalScopes) { | |
| 97 | + instance.additionalScopes = additionalScopes; | |
| 98 | + return this; | |
| 99 | + } | |
| 100 | + | |
| 101 | + public Builder additionalScope(String additionalScope) { | |
| 102 | + instance.additionalScopes.add(additionalScope); | |
| 103 | + return this; | |
| 104 | + } | |
| 105 | + | |
| 88 | 106 | public CatalogRequest build() { |
| 89 | 107 | return instance; |
| 90 | 108 | } |
modified spi/control-plane/catalog-spi/src/main/java/org/eclipse/edc/connector/controlplane/catalog/spi/CatalogRequestMessage.java +13 −0
| @@ -21,6 +21,9 @@ | ||
| 21 | 21 | import org.eclipse.edc.spi.types.domain.message.RemoteMessage; |
| 22 | 22 | import org.jetbrains.annotations.NotNull; |
| 23 | 23 | |
| 24 | +import java.util.ArrayList; | |
| 25 | +import java.util.Arrays; | |
| 26 | +import java.util.List; | |
| 24 | 27 | import java.util.Objects; |
| 25 | 28 | |
| 26 | 29 | /** |
| @@ -30,6 +33,7 @@ | ||
| 30 | 33 | public class CatalogRequestMessage implements RemoteMessage { |
| 31 | 34 | |
| 32 | 35 | private final Policy policy; |
| 36 | + private List<String> additionalScopes = new ArrayList<>(); | |
| 33 | 37 | private String protocol = "unknown"; |
| 34 | 38 | private String counterPartyAddress; |
| 35 | 39 | private String counterPartyId; |
| @@ -77,6 +81,10 @@ | ||
| 77 | 81 | return policy; |
| 78 | 82 | } |
| 79 | 83 | |
| 84 | + public List<String> getAdditionalScopes() { | |
| 85 | + return additionalScopes; | |
| 86 | + } | |
| 87 | + | |
| 80 | 88 | public static class Builder { |
| 81 | 89 | private final CatalogRequestMessage message; |
| 82 | 90 | |
| @@ -109,6 +117,11 @@ | ||
| 109 | 117 | return this; |
| 110 | 118 | } |
| 111 | 119 | |
| 120 | + public CatalogRequestMessage.Builder additionalScopes(String... additionalScopes) { | |
| 121 | + this.message.additionalScopes = Arrays.asList(additionalScopes); | |
| 122 | + return this; | |
| 123 | + } | |
| 124 | + | |
| 112 | 125 | public CatalogRequestMessage build() { |
| 113 | 126 | Objects.requireNonNull(message.protocol, "protocol"); |
| 114 | 127 |
modified spi/control-plane/control-plane-spi/src/main/java/org/eclipse/edc/connector/controlplane/services/spi/catalog/CatalogService.java +2 −1
| @@ -27,9 +27,10 @@ | ||
| 27 | 27 | * @param counterPartyAddress the url of the provider. |
| 28 | 28 | * @param protocol the protocol id string. |
| 29 | 29 | * @param querySpec the {@link QuerySpec} object. |
| 30 | + * @param additionalScopes optional list of additional scope values that are intended for use with the IAM subsystem | |
| 30 | 31 | * @return the provider's catalog |
| 31 | 32 | */ |
| 32 | - CompletableFuture<StatusResult<byte[]>> requestCatalog(String counterPartyId, String counterPartyAddress, String protocol, QuerySpec querySpec); | |
| 33 | + CompletableFuture<StatusResult<byte[]>> requestCatalog(String counterPartyId, String counterPartyAddress, String protocol, QuerySpec querySpec, String... additionalScopes); | |
| 33 | 34 | |
| 34 | 35 | /** |
| 35 | 36 | * Return the dataset |