diff --git a/src/main/java/com/cryptlex/lexfloatclient/LexFloatClient.java b/src/main/java/com/cryptlex/lexfloatclient/LexFloatClient.java index fb34470..ad79d0a 100644 --- a/src/main/java/com/cryptlex/lexfloatclient/LexFloatClient.java +++ b/src/main/java/com/cryptlex/lexfloatclient/LexFloatClient.java @@ -263,6 +263,32 @@ public static String GetHostLicenseMetadata(String key) throws LexFloatClientExc } throw new LexFloatClientException(status); } + + /** + * Get the value of the license metadata field associated with the LexFloatServer license. + * + * @param key key of the metadata field whose value you want to get + * @return Returns the metadata key value + * @throws LexFloatClientException + * @throws UnsupportedEncodingException + */ + public static String GetFloatingClientMetadata(String key) throws LexFloatClientException, UnsupportedEncodingException { + int status; + if (Platform.isWindows()) { + CharBuffer buffer = CharBuffer.allocate(256); + status = LexFloatClientNative.GetFloatingClientMetadata(new WString(key), buffer, 256); + if (LF_OK == status) { + return buffer.toString().trim(); + } + } else { + ByteBuffer buffer = ByteBuffer.allocate(256); + status = LexFloatClientNative.GetFloatingClientMetadata(key, buffer, 256); + if (LF_OK == status) { + return new String(buffer.array(), "UTF-8"); + } + } + throw new LexFloatClientException(status); + } /** * Gets the license meter attribute allowed uses and total uses associated diff --git a/src/main/java/com/cryptlex/lexfloatclient/LexFloatClientNative.java b/src/main/java/com/cryptlex/lexfloatclient/LexFloatClientNative.java index ba8087a..fede5c2 100644 --- a/src/main/java/com/cryptlex/lexfloatclient/LexFloatClientNative.java +++ b/src/main/java/com/cryptlex/lexfloatclient/LexFloatClientNative.java @@ -63,10 +63,14 @@ public interface CallbackType extends Callback { public static native int GetHostLicenseExpiryDate(IntByReference expiryDate); + public static native int GetFloatingClientMetadata(String key, ByteBuffer value, int length); + + public static native int GetFloatingClientMetadata(WString key, CharBuffer value, int length); + public static native int GetFloatingLicenseMode(ByteBuffer mode, int length); public static native int GetFloatingLicenseMode(CharBuffer mode, int length); - + public static native int GetFloatingClientMeterAttributeUses(String name, IntByReference uses); public static native int GetFloatingClientMeterAttributeUses(WString name, IntByReference uses);