Skip to content

Commit 72d3b1c

Browse files
authored
Merge pull request #29 from cryptlex/huzaif/host-prod-metadata
feat: added GetHostProductMetadata() function
2 parents a04bf81 + 14eb9e7 commit 72d3b1c

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/main/java/com/cryptlex/lexfloatclient/LexFloatClient.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,32 @@ public static HostFeatureEntitlement GetHostFeatureEntitlement(String name) thro
463463
throw new LexFloatClientException(status);
464464
}
465465

466+
/**
467+
* Gets the value of the product metadata.
468+
*
469+
* @param key key of the metadata field whose value you want to get
470+
* @return Returns the metadata key value
471+
* @throws LexFloatClientException
472+
* @throws UnsupportedEncodingException
473+
*/
474+
public static String GetHostProductMetadata(String key) throws LexFloatClientException, UnsupportedEncodingException {
475+
int status;
476+
if (Platform.isWindows()) {
477+
CharBuffer buffer = CharBuffer.allocate(4096);
478+
status = LexFloatClientNative.GetHostProductMetadata(new WString(key), buffer, 4096);
479+
if (LF_OK == status) {
480+
return buffer.toString().trim();
481+
}
482+
} else {
483+
ByteBuffer buffer = ByteBuffer.allocate(4096);
484+
status = LexFloatClientNative.GetHostProductMetadata(key, buffer, 4096);
485+
if (LF_OK == status) {
486+
return new String(buffer.array(), "UTF-8");
487+
}
488+
}
489+
throw new LexFloatClientException(status);
490+
}
491+
466492
/**
467493
* Get the value of the license metadata field associated with the
468494
* LexFloatServer license key

src/main/java/com/cryptlex/lexfloatclient/LexFloatClientNative.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ public interface CallbackType extends Callback {
7979

8080
public static native int GetHostFeatureEntitlementInternal(WString featureName, CharBuffer featureEntitlementJson, int length);
8181

82+
public static native int GetHostProductMetadata(String key, ByteBuffer value, int length);
83+
84+
public static native int GetHostProductMetadata(WString key, CharBuffer value, int length);
85+
8286
public static native int GetHostLicenseMetadata(String key, ByteBuffer value, int length);
8387

8488
public static native int GetHostLicenseMetadata(WString key, CharBuffer value, int length);

0 commit comments

Comments
 (0)