diff --git a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/io/EncryptionKeySize.java b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/io/EncryptionKeySize.java index b9c5ee8fe..e2c0afe67 100644 --- a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/io/EncryptionKeySize.java +++ b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/io/EncryptionKeySize.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2022 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -23,7 +23,7 @@ public abstract class EncryptionKeySize { public EncryptionKeySize(int size) { if (size <= 0) { - throw new IllegalArgumentException("EncryptionKeySize::size must be positiv"); //$NON-NLS-1$ + throw new IllegalArgumentException("EncryptionKeySize::size must be positive"); //$NON-NLS-1$ } this.size = size; } diff --git a/bundles/org.eclipse.passage.lic.base/META-INF/MANIFEST.MF b/bundles/org.eclipse.passage.lic.base/META-INF/MANIFEST.MF index 0a6435299..f636b3ebb 100644 --- a/bundles/org.eclipse.passage.lic.base/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.passage.lic.base/META-INF/MANIFEST.MF @@ -30,4 +30,5 @@ Export-Package: org.eclipse.passage.lic.base, org.eclipse.passage.lic.internal.base.inspection.hardware;x-friends:="org.eclipse.passage.loc.licenses.core,org.eclipse.passage.lic.oshi", org.eclipse.passage.lic.internal.base.logging;x-friends:="org.eclipse.passage.lic.jetty", org.eclipse.passage.lic.internal.base.observatory;x-internal:=true, + org.eclipse.passage.lic.internal.base.requirements;x-internal:=true, org.eclipse.passage.lic.internal.base.time;x-friends:="org.eclipse.passage.lic.base.tests" diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Library.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Library.java index dfd99eae1..03c248692 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Library.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Library.java @@ -86,9 +86,15 @@ public interface Library extends PassageLicenseCoverage { ServiceInvocationResult assess(); /** + *

* For a given {@code agreement} a library should perform an analysis if this * agreement is demanded by it, and in this case supply an instance and * {@linkplain AgreementAcceptanceService} for acceptance. + *

+ *

+ * If the {@code agreement} does not belong to the library, report empty result + * with bearable diagnostic of {@linkplain ForeignLicense} trouble code. + *

*/ ServiceInvocationResult agreementsService(AgreementToAccept agreement); diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/requirements/FilteredRequirements.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/requirements/FilteredRequirements.java similarity index 97% rename from bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/requirements/FilteredRequirements.java rename to bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/requirements/FilteredRequirements.java index ba09b7e5a..d3a13a9be 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/requirements/FilteredRequirements.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/requirements/FilteredRequirements.java @@ -10,7 +10,7 @@ * Contributors: * ArSysOp - initial API and implementation *******************************************************************************/ -package org.eclipse.passage.lic.internal.requirements; +package org.eclipse.passage.lic.internal.base.requirements; import java.util.Collection; import java.util.Objects; diff --git a/bundles/org.eclipse.passage.lic.e4.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.passage.lic.e4.ui/META-INF/MANIFEST.MF index 9e86d0fc5..5a4210fc5 100644 --- a/bundles/org.eclipse.passage.lic.e4.ui/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.passage.lic.e4.ui/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.passage.lic.e4.ui Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.passage.lic.e4.ui -Bundle-Version: 2.1.0.qualifier +Bundle-Version: 2.2.0.qualifier Bundle-Vendor: %Bundle-Vendor Bundle-Copyright: %Bundle-Copyright Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/bundles/org.eclipse.passage.lic.e4.ui/src/org/eclipse/passage/lic/e4/ui/addons/E4LicensingAddon.java b/bundles/org.eclipse.passage.lic.e4.ui/src/org/eclipse/passage/lic/e4/ui/addons/E4LicensingAddon.java index a6584826b..0f3a01f73 100644 --- a/bundles/org.eclipse.passage.lic.e4.ui/src/org/eclipse/passage/lic/e4/ui/addons/E4LicensingAddon.java +++ b/bundles/org.eclipse.passage.lic.e4.ui/src/org/eclipse/passage/lic/e4/ui/addons/E4LicensingAddon.java @@ -19,12 +19,15 @@ import org.eclipse.e4.ui.di.UIEventTopic; import org.eclipse.e4.ui.workbench.UIEvents; import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.passage.lic.api.Framework; +import org.eclipse.passage.lic.api.LicensedProduct; import org.eclipse.passage.lic.api.ServiceInvocationResult; import org.eclipse.passage.lic.api.access.GrantLockAttempt; import org.eclipse.passage.lic.base.diagnostic.DiagnosticExplained; import org.eclipse.passage.lic.base.restrictions.ExaminationExplained; import org.eclipse.passage.lic.equinox.EquinoxPassage; import org.eclipse.passage.lic.equinox.LicensedProductFromContext; +import org.eclipse.passage.lic.equinox.SuppliedFrameworkAware; import org.eclipse.passage.lic.internal.e4.ui.restrictions.WorkbenchShutdown; import org.eclipse.passage.lic.jface.EquinoxPassageUI; import org.eclipse.swt.widgets.Shell; @@ -52,8 +55,7 @@ public void applicationStarted(// @UIEventTopic(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE) // Event event) { ServiceInvocationResult response = // - new EquinoxPassageUI(this::shell) - .acquireLicense(new LicensedProductFromContext(application).get().identifier()); + new EquinoxPassageUI(this::shell).acquireLicense(product().identifier()); if (grantAcquired(response)) { grant = response.data(); } else { @@ -63,6 +65,11 @@ public void applicationStarted(// } } + private LicensedProduct product() { + return new SuppliedFrameworkAware().withFramework(Framework::product)// + .orElseGet(new LicensedProductFromContext(application)); + } + @Inject @Optional public void applicationFainted(// diff --git a/bundles/org.eclipse.passage.lic.execute/.settings/.api_filters b/bundles/org.eclipse.passage.lic.execute/.settings/.api_filters index bbec12fcb..b61d39987 100644 --- a/bundles/org.eclipse.passage.lic.execute/.settings/.api_filters +++ b/bundles/org.eclipse.passage.lic.execute/.settings/.api_filters @@ -9,4 +9,13 @@ + + + + + + + + + diff --git a/bundles/org.eclipse.passage.lic.execute/META-INF/MANIFEST.MF b/bundles/org.eclipse.passage.lic.execute/META-INF/MANIFEST.MF index 192af854e..484c05c78 100644 --- a/bundles/org.eclipse.passage.lic.execute/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.passage.lic.execute/META-INF/MANIFEST.MF @@ -10,12 +10,12 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Require-Bundle: org.apache.logging.log4j;bundle-version="2.17.1", org.eclipse.osgi.services;bundle-version="0.0.0", - org.eclipse.passage.lic.api;bundle-version="2.3.0", - org.eclipse.passage.lic.base;bundle-version="2.3.0", - org.eclipse.passage.lic.bc;bundle-version="1.2.1", - org.eclipse.passage.lic.equinox;bundle-version="2.3.0", - org.eclipse.passage.lic.hc;bundle-version="1.2.1", - org.eclipse.passage.lic.licenses;bundle-version="2.3.0", - org.eclipse.passage.lic.licenses.model;bundle-version="2.3.0", - org.eclipse.passage.lic.oshi;bundle-version="1.2.1" + org.eclipse.passage.lic.api;bundle-version="0.0.0", + org.eclipse.passage.lic.base;bundle-version="0.0.0", + org.eclipse.passage.lic.bc;bundle-version="0.0.0", + org.eclipse.passage.lic.equinox;bundle-version="0.0.0", + org.eclipse.passage.lic.hc;bundle-version="0.0.0", + org.eclipse.passage.lic.licenses;bundle-version="0.0.0", + org.eclipse.passage.lic.licenses.model;bundle-version="0.0.0", + org.eclipse.passage.lic.oshi;bundle-version="0.0.0" Export-Package: org.eclipse.passage.lic.execute diff --git a/bundles/org.eclipse.passage.lic.execute/src/org/eclipse/passage/lic/execute/BundleRequirementsForNamespace.java b/bundles/org.eclipse.passage.lic.execute/src/org/eclipse/passage/lic/execute/BundleRequirementsForNamespace.java new file mode 100644 index 000000000..5ecdf71de --- /dev/null +++ b/bundles/org.eclipse.passage.lic.execute/src/org/eclipse/passage/lic/execute/BundleRequirementsForNamespace.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2022 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.lic.execute; + +import org.eclipse.passage.lic.api.registry.Registry; +import org.eclipse.passage.lic.api.registry.StringServiceId; +import org.eclipse.passage.lic.api.requirements.Requirement; +import org.eclipse.passage.lic.api.requirements.ResolvedRequirements; +import org.eclipse.passage.lic.api.requirements.ResolvedRequirementsRegistry; +import org.eclipse.passage.lic.base.registry.ReadOnlyRegistry; +import org.eclipse.passage.lic.equinox.requirements.BundleRequirements; +import org.eclipse.passage.lic.internal.base.requirements.FilteredRequirements; + +@SuppressWarnings("restriction") +final class BundleRequirementsForNamespace implements ResolvedRequirementsRegistry { + + private final String namespace; + private final Registry delegate; + + BundleRequirementsForNamespace(String namespace) { + this.namespace = namespace; + this.delegate = new ReadOnlyRegistry<>(// + new FilteredRequirements(// + new BundleRequirements(), // + this::declaredInNamespace// + )); + } + + @Override + public Registry get() { + return delegate; + } + + private boolean declaredInNamespace(Requirement requirement) { + return requirement.feature().identifier().startsWith(namespace); + } + +} diff --git a/bundles/org.eclipse.passage.lic.execute/src/org/eclipse/passage/lic/execute/NamespaceConfiguraton.java b/bundles/org.eclipse.passage.lic.execute/src/org/eclipse/passage/lic/execute/NamespaceConfiguraton.java new file mode 100644 index 000000000..929d611f4 --- /dev/null +++ b/bundles/org.eclipse.passage.lic.execute/src/org/eclipse/passage/lic/execute/NamespaceConfiguraton.java @@ -0,0 +1,139 @@ +/******************************************************************************* + * Copyright (c) 2022 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.lic.execute; + +import java.util.function.Supplier; + +import org.eclipse.passage.lic.api.AccessCycleConfiguration; +import org.eclipse.passage.lic.api.LicensedProduct; +import org.eclipse.passage.lic.api.acquire.GrantsTraceService; +import org.eclipse.passage.lic.api.acquire.LicenseAcquisitionServicesRegistry; +import org.eclipse.passage.lic.api.agreements.AgreementAcceptanceService; +import org.eclipse.passage.lic.api.conditions.evaluation.ExpressionEvaluatorsRegistry; +import org.eclipse.passage.lic.api.conditions.evaluation.ExpressionPasringRegistry; +import org.eclipse.passage.lic.api.conditions.evaluation.ExpressionTokenAssessorsRegistry; +import org.eclipse.passage.lic.api.conditions.evaluation.PermissionEmittersRegistry; +import org.eclipse.passage.lic.api.conditions.mining.ConditionTransportRegistry; +import org.eclipse.passage.lic.api.conditions.mining.MinedConditionsRegistry; +import org.eclipse.passage.lic.api.conditions.mining.MiningEquipment; +import org.eclipse.passage.lic.api.inspection.RuntimeEnvironmentRegistry; +import org.eclipse.passage.lic.api.io.HashesRegistry; +import org.eclipse.passage.lic.api.io.KeyKeeperRegistry; +import org.eclipse.passage.lic.api.io.StreamCodecRegistry; +import org.eclipse.passage.lic.api.requirements.ResolvedRequirementsRegistry; +import org.eclipse.passage.lic.api.restrictions.PermissionsExaminationServicesRegistry; +import org.osgi.framework.Bundle; + +/** + * @since 2.3 + */ +@SuppressWarnings("restriction") +public final class NamespaceConfiguraton implements AccessCycleConfiguration { + + private final AccessCycleConfiguration delegate; + private final BundleRequirementsForNamespace requirements; + + public NamespaceConfiguraton(String namespace, Supplier product, Supplier bundle) { + this(new FocusedAccessCycleConfiguration.Wide(product, bundle), new BundleRequirementsForNamespace(namespace)); + } + + public NamespaceConfiguraton(String namespace, AccessCycleConfiguration delegate) { + this(delegate, new BundleRequirementsForNamespace(namespace)); + } + + public NamespaceConfiguraton(AccessCycleConfiguration delegate, BundleRequirementsForNamespace requirements) { + this.delegate = delegate; + this.requirements = requirements; + } + + @Override + public ResolvedRequirementsRegistry requirementResolvers() { + return requirements; + } + + @Override + public MinedConditionsRegistry conditionMiners() { + return delegate.conditionMiners(); + } + + @Override + public MiningEquipment miningEquipment() { + return delegate.miningEquipment(); + } + + @Override + public StreamCodecRegistry codecs() { + return delegate.codecs(); + } + + @Override + public KeyKeeperRegistry keyKeepers() { + return delegate.keyKeepers(); + } + + @Override + public ConditionTransportRegistry transports() { + return delegate.transports(); + } + + @Override + public PermissionEmittersRegistry permissionEmitters() { + return delegate.permissionEmitters(); + } + + @Override + public ExpressionPasringRegistry expressionParsers() { + return delegate.expressionParsers(); + } + + @Override + public ExpressionEvaluatorsRegistry expressionEvaluators() { + return delegate.expressionEvaluators(); + } + + @Override + public ExpressionTokenAssessorsRegistry expressionAssessors() { + return delegate.expressionAssessors(); + } + + @Override + public RuntimeEnvironmentRegistry environments() { + return delegate.environments(); + } + + @Override + public PermissionsExaminationServicesRegistry examinators() { + return delegate.examinators(); + } + + @Override + public LicenseAcquisitionServicesRegistry acquirers() { + return delegate.acquirers(); + } + + @Override + public HashesRegistry hashes() { + return delegate.hashes(); + } + + @Override + public AgreementAcceptanceService acceptance() { + return delegate.acceptance(); + } + + @Override + public GrantsTraceService grantsTrace() { + return delegate.grantsTrace(); + } + +}