From e4fd20c34d0ad5f180b9b490790f081ec4674826 Mon Sep 17 00:00:00 2001 From: eparovyshnaya Date: Fri, 19 Feb 2021 08:38:52 +0300 Subject: [PATCH] Bug 571254 - [Passage][LA] agent state Start designing request-dependent services to empower PassageAgent Signed-off-by: eparovyshnaya --- .../internal/gear/RuntimeConfiguration.java | 10 +++-- .../lac/internal/gear/RuntimeFramework.java | 19 +++----- .../.settings/.api_filters | 15 +++++++ .../internal/lac/base/CannotUseFeature.java | 2 +- .../lac/base/access/RequestKeyKeeper.java | 43 +++++++++++++++++++ .../META-INF/MANIFEST.MF | 3 +- 6 files changed, 73 insertions(+), 19 deletions(-) create mode 100644 bundles/org.eclipse.passage.lac/src/org/eclipse/passage/internal/lac/base/access/RequestKeyKeeper.java diff --git a/bundles/org.eclipse.passage.lac.gear/src/org/eclipse/passage/lac/internal/gear/RuntimeConfiguration.java b/bundles/org.eclipse.passage.lac.gear/src/org/eclipse/passage/lac/internal/gear/RuntimeConfiguration.java index fc6a43eda..9898bbd0f 100644 --- a/bundles/org.eclipse.passage.lac.gear/src/org/eclipse/passage/lac/internal/gear/RuntimeConfiguration.java +++ b/bundles/org.eclipse.passage.lac.gear/src/org/eclipse/passage/lac/internal/gear/RuntimeConfiguration.java @@ -63,6 +63,8 @@ import org.eclipse.passage.lic.internal.equinox.requirements.ComponentRequirements; import org.eclipse.passage.lic.internal.json.JsonConditionTransport; import org.eclipse.passage.lic.internal.licenses.migration.tobemoved.UserFilteringConditionTransport; +import org.eclipse.passage.lic.internal.net.api.handle.NetRequest; +import org.eclipse.passage.lic.internal.net.handle.ProductUserRequest; import org.eclipse.passage.lic.internal.oshi.HardwareAssessmentService; import org.eclipse.passage.lic.internal.oshi.HardwareEnvironment; @@ -82,7 +84,7 @@ public final class RuntimeConfiguration implements AccessCycleConfiguration { private final Registry environments; private final Registry examinators; - public RuntimeConfiguration(Supplier source, Supplier user, Supplier product) { + public RuntimeConfiguration(Supplier source, ProductUserRequest request) { requirements = new ReadOnlyRegistry<>(Arrays.asList(// new BundleRequirements(), // new ComponentRequirements() // @@ -95,10 +97,10 @@ public RuntimeConfiguration(Supplier source, Supplier user, Suppli ); transports = new ReadOnlyRegistry<>(Arrays.asList(// new JsonConditionTransport(), // - new UserFilteringConditionTransport(user) // + new UserFilteringConditionTransport(() -> request.user().get()) // )); - codecs = new ReadOnlyRegistry<>(new BcStreamCodec(product)); - keys = new ReadOnlyRegistry<>(new PathKeyKeeper(product.get(), source)); + codecs = new ReadOnlyRegistry<>(new BcStreamCodec(() -> request.product().get())); + keys = new ReadOnlyRegistry<>(new PathKeyKeeper(request.product().get(), source)); emitters = new ReadOnlyRegistry<>(Arrays.asList(// new BasePermissionEmittingService(// expressionParsers(), // diff --git a/bundles/org.eclipse.passage.lac.gear/src/org/eclipse/passage/lac/internal/gear/RuntimeFramework.java b/bundles/org.eclipse.passage.lac.gear/src/org/eclipse/passage/lac/internal/gear/RuntimeFramework.java index ed2e157b9..b59ad5215 100644 --- a/bundles/org.eclipse.passage.lac.gear/src/org/eclipse/passage/lac/internal/gear/RuntimeFramework.java +++ b/bundles/org.eclipse.passage.lac.gear/src/org/eclipse/passage/lac/internal/gear/RuntimeFramework.java @@ -12,39 +12,32 @@ *******************************************************************************/ package org.eclipse.passage.lac.internal.gear; -import java.util.function.Supplier; - import org.eclipse.passage.lic.internal.api.AccessCycleConfiguration; import org.eclipse.passage.lic.internal.api.Framework; import org.eclipse.passage.lic.internal.api.LicensedProduct; import org.eclipse.passage.lic.internal.api.conditions.mining.LicenseReadingService; import org.eclipse.passage.lic.internal.api.io.UnemployedCodecs; import org.eclipse.passage.lic.internal.base.io.UserHomePath; +import org.eclipse.passage.lic.internal.net.api.handle.NetRequest; import org.eclipse.passage.lic.internal.net.handle.ProductUserRequest; @SuppressWarnings("restriction") final class RuntimeFramework implements Framework { - private final Supplier user; - private final Supplier product; - - public RuntimeFramework(ProductUserRequest request) { - this(request.user()::get, request.product()::get); - } + private final ProductUserRequest request; - public RuntimeFramework(Supplier user, Supplier product) { - this.user = user; - this.product = product; + public RuntimeFramework(ProductUserRequest request) { + this.request = request; } @Override public LicensedProduct product() { - return product.get(); + return request.product().get(); } @Override public AccessCycleConfiguration accessCycleConfiguration() { - return new RuntimeConfiguration(new UserHomePath(), user, product); + return new RuntimeConfiguration(new UserHomePath(), request); } @Override diff --git a/bundles/org.eclipse.passage.lac/.settings/.api_filters b/bundles/org.eclipse.passage.lac/.settings/.api_filters index 9f04831a4..18f0ba270 100644 --- a/bundles/org.eclipse.passage.lac/.settings/.api_filters +++ b/bundles/org.eclipse.passage.lac/.settings/.api_filters @@ -23,4 +23,19 @@ + + + + + + + + + + + + + + + diff --git a/bundles/org.eclipse.passage.lac/src/org/eclipse/passage/internal/lac/base/CannotUseFeature.java b/bundles/org.eclipse.passage.lac/src/org/eclipse/passage/internal/lac/base/CannotUseFeature.java index ac4c10ef9..0bb55ef7b 100644 --- a/bundles/org.eclipse.passage.lac/src/org/eclipse/passage/internal/lac/base/CannotUseFeature.java +++ b/bundles/org.eclipse.passage.lac/src/org/eclipse/passage/internal/lac/base/CannotUseFeature.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2021 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at diff --git a/bundles/org.eclipse.passage.lac/src/org/eclipse/passage/internal/lac/base/access/RequestKeyKeeper.java b/bundles/org.eclipse.passage.lac/src/org/eclipse/passage/internal/lac/base/access/RequestKeyKeeper.java new file mode 100644 index 000000000..cb517de12 --- /dev/null +++ b/bundles/org.eclipse.passage.lac/src/org/eclipse/passage/internal/lac/base/access/RequestKeyKeeper.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2021 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.internal.lac.base.access; + +import java.io.InputStream; + +import org.eclipse.passage.lic.internal.api.LicensedProduct; +import org.eclipse.passage.lic.internal.api.LicensingException; +import org.eclipse.passage.lic.internal.api.io.KeyKeeper; +import org.eclipse.passage.lic.internal.net.api.handle.NetRequest; +import org.eclipse.passage.lic.internal.net.handle.ProductUserRequest; + +final class RequestKeyKeeper implements KeyKeeper { + + // TODO: stated request + private final ProductUserRequest request; + + public RequestKeyKeeper(ProductUserRequest request) { + this.request = request; + } + + @Override + public LicensedProduct id() { + return request.product().get(); + } + + @Override + public InputStream productPublicKey() throws LicensingException { + // TODO: read from request.content or state, if already sent + return null; + } + +} diff --git a/bundles/org.eclipse.passage.lic.api/META-INF/MANIFEST.MF b/bundles/org.eclipse.passage.lic.api/META-INF/MANIFEST.MF index 41329a731..74ac1ccd1 100644 --- a/bundles/org.eclipse.passage.lic.api/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.passage.lic.api/META-INF/MANIFEST.MF @@ -126,7 +126,8 @@ Export-Package: org.eclipse.passage.lic.internal.api; org.eclipse.passage.seal.demo, org.eclipse.passage.lic.bc, org.eclipse.passage.lic.equinox, - org.eclipse.passage.loc.products.core", + org.eclipse.passage.loc.products.core, + org.eclipse.passage.lac", org.eclipse.passage.lic.internal.api.observatory;x-friends:="org.eclipse.passage.lic.base", org.eclipse.passage.lic.internal.api.registry; x-friends:="org.eclipse.passage.lic.base,