Skip to content

Commit

Permalink
Bug 564328 API revision | conditions | rethink key interfaces
Browse files Browse the repository at this point in the history
 - 'LicensingCondition' interface reconstructed

Signed-off-by: elena.parovyshnaya <elena.parovyshnaya@gmail.com>
  • Loading branch information
eparovyshnaya committed Jun 16, 2020
1 parent beefbbf commit 30563cd
Show file tree
Hide file tree
Showing 10 changed files with 386 additions and 52 deletions.
1 change: 1 addition & 0 deletions bundles/org.eclipse.passage.lic.api/META-INF/MANIFEST.MF
Expand Up @@ -22,6 +22,7 @@ Export-Package: org.eclipse.passage.lic.api,
org.eclipse.passage.loc.products.ui,
org.eclipse.passage.loc.users.ui,
org.eclipse.passage.loc.api",
org.eclipse.passage.lic.internal.api.conditions;x-internal:=true,
org.eclipse.passage.lic.internal.api.registry;x-internal:=true,
org.eclipse.passage.lic.internal.api.requirements;x-internal:=true,
org.eclipse.passage.lic.internal.api.restrictions;x-internal:=true
Expand Up @@ -17,72 +17,76 @@
import org.eclipse.passage.lic.api.access.PermissionEmitter;

/**
* Defines the set of terms under which the identified {@code Feature} can be used.
* to be evaluated by {@link PermissionEmitter} <br/>
* Defines the set of terms under which the identified {@code Feature} can be
* used. to be evaluated by {@link PermissionEmitter} <br/>
* Obtained from {@link ConditionMiner}
*
* @deprecated use {@linkplain Condition} instead
* @since 0.5.0
*/
@Deprecated
public interface LicensingCondition {
/**
* Returns unique identifier of a feature under licensing.
*
* @return feature identifier
* @since 0.5.0
*/
/**
* Returns unique identifier of a feature under licensing.
*
* @return feature identifier
* @since 0.5.0
*/
String getFeatureIdentifier();

/**
* Returns descriptor of the feature version allowed by this licensing condition.
*
* @return version descriptor
* @since 0.5.0
*/
/**
* Returns descriptor of the feature version allowed by this licensing
* condition.
*
* @return version descriptor
* @since 0.5.0
*/
String getMatchVersion();

/**
* Returns rule of version matching, like "perfect match" or "equal or greater".
*
* @return match rule
* @since 0.5.0
*/
/**
* Returns rule of version matching, like "perfect match" or "equal or greater".
*
* @return match rule
* @since 0.5.0
*/
String getMatchRule();

/**
* Returns the validity period start date of this licensing condition. This is
* the value of its <code>"validFrom"</code> attribute.
*
* @return the valid from
* @since 0.5.0
*/
/**
* Returns the validity period start date of this licensing condition. This is
* the value of its <code>"validFrom"</code> attribute.
*
* @return the valid from
* @since 0.5.0
*/
Date getValidFrom();

/**
* Returns the validity period end date of this licensing condition. This is the
* value of its <code>"validUntil"</code> attribute.
*
* @return the valid until
* @since 0.5.0
*/
/**
* Returns the validity period end date of this licensing condition. This is the
* value of its <code>"validUntil"</code> attribute.
*
* @return the valid until
* @since 0.5.0
*/
Date getValidUntil();

/**
* The type of condition like "time" or "hardware".
* Defines the way the condition will be evaluated in a running environment.
*
* @return condition type
* @since 0.5.0
*/
/**
* The type of condition like "time" or "hardware". Defines the way the
* condition will be evaluated in a running environment.
*
* @return condition type
* @since 0.5.0
*/
String getConditionType();

/**
* Returns additional data encoded in a single string value.
* The expression is utilized by {@link PermissionEmitter} in conjunction with {@code conditionType}
*
* @return enlistment of additional information of this licencing condition
* @see PermissionEmitter
* @see #getConditionType
* @since 0.5.0
*/
/**
* Returns additional data encoded in a single string value. The expression is
* utilized by {@link PermissionEmitter} in conjunction with
* {@code conditionType}
*
* @return enlistment of additional information of this licensing condition
* @see PermissionEmitter
* @see #getConditionType
* @since 0.5.0
*/
String getConditionExpression();
}
@@ -0,0 +1,63 @@
/*******************************************************************************
* 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.api.conditions;

/**
* <p>
* Regarding each feature under licensing there is a series of statements in a
* license of some kind.
* </p>
* <p>
* These statements demands the feature to be used under curtain
* {@code condition}s, such as "only version older than 2.14.1 on a workstation
* under Windows OS with hard disk of serial AB0123C4DEFJHI and only for two
* years starting from the 1st of May, 2020." {@code Condition} represents such
* a bundle of demands.
* </p>
*/
public interface Condition {

/**
* @return unique identifier of a feature under licensing.
*/
String feature();

/**
* Define the actual {@code version} representing string that has been mined in
* the scope of this condition (typically from license of sorts).
*
* @see VersionMatch
*/
VersionMatch versionMatch();

/**
* Period of this condition applicability.
*
* @see ValidityPeriod
*/
ValidityPeriod validityPeriod();

/**
* <p>
* Defined how exactly the condition is to be evaluates.
* </p>
* <p>
* Type of a license dictates how Passage can evaluate the condition (check if
* all it's demands are met). For example, "hardware" license requires examining
* of the actual workstation hardware.
* </p>
*
* @see EvaluationInstructions
*/
EvaluationInstructions evaluationInstructions();
}
@@ -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.api.conditions;

