Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 571325 - [Passage][Operator] encrypted licenses cannot be issued #666

Merged
merged 4 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundles/org.eclipse.passage.lac.gear/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
Automatic-Module-Name: org.eclipse.passage.lac.seal
Automatic-Module-Name: org.eclipse.passage.lac.gear
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.passage.lac.gear;singleton:=true
Bundle-Version: 0.1.0.qualifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
# Contributors:
# ArSysOp - initial API and implementation
###############################################################################
#Properties file for org.eclipse.passage.ldc
#Properties file for org.eclipse.passage.lac.gear

Bundle-Name = Passage LAC Seal
Bundle-Name = Passage LAC Gear
Bundle-Vendor = Eclipse Passage
Bundle-Copyright = Copyright (c) 2021 ArSysOp and others.\n\
\n\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ public RuntimeConfiguration(Supplier<Path> source, ProductUserRequest<? extends
examinators = new ReadOnlyRegistry<>(Collections.emptyList());
}

final MiningEquipment miningEquipment() {
@Override
public final MiningEquipment miningEquipment() {
return new PersonalLicenseMiningEquipment(keyKeepers(), codecs(), transports());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
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;
Expand All @@ -40,14 +38,4 @@ public AccessCycleConfiguration accessCycleConfiguration() {
return new RuntimeConfiguration(new UserHomePath(), request);
}

@Override
public LicenseReadingService licenseReader() {
throw new UnsupportedOperationException();
}

@Override
public UnemployedCodecs unemployedCodecs() {
throw new UnsupportedOperationException();
}

}
7 changes: 5 additions & 2 deletions bundles/org.eclipse.passage.lic.api/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ Export-Package: org.eclipse.passage.lic.internal.api;
org.eclipse.passage.loc.workbench,
org.eclipse.passage.seal.demo,
org.eclipse.passage.seal.demo.tests,
org.eclipse.passage.lac.gear",
org.eclipse.passage.lac.gear,
org.eclipse.passage.loc.operator.gear",
org.eclipse.passage.lic.internal.api.access;
x-friends:="org.eclipse.passage.lic.base,
org.eclipse.passage.lic.e4.ui,
Expand Down Expand Up @@ -127,7 +128,9 @@ Export-Package: org.eclipse.passage.lic.internal.api;
org.eclipse.passage.lic.bc,
org.eclipse.passage.lic.equinox,
org.eclipse.passage.loc.products.core,
org.eclipse.passage.lac",
org.eclipse.passage.lac,
org.eclipse.passage.loc.api,
org.eclipse.passage.loc.operator.gear",
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.passage.lic.internal.api.conditions.evaluation.PermissionEmittersRegistry;
import org.eclipse.passage.lic.internal.api.conditions.mining.ConditionTransportRegistry;
import org.eclipse.passage.lic.internal.api.conditions.mining.MinedConditionsRegistry;
import org.eclipse.passage.lic.internal.api.conditions.mining.MiningEquipment;
import org.eclipse.passage.lic.internal.api.inspection.RuntimeEnvironmentRegistry;
import org.eclipse.passage.lic.internal.api.io.KeyKeeperRegistry;
import org.eclipse.passage.lic.internal.api.io.StreamCodecRegistry;
Expand All @@ -34,6 +35,8 @@ public interface AccessCycleConfiguration {

MinedConditionsRegistry conditionMiners();

MiningEquipment miningEquipment();

StreamCodecRegistry codecs();

KeyKeeperRegistry keyKeepers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
*******************************************************************************/
package org.eclipse.passage.lic.internal.api;

import org.eclipse.passage.lic.internal.api.conditions.mining.LicenseReadingService;
import org.eclipse.passage.lic.internal.api.io.UnemployedCodecs;

/**
* <p>
* All the framework-relying constructions are to originate from this point this
Expand All @@ -31,18 +28,11 @@
* <li>event bus</li>
* </ul>
* <p>
* <p>
* Two implementation is currently planned: Equinox-based and Spring based.
* </p>
*/
public interface Framework {

LicensedProduct product();

AccessCycleConfiguration accessCycleConfiguration();

LicenseReadingService licenseReader();

UnemployedCodecs unemployedCodecs();

}
5 changes: 3 additions & 2 deletions bundles/org.eclipse.passage.lic.bc/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Automatic-Module-Name: org.eclipse.passage.lic.bc
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.passage.lic.bc
Bundle-Version: 1.0.100.qualifier
Bundle-Version: 1.0.200.qualifier
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
Bundle-Copyright: %Bundle-Copyright
Expand All @@ -18,4 +18,5 @@ Export-Package: org.eclipse.passage.lic.internal.bc;
x-friends:="org.eclipse.passage.lbc.base.tests,
org.eclipse.passage.lbc.base,
org.eclipse.passage.lic.hc.tests,
org.eclipse.passage.seal.demo"
org.eclipse.passage.seal.demo,
org.eclipse.passage.loc.operator.gear"
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.eclipse.passage.lic.internal.api.ServiceInvocationResult;
import org.eclipse.passage.lic.internal.api.conditions.mining.LicenseReadingService;
import org.eclipse.passage.lic.internal.base.BaseServiceInvocationResult;
import org.eclipse.passage.lic.internal.base.conditions.mining.BaseLicenseReadingService;

public final class LicenseReadingServiceRequest implements Supplier<ServiceInvocationResult<LicenseReadingService>> {

Expand All @@ -32,7 +33,12 @@ public LicenseReadingServiceRequest(FrameworkAware<?> delegate) {

@Override
public ServiceInvocationResult<LicenseReadingService> get() {
return delegate.withFrameworkService(framework -> new BaseServiceInvocationResult<>(framework.licenseReader()));
return delegate.withFrameworkService(framework -> new BaseServiceInvocationResult<>(//
new BaseLicenseReadingService(//
framework.product(), //
framework.accessCycleConfiguration().miningEquipment()//
)//
));
}

}
6 changes: 4 additions & 2 deletions bundles/org.eclipse.passage.loc.api/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ Export-Package: org.eclipse.passage.loc.internal.api;
org.eclipse.passage.loc.licenses.core,
org.eclipse.passage.loc.products.core,
org.eclipse.passage.loc.features.core,
org.eclipse.passage.loc.users.core",
org.eclipse.passage.loc.users.core,
org.eclipse.passage.loc.operator.gear",
org.eclipse.passage.loc.internal.emf;
x-friends:="org.eclipse.passage.loc.licenses.core,
org.eclipse.passage.loc.edit.ui,
org.eclipse.passage.loc.products.core,
org.eclipse.passage.loc.features.core,
org.eclipse.passage.loc.users.core,
org.eclipse.passage.loc.workbench,
org.eclipse.passage.loc.dashboard.ui"
org.eclipse.passage.loc.dashboard.ui",
org.eclipse.passage.loc.internal.equinox;x-friends:="org.eclipse.passage.loc.products.core,org.eclipse.passage.loc.licenses.core"
Require-Bundle: org.eclipse.e4.core.services;bundle-version="0.0.0",
org.eclipse.emf.edit;bundle-version="0.0.0",
org.eclipse.equinox.common;bundle-version="0.0.0";visibility:=reexport,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020 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
Expand All @@ -10,14 +10,13 @@
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
package org.eclipse.passage.lic.internal.api.io;

import java.util.function.Supplier;
package org.eclipse.passage.loc.internal.api;

import org.eclipse.passage.lic.internal.api.LicensedProduct;
import org.eclipse.passage.lic.internal.api.io.StreamCodec;

public interface UnemployedCodecs {
public interface OperatorGear {

StreamCodec employFor(Supplier<LicensedProduct> product);
StreamCodec codec(LicensedProduct product);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*******************************************************************************
* 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.loc.internal.api;

public interface OperatorGearSupplier {

OperatorGear gear();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*******************************************************************************
* 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.loc.internal.equinox;

import java.util.Collection;
import java.util.Collections;
import java.util.Optional;
import java.util.function.Function;

import org.eclipse.passage.loc.internal.api.OperatorGear;
import org.eclipse.passage.loc.internal.api.OperatorGearSupplier;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;

public final class OperatorGearAware {

public <T> Optional<T> withGear(Function<OperatorGear, Optional<T>> with) {
BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
Collection<ServiceReference<OperatorGearSupplier>> references = Collections.emptyList();
try {
references = context.getServiceReferences(OperatorGearSupplier.class, null);
} catch (InvalidSyntaxException e) {
return Optional.empty();
}
if (references.isEmpty()) {
return Optional.empty();
}
ServiceReference<OperatorGearSupplier> any = references.iterator().next();
try {
return with.apply(context.getService(any).gear());
} finally {
context.ungetService(any);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.eclipse.passage.lic.internal.base.io.FileNameFromLicensedProduct;
import org.eclipse.passage.lic.internal.base.io.PassageFileExtension;
import org.eclipse.passage.lic.internal.base.io.UserHomeProductResidence;
import org.eclipse.passage.loc.internal.api.CodecSupplier;
import org.eclipse.passage.loc.internal.equinox.OperatorGearAware;
import org.eclipse.passage.loc.internal.licenses.core.i18n.LicensesCoreMessages;

final class PersistedEncoded {
Expand Down Expand Up @@ -68,7 +68,8 @@ private Path key() throws LicensingException {
}

private StreamCodec codec() throws LicensingException {
Optional<StreamCodec> codec = new CodecSupplier(product).get();
Optional<StreamCodec> codec = new OperatorGearAware()
.withGear(gear -> Optional.ofNullable(gear.codec(product)));
if (!codec.isPresent()) {
throw new LicensingException(
String.format(LicensesCoreMessages.LicenseOperatorServiceImpl_w_no_encoding, decrypted));
Expand Down
7 changes: 7 additions & 0 deletions bundles/org.eclipse.passage.loc.operator.gear/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
39 changes: 39 additions & 0 deletions bundles/org.eclipse.passage.loc.operator.gear/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.passage.loc.operator.gear</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
</natures>
</projectDescription>
Loading