Skip to content
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
@@ -0,0 +1,18 @@
package com.cryptlex.android.lexfloatclient;

public class HostFeatureEntitlement {
/**
* The name of the feature.
*/
public String featureName;

/**
* The display name of the feature.
*/
public String featureDisplayName;

/**
* The value of the feature.
*/
public String value;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.sun.jna.ptr.LongByReference;
import java.math.BigInteger;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -206,6 +207,8 @@ public static HostConfig GetHostConfig() throws LexFloatClientException, Unsuppo
/**
* Gets the product version name.
*
* @deprecated This function is deprecated. Use GetHostLicenseEntitlementSetName() instead.
*
* @return name - Returns the name of the Product Version being used.
* @throws LexFloatClientException
* @throws UnsupportedEncodingException
Expand All @@ -224,6 +227,8 @@ public static String GetHostProductVersionName() throws LexFloatClientException,
/**
* Gets the product version display name.
*
* @deprecated This function is deprecated. Use GetHostLicenseEntitlementSetDisplayName() instead.
*
* @return displayName - Returns the display name of the Product Version being used.
* @throws LexFloatClientException
* @throws UnsupportedEncodingException
Expand All @@ -242,6 +247,8 @@ public static String GetHostProductVersionDisplayName() throws LexFloatClientExc
/**
* Gets the product version feature flag.
*
* @deprecated This function is deprecated. Use GetHostFeatureEntitlement() instead.
*
* @param name - The name of the Feature Flag.
* @return The properties of the Feature Flag as an object.
* @throws LexFloatClientException
Expand All @@ -259,6 +266,105 @@ public static HostProductVersionFeatureFlag GetHostProductVersionFeatureFlag(Str
throw new LexFloatClientException(status);
}

/**
* Gets the name of the entitlement set associated with the LexFloatServer license.
*
* @return Returns the host license entitlement set name.
* @throws LexFloatClientException
* @throws UnsupportedEncodingException
*/
public static String GetHostLicenseEntitlementSetName() throws LexFloatClientException, UnsupportedEncodingException {
int status;
int bufferSize = 256;

ByteBuffer buffer = ByteBuffer.allocate(bufferSize);
status = LexFloatClientNative.GetHostLicenseEntitlementSetName(buffer, bufferSize);
if (LF_OK == status) {
return new String(buffer.array(), "UTF-8").trim();
}
throw new LexFloatClientException(status);
}

/**
* Gets the display name of the entitlement set associated with the LexFloatServer license.
*
* @return Returns the host license entitlement set display name.
* @throws LexFloatClientException
* @throws UnsupportedEncodingException
*/
public static String GetHostLicenseEntitlementSetDisplayName() throws LexFloatClientException, UnsupportedEncodingException {
int status;
int bufferSize = 256;

ByteBuffer buffer = ByteBuffer.allocate(bufferSize);
status = LexFloatClientNative.GetHostLicenseEntitlementSetDisplayName(buffer, bufferSize);
if (LF_OK == status) {
return new String(buffer.array(), "UTF-8").trim();
}
throw new LexFloatClientException(status);
}

/**
* Gets the feature entitlements associated with the LexFloatServer license.
*
* Feature entitlements can be linked directly to a license (license feature entitlements)
* or via entitlement sets. If a feature entitlement is defined in both, the value from
* the license feature entitlement takes precedence, overriding the entitlement set value.
*
* @return Returns a list of host feature entitlements.
* @throws LexFloatClientException
* @throws UnsupportedEncodingException
*/
public static List<HostFeatureEntitlement> GetHostFeatureEntitlements() throws LexFloatClientException, UnsupportedEncodingException {
int status;
int bufferSize = 4096;

ByteBuffer buffer = ByteBuffer.allocate(bufferSize);
status = LexFloatClientNative.GetHostFeatureEntitlementsInternal(buffer, bufferSize);
if (LF_OK == status) {
String hostFeatureEntitlementsJson = new String(buffer.array(), "UTF-8").trim();
if (!hostFeatureEntitlementsJson.isEmpty()) {
ObjectMapper objectMapper = new ObjectMapper();
try {
List<HostFeatureEntitlement> hostFeatureEntitlements = objectMapper.readValue(hostFeatureEntitlementsJson, new TypeReference<List<HostFeatureEntitlement>>() {});
return hostFeatureEntitlements;
} catch (JsonProcessingException e) {}
} else {
return new ArrayList<>();
}
}
throw new LexFloatClientException(status);
}

/**
* Gets the feature entitlement associated with the LexFloatServer license.
*
* Feature entitlements can be linked directly to a license (license feature entitlements)
* or via entitlement sets. If a feature entitlement is defined in both, the value from
* the license feature entitlement takes precedence, overriding the entitlement set value.
*
* @param name The name of the feature.
* @return Returns the host feature entitlement object.
* @throws LexFloatClientException
* @throws UnsupportedEncodingException
*/
public static HostFeatureEntitlement GetHostFeatureEntitlement(String name) throws LexFloatClientException, UnsupportedEncodingException {
int status;
int bufferSize = 1024;

ByteBuffer buffer = ByteBuffer.allocate(bufferSize);
status = LexFloatClientNative.GetHostFeatureEntitlementInternal(name, buffer, bufferSize);
if (LF_OK == status) {
String hostFeatureEntitlementJson = new String(buffer.array(), "UTF-8").trim();
ObjectMapper objectMapper = new ObjectMapper();
try {
HostFeatureEntitlement hostFeatureEntitlement = objectMapper.readValue(hostFeatureEntitlementJson, HostFeatureEntitlement.class);
return hostFeatureEntitlement;
} catch (JsonProcessingException e) {}
}
throw new LexFloatClientException(status);
}

/**
* Get the value of the license metadata field associated with the
* LexFloatServer license key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ public static String getErrorMessage(int errorCode) {
case LF_E_MACHINE_FINGERPRINT:
message = "Machine fingerprint has changed since activation.";
break;
case LF_E_ENTITLEMENT_SET_NOT_LINKED:
message = "No entitlement set is linked to the license.";
break;
case LF_E_FEATURE_ENTITLEMENT_NOT_FOUND:
message = "The feature entitlement does not exist.";
break;
case LF_E_CLIENT:
message = "Client error.";
break;
Expand Down Expand Up @@ -340,7 +346,21 @@ public static String getErrorMessage(int errorCode) {
*
* MESSAGE: Request blocked due to untrusted proxy.
*/
public static final int LF_E_PROXY_NOT_TRUSTED = 67;
public static final int LF_E_PROXY_NOT_TRUSTED = 67;

/*
* CODE: LF_E_ENTITLEMENT_SET_NOT_LINKED
*
* MESSAGE: No entitlement set is linked to the license.
*/
public static final int LF_E_ENTITLEMENT_SET_NOT_LINKED = 68;

/*
* CODE: LF_E_FEATURE_ENTITLEMENT_NOT_FOUND
*
* MESSAGE: The feature entitlement does not exist.
*/
public static final int LF_E_FEATURE_ENTITLEMENT_NOT_FOUND = 69;

/*
* CODE: LF_E_CLIENT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ public interface CallbackType extends Callback {

public static native int GetHostProductVersionFeatureFlag(String name, IntByReference enabled, ByteBuffer data, int length);

public static native int GetHostLicenseEntitlementSetName(ByteBuffer name, int length);

public static native int GetHostLicenseEntitlementSetDisplayName(ByteBuffer displayName, int length);

public static native int GetHostFeatureEntitlementsInternal(ByteBuffer featureEntitlementsJson, int length);

public static native int GetHostFeatureEntitlementInternal(String featureName, ByteBuffer featureEntitlementJson, int length);

public static native int GetHostLicenseMetadata(String key, ByteBuffer value, int length);

public static native int GetHostLicenseMeterAttribute(String name, LongByReference allowedUses, LongByReference totalUses, LongByReference grossUses);
Expand Down