Skip to content

Commit

Permalink
Bug 571254 - [Passage][LA] agent state
Browse files Browse the repository at this point in the history
Start designing request-dependent services to empower PassageAgent

Signed-off-by: eparovyshnaya <[email protected]>
  • Loading branch information
eparovyshnaya committed Feb 19, 2021
1 parent e9dd779 commit e4fd20c
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -82,7 +84,7 @@ public final class RuntimeConfiguration implements AccessCycleConfiguration {
private final Registry<EvaluationType, RuntimeEnvironment> environments;
private final Registry<StringServiceId, PermissionsExaminationService> examinators;

public RuntimeConfiguration(Supplier<Path> source, Supplier<String> user, Supplier<LicensedProduct> product) {
public RuntimeConfiguration(Supplier<Path> source, ProductUserRequest<? extends NetRequest> request) {
requirements = new ReadOnlyRegistry<>(Arrays.asList(//
new BundleRequirements(), //
new ComponentRequirements() //
Expand All @@ -95,10 +97,10 @@ public RuntimeConfiguration(Supplier<Path> source, Supplier<String> 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(), //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> user;
private final Supplier<LicensedProduct> product;

public RuntimeFramework(ProductUserRequest<?> request) {
this(request.user()::get, request.product()::get);
}
private final ProductUserRequest<? extends NetRequest> request;

public RuntimeFramework(Supplier<String> user, Supplier<LicensedProduct> product) {
this.user = user;
this.product = product;
public RuntimeFramework(ProductUserRequest<? extends NetRequest> 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
Expand Down
15 changes: 15 additions & 0 deletions bundles/org.eclipse.passage.lac/.settings/.api_filters
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,19 @@
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/passage/internal/lac/base/CannotUseFeature.java" type="org.eclipse.passage.internal.lac.base.CannotUseFeature">
<filter id="576720909">
<message_arguments>
<message_argument value="Failure"/>
<message_argument value="CannotUseFeature"/>
</message_arguments>
</filter>
<filter id="643850349">
<message_arguments>
<message_argument value="LicensedProduct"/>
<message_argument value="CannotUseFeature"/>
<message_argument value="CannotUseFeature(String, LicensedProduct, String)"/>
</message_arguments>
</filter>
</resource>
</component>
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<R extends NetRequest> implements KeyKeeper {

// TODO: stated request
private final ProductUserRequest<R> request;

public RequestKeyKeeper(ProductUserRequest<R> 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;
}

}
3 changes: 2 additions & 1 deletion bundles/org.eclipse.passage.lic.api/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e4fd20c

Please sign in to comment.