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

feat: Add GetFloatingClientMetadata() method to retrieve license metadata #15

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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 @@ -245,6 +245,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 @@ -60,6 +60,10 @@ public interface CallbackType extends Callback {
public static native int GetHostLicenseMeterAttribute(WString name, IntByReference allowedUses, IntByReference totalUses, IntByReference grossUses);

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 GetFloatingClientMeterAttributeUses(String name, IntByReference uses);

Expand Down