/**
* <p>
* Condition definition contains sufficient amount of instructions on how
* exactly can we say if this condition is satisfied or not.
* </p>
* <p>
* For example, condition of {@code hardware} type requires actual workstation
* hardware evaluation and assessing it against condition's expectations. These
* ones can demand particular hardware part of have predefined serial id.
* </p>
*/
public interface EvaluationInstructions {

/**
* Meta classifier of the way this condition can be evaluated
*
* @see EvaluationType
*/
EvaluationType type();

/**
* Precise data for evaluation. Each evaluation type can expect it's own format
* here.
*
* @return raw string mined from a license
*/
String expression();

}
@@ -0,0 +1,81 @@
/*******************************************************************************
* 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.api.conditions;

import java.util.Objects;

/**
* <p>
* Defines the way the condition will be evaluated in a running environment. The
* type of condition like "time" or "hardware".
* </p>
* <p>
* Designed to be a <i>data-class</i>.
* </p>
*/
public abstract class EvaluationType {

private final String identifier;

protected EvaluationType(String identifier) {
Objects.requireNonNull(identifier, "Identifier is mandatory for condition type"); //$NON-NLS-1$
this.identifier = identifier.trim().toLowerCase();
}

public final String identifier() {
return identifier;
}

@Override
public final int hashCode() {
return Objects.hash(identifier());
}

@Override
public final boolean equals(Object object) {
if (!EvaluationType.class.isInstance(object)) {
return false;
}
return identifier.equals(((EvaluationType) object).identifier);
}

@Override
public final String toString() {
return identifier;
}

public static final class Time extends EvaluationType {

public Time() {
super("time"); //$NON-NLS-1$
}

}

public static final class Hardware extends EvaluationType {

public Hardware() {
super("hardware"); //$NON-NLS-1$
}

}

public static final class Of extends EvaluationType {

public Of(String identifier) {
super(identifier);
}

}

}
@@ -0,0 +1,45 @@
/*******************************************************************************
* 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.api.conditions;

/**
* <p>
* Defines the way a actual string (tested) can be matched with a predefined
* one. (beacon).
* </p>
* <p>
* For example {@code perfect match} for any string type would mean absolute
* equality, and {@code not less} match rule for a {@code version} strings would
* mean that match is successful iff the tested version is greater or equal than
* the beacon one.
* </p>
*
* @see VersionMatch
* @see Condition
*/
public abstract interface MatchingRule {

/**
* Descriptive identifier of a rule.
*
* @return
*/
String identifier();

/**
* Find out if the {@code tested} string {@code matches} with the {@code beacon}
* one.
*/
boolean match(String tested, String beacon);

}

0 comments on commit 30563cd

Please sign in to comment.