Skip to content

Commit

Permalink
Merge pull request #15 from cryptlex/muneeb/Get-FloatingClient-Metadata
Browse files Browse the repository at this point in the history
feat: Add GetFloatingClientMetadata() method to retrieve license metadata
  • Loading branch information
ahmad-kemsan authored Aug 6, 2024
2 parents 6529949 + f1db536 commit c62a261
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/main/java/com/cryptlex/lexfloatclient/LexFloatClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c62a261

Please sign in to comment.