Skip to content

Commit

Permalink
Merge pull request #552 from eclipse-passage/568792
Browse files Browse the repository at this point in the history
Bug 568792 extend access cycle with a grant acquiring and release
  • Loading branch information
eparovyshnaya authored Nov 14, 2020
2 parents 2de94db + dc965fb commit b186533
Show file tree
Hide file tree
Showing 18 changed files with 236 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.passage.lic.internal.api;

import org.eclipse.passage.lic.internal.api.acquire.LicenseAcquisitionServicesRegistry;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionEvaluatorsRegistry;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionPasringRegistry;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionTokenAssessorsRegistry;
Expand Down Expand Up @@ -51,4 +52,6 @@ public interface AccessCycleConfiguration {

PermissionsExaminationServicesRegistry examinators();

LicenseAcquisitionServicesRegistry acquirers();

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.eclipse.passage.lic.internal.api.conditions.mining.ConditionMiningTarget;
import org.eclipse.passage.lic.internal.api.registry.Registry;

public interface LicenseAcquisitionServiceRegistry
public interface LicenseAcquisitionServicesRegistry
extends Supplier<Registry<ConditionMiningTarget, LicenseAcquisitionService>> {

}
2 changes: 1 addition & 1 deletion bundles/org.eclipse.passage.lic.base/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Export-Package: org.eclipse.passage.lic.internal.base;
org.eclipse.passage.loc.licenses.core,
org.eclipse.passage.lic.net",
org.eclipse.passage.lic.internal.base.access;x-internal:=true,
org.eclipse.passage.lic.internal.base.acquire;x-friends:="org.eclipse.passage.lic.floating.model",
org.eclipse.passage.lic.internal.base.acquire;x-friends:="org.eclipse.passage.lic.floating.model,org.eclipse.passage.lic.equinox",
org.eclipse.passage.lic.internal.base.conditions;
x-friends:="org.eclipse.passage.lbc.base,
org.eclipse.passage.lic.json,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*******************************************************************************
* Copyright (c) 2020 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.internal.base.acquire;

import java.util.Date;

import org.eclipse.passage.lic.internal.api.LicensedProduct;
import org.eclipse.passage.lic.internal.api.ServiceInvocationResult;
import org.eclipse.passage.lic.internal.api.acquire.GrantAcqisition;
import org.eclipse.passage.lic.internal.api.acquire.LicenseAcquisitionService;
import org.eclipse.passage.lic.internal.base.BaseServiceInvocationResult;

// FIXME: just stub for now. Implement properly. #568791
public abstract class LocalLicenseAcquisitionService implements LicenseAcquisitionService {

@Override
public final ServiceInvocationResult<GrantAcqisition> acquire(LicensedProduct product, String feature) {
return new BaseServiceInvocationResult<>(//
new BaseGrantAcquisition(//
"local", //$NON-NLS-1$
"temp", //$NON-NLS-1$
feature, //
"user", //$NON-NLS-1$
new Date())//
);
}

@Override
public final ServiceInvocationResult<Boolean> release(LicensedProduct product, GrantAcqisition acquisition) {
return new BaseServiceInvocationResult<>(Boolean.TRUE);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*******************************************************************************
* Copyright (c) 2020 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.internal.base.acquire;

import org.eclipse.passage.lic.internal.api.conditions.mining.ConditionMiningTarget;
import org.eclipse.passage.lic.internal.base.conditions.mining.UserHomeMiningTarget;

public final class UserHomeLicenseAcquisitionService extends LocalLicenseAcquisitionService {

@Override
public ConditionMiningTarget id() {
return new UserHomeMiningTarget().get();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2020 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.internal.base.conditions.mining;

import java.util.function.Supplier;

import org.eclipse.passage.lic.internal.api.conditions.mining.ConditionMiningTarget;

public final class UserHomeMiningTarget implements Supplier<ConditionMiningTarget> {

@Override
public ConditionMiningTarget get() {
return new ConditionMiningTarget.Local().child("user-home-conditions"); //$NON-NLS-1$
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.function.Supplier;

import org.eclipse.passage.lic.internal.api.LicensedProduct;
import org.eclipse.passage.lic.internal.api.conditions.mining.ConditionMiningTarget;
import org.eclipse.passage.lic.internal.base.io.LicensingFolder;
import org.eclipse.passage.lic.internal.base.io.PathFromLicensedProduct;
import org.eclipse.passage.lic.internal.base.io.UserHomePath;
Expand All @@ -28,7 +27,7 @@
public final class UserHomeResidentConditions extends LocalConditions {

public UserHomeResidentConditions(MiningEquipment equipment) {
super(new ConditionMiningTarget.Local().child("user-home-conditions"), equipment); //$NON-NLS-1$
super(new UserHomeMiningTarget().get(), equipment);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Require-Bundle: org.eclipse.osgi;bundle-version="0.0.0";visibility:=reexport,
org.eclipse.passage.lic.api;bundle-version="1.0.0";visibility:=reexport,
org.eclipse.passage.lic.base;bundle-version="1.0.0";visibility:=reexport
Export-Package: org.eclipse.passage.lic.internal.equinox;x-internal:=true,
org.eclipse.passage.lic.internal.equinox.acquire;x-internal:=true,
org.eclipse.passage.lic.internal.equinox.conditions;x-internal:=true,
org.eclipse.passage.lic.internal.equinox.events;
x-friends:="org.eclipse.passage.loc.features.core,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2020 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.internal.equinox.acquire;

import org.eclipse.passage.lic.internal.api.conditions.mining.ConditionMiningTarget;
import org.eclipse.passage.lic.internal.base.acquire.LocalLicenseAcquisitionService;
import org.eclipse.passage.lic.internal.equinox.conditions.ConfigurationMiningTarget;

public final class ConfigurationLicenseAcquisitionService extends LocalLicenseAcquisitionService {

@Override
public ConditionMiningTarget id() {
return new ConfigurationMiningTarget().get();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2020 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.internal.equinox.acquire;

import org.eclipse.passage.lic.internal.api.conditions.mining.ConditionMiningTarget;
import org.eclipse.passage.lic.internal.base.acquire.LocalLicenseAcquisitionService;
import org.eclipse.passage.lic.internal.equinox.conditions.InstallationMiningTarget;

public final class InstallationLicenseAcquisitionService extends LocalLicenseAcquisitionService {

@Override
public ConditionMiningTarget id() {
return new InstallationMiningTarget().get();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2020 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.internal.equinox.conditions;

import java.util.function.Supplier;

import org.eclipse.passage.lic.internal.api.conditions.mining.ConditionMiningTarget;

public final class ConfigurationMiningTarget implements Supplier<ConditionMiningTarget> {

@Override
public ConditionMiningTarget get() {
return new ConditionMiningTarget.Local().child("configuration-conditions"); //$NON-NLS-1$
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.function.Supplier;

import org.eclipse.passage.lic.internal.api.LicensedProduct;
import org.eclipse.passage.lic.internal.api.conditions.mining.ConditionMiningTarget;
import org.eclipse.passage.lic.internal.base.conditions.mining.LocalConditions;
import org.eclipse.passage.lic.internal.base.conditions.mining.MiningEquipment;
import org.eclipse.passage.lic.internal.base.io.LicensingFolder;
Expand All @@ -31,7 +30,7 @@
public final class ConfigurationResidentConditions extends LocalConditions {

public ConfigurationResidentConditions(MiningEquipment equipment) {
super(new ConditionMiningTarget.Local().child("configuration-conditions"), equipment); //$NON-NLS-1$
super(new ConfigurationMiningTarget().get(), equipment);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2020 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.internal.equinox.conditions;

import java.util.function.Supplier;

import org.eclipse.passage.lic.internal.api.conditions.mining.ConditionMiningTarget;

public final class InstallationMiningTarget implements Supplier<ConditionMiningTarget> {

@Override
public ConditionMiningTarget get() {
return new ConditionMiningTarget.Local().child("installation-conditions"); //$NON-NLS-1$
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.function.Supplier;

import org.eclipse.passage.lic.internal.api.LicensedProduct;
import org.eclipse.passage.lic.internal.api.conditions.mining.ConditionMiningTarget;
import org.eclipse.passage.lic.internal.base.conditions.mining.LocalConditions;
import org.eclipse.passage.lic.internal.base.conditions.mining.MiningEquipment;
import org.eclipse.passage.lic.internal.base.io.LicensingFolder;
Expand All @@ -31,7 +30,7 @@
public final class InstallationResidentConditions extends LocalConditions {

public InstallationResidentConditions(MiningEquipment equipment) {
super(new ConditionMiningTarget.Local().child("installation-conditions"), equipment); //$NON-NLS-1$
super(new InstallationMiningTarget().get(), equipment); // $NON-NLS-1$
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion bundles/org.eclipse.passage.lic.hc/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ Require-Bundle: org.apache.httpcomponents.httpcore;bundle-version="0.0.0",
org.eclipse.passage.lic.floating.model;bundle-version="0.1.0",
org.eclipse.emf.ecore.xmi;bundle-version="2.16.0"
Export-Package: org.eclipse.passage.lic.internal.hc.remote;x-internal:=true,
org.eclipse.passage.lic.internal.hc.remote.impl;x-internal:=true
org.eclipse.passage.lic.internal.hc.remote.impl;x-internal:=true,
org.eclipse.passage.lic.internal.hc.remote.impl.acquire;x-internal:=true,
org.eclipse.passage.lic.internal.hc.remote.impl.mine;x-internal:=true
Bundle-ActivationPolicy: lazy
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
import org.eclipse.passage.lic.internal.api.io.StreamCodecRegistry;
import org.eclipse.passage.lic.internal.hc.remote.impl.RemoteServiceData;

public final class RemoteAcquiringService implements LicenseAcquisitionService {
public final class RemoteAcquisitionService implements LicenseAcquisitionService {

private final KeyKeeperRegistry keys;
private final StreamCodecRegistry codecs;
private final ConditionMiningTarget target = new ConditionMiningTarget.Remote();

protected RemoteAcquiringService(KeyKeeperRegistry keys, StreamCodecRegistry codecs) {
public RemoteAcquisitionService(KeyKeeperRegistry keys, StreamCodecRegistry codecs) {
this.keys = keys;
this.codecs = codecs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import org.eclipse.passage.lic.internal.api.AccessCycleConfiguration;
import org.eclipse.passage.lic.internal.api.LicensedProduct;
import org.eclipse.passage.lic.internal.api.acquire.LicenseAcquisitionService;
import org.eclipse.passage.lic.internal.api.acquire.LicenseAcquisitionServicesRegistry;
import org.eclipse.passage.lic.internal.api.conditions.EvaluationType;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionEvaluationService;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionEvaluatorsRegistry;
Expand Down Expand Up @@ -45,6 +47,7 @@
import org.eclipse.passage.lic.internal.api.requirements.ResolvedRequirementsRegistry;
import org.eclipse.passage.lic.internal.api.restrictions.PermissionsExaminationService;
import org.eclipse.passage.lic.internal.api.restrictions.PermissionsExaminationServicesRegistry;
import org.eclipse.passage.lic.internal.base.acquire.UserHomeLicenseAcquisitionService;
import org.eclipse.passage.lic.internal.base.conditions.evaluation.BasePermissionEmittingService;
import org.eclipse.passage.lic.internal.base.conditions.evaluation.BerlinProtocolExpressionParseService;
import org.eclipse.passage.lic.internal.base.conditions.evaluation.MunichProtocolExpressionParseService;
Expand All @@ -54,6 +57,8 @@
import org.eclipse.passage.lic.internal.base.registry.ReadOnlyRegistry;
import org.eclipse.passage.lic.internal.base.restrictions.BasePermissionsExaminationService;
import org.eclipse.passage.lic.internal.bc.BcStreamCodec;
import org.eclipse.passage.lic.internal.equinox.acquire.ConfigurationLicenseAcquisitionService;
import org.eclipse.passage.lic.internal.equinox.acquire.InstallationLicenseAcquisitionService;
import org.eclipse.passage.lic.internal.equinox.conditions.ConfigurationResidentConditions;
import org.eclipse.passage.lic.internal.equinox.conditions.InstallationResidentConditions;
import org.eclipse.passage.lic.internal.equinox.io.BundleKeyKeeper;
Expand All @@ -80,6 +85,7 @@ final class SealedAccessCycleConfiguration implements AccessCycleConfiguration {
private final Registry<EvaluationType, ExpressionTokenAssessmentService> tokenAssessors;
private final Registry<EvaluationType, RuntimeEnvironment> environments;
private final Registry<StringServiceId, PermissionsExaminationService> examinators;
private final Registry<ConditionMiningTarget, LicenseAcquisitionService> acquirers;

SealedAccessCycleConfiguration(Supplier<LicensedProduct> product) {
requirements = new ReadOnlyRegistry<>(Arrays.asList(//
Expand Down Expand Up @@ -124,6 +130,12 @@ final class SealedAccessCycleConfiguration implements AccessCycleConfiguration {
examinators = new ReadOnlyRegistry<>(Arrays.asList(//
new BasePermissionsExaminationService()//
));
acquirers = new ReadOnlyRegistry<>(Arrays.asList(//
// new RemoteAcquisitionService(keyKeepers(), codecs()), //
new UserHomeLicenseAcquisitionService(), //
new InstallationLicenseAcquisitionService(), //
new ConfigurationLicenseAcquisitionService()//
));
}

MiningEquipment miningEquipment() {
Expand Down Expand Up @@ -189,4 +201,9 @@ public PermissionsExaminationServicesRegistry examinators() {
return () -> examinators;
}

@Override
public LicenseAcquisitionServicesRegistry acquirers() {
return () -> acquirers;
}

}
Loading

0 comments on commit b186533

Please sign in to comment.