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 568632 Implement feature grant acquire/release #531

Merged
merged 2 commits into from
Nov 9, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ public String toString() {
return name;
}

public static final class Aquire extends ConditionAction {
public static final class Mine extends ConditionAction {

public Aquire() {
super("acquire"); //$NON-NLS-1$
public Mine() {
super("mine"); //$NON-NLS-1$
}

}

public static final class Keep extends ConditionAction {
public static final class Acquire extends ConditionAction {

public Keep() {
super("keep"); //$NON-NLS-1$
public Acquire() {
super("acquire"); //$NON-NLS-1$
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Collection<ConditionPack> read(byte[] raw, String contentType) throws Lic
return Collections.singleton(//
new BaseConditionPack(//
source(), //
transport(new ContentType.Of(contentType)).read(stream)//
transport(contentType).read(stream)//
));
} catch (IOException e) {
throw new LicensingException(HcMessages.DecryptedConditions_reading_error, e);
Expand All @@ -58,12 +58,13 @@ private String source() {
return String.format("net:%s:%d", coordinates.getIp(), coordinates.getPort());//$NON-NLS-1$
}

private ConditionTransport transport(ContentType contentType) throws LicensingException {
if (!transports.get().hasService(contentType)) {
throw new LicensingException(String.format(HcMessages.DecryptedConditions_no_transport_for_content_type,
contentType.contentType()));
private ConditionTransport transport(String contentType) throws LicensingException {
ContentType type = new ContentType.Of(contentType);
if (!transports.get().hasService(type)) {
throw new LicensingException(
String.format(HcMessages.DecryptedConditions_no_transport_for_content_type, contentType));
}
return transports.get().service(contentType);
return transports.get().service(type);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
*
* FIXME: for development: #564815
*/
final class LicenseUser extends StringNamedData {
public final class LicenseUser extends StringNamedData {

protected LicenseUser(String value) {
public LicenseUser(String value) {
super(value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
import org.eclipse.passage.lic.internal.base.conditions.mining.LicensingContentType;
import org.eclipse.passage.lic.internal.net.LicensingAction;

final class RequestParameters {
final class MineRequestParameters {

private final LicensedProduct product;
private final FloatingLicenseAccess access;

RequestParameters(LicensedProduct product, FloatingLicenseAccess access) {
MineRequestParameters(LicensedProduct product, FloatingLicenseAccess access) {
this.product = product;
this.access = access;
}
Expand All @@ -50,7 +50,7 @@ private NamedData[] parameters() throws UnsupportedEncodingException {
return new NamedData[] { //
new ProductIdentifier(encode(product.identifier())), //
new ProductVersion(encode(product.version())), //
new LicensingAction(new ConditionAction.Aquire()), //
new LicensingAction(new ConditionAction.Mine()), //
new LicensingContentType(new ContentType.Xml()), //
new LicenseUser(access.getUser()), //
new ServerAuthenticationType(access.getServer()), //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public URL url() throws LicensingException {
return new URL("http", //$NON-NLS-1$
corrdinates.host(), //
Integer.parseInt(corrdinates.port()), //
new RequestParameters(product, access).query());
new MineRequestParameters(product, access).query());
} catch (LicensingException //
| NumberFormatException //
| MalformedURLException //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.eclipse.passage.lic.internal.base.ProductIdentifier;
import org.eclipse.passage.lic.internal.base.ProductVersion;
import org.eclipse.passage.lic.internal.base.conditions.mining.LicensingContentType;
import org.eclipse.passage.lic.internal.hc.remote.impl.LicenseUser;
import org.eclipse.passage.lic.internal.hc.remote.impl.RemoteConditionsRequest;
import org.eclipse.passage.lic.internal.hc.remote.impl.ServerAuthenticationExpression;
import org.eclipse.passage.lic.internal.hc.remote.impl.ServerAuthenticationType;
Expand All @@ -57,13 +58,29 @@ public void urlContainsAllParameters() throws IOException {
assertEquals(host, url.getHost());
assertEquals(port, url.getPort());
assertNotNull(url.getQuery());
assertTrue(url.getQuery().contains(new ProductIdentifier("any").key())); //$NON-NLS-1$
assertTrue(url.getQuery().contains(new ProductVersion("any").key())); //$NON-NLS-1$
assertTrue(url.getQuery().contains(new LicensingAction(new ConditionAction.Of("any")).key())); //$NON-NLS-1$
assertTrue(url.getQuery().contains(new ServerAuthenticationExpression("any").key())); //$NON-NLS-1$
assertTrue(url.getQuery().contains(new ServerAuthenticationType("any").key())); //$NON-NLS-1$
assertTrue(url.getQuery().contains("user")); //$NON-NLS-1$
assertTrue(url.getQuery().contains(new LicensingContentType(new ContentType.Of("any")).key())); //$NON-NLS-1$
queryHas(url, new ProductIdentifier("any").key()); //$NON-NLS-1$
queryHas(url, new ProductVersion("any").key()); //$NON-NLS-1$
queryHas(url, //
new LicensingAction(new ConditionAction.Of("any")).key(), //$NON-NLS-1$
new ConditionAction.Mine().name());
queryHas(url, //
new ServerAuthenticationExpression("any").key(), //$NON-NLS-1$
expression);
queryHas(url, //
new ServerAuthenticationType("any").key(), //$NON-NLS-1$
environment);
queryHas(url, //
new LicenseUser(user).key(), //
user);
queryHas(url, //
new LicensingContentType(new ContentType.Of("any")).key(), //$NON-NLS-1$
new ContentType.Xml().contentType());
}

private void queryHas(URL url, String... values) {
for (String value : values) {
assertTrue(url.getQuery().contains(value));
}
}

private URL url() {
Expand Down