66import java .nio .CharBuffer ;
77import java .io .UnsupportedEncodingException ;
88import com .sun .jna .ptr .IntByReference ;
9+ import com .fasterxml .jackson .databind .ObjectMapper ;
10+ import com .fasterxml .jackson .core .JsonProcessingException ;
911import java .util .ArrayList ;
1012import java .util .List ;
1113
@@ -56,6 +58,28 @@ public static void SetHostUrl(String hostUrl) throws LexFloatClientException {
5658 }
5759 }
5860
61+ /**
62+ * Sets the permission flag. This function must be called on every start of your program
63+ * after SetHostProductId() function in case the application allows borrowing of licenses
64+ * or system wide activation.
65+ *
66+ * @param flag depending on your application's requirements, choose one of
67+ * the following values: LF_USER, LF_ALL_USERS.
68+ * <ul>
69+ * <li> LF_USER: This flag indicates that the application does not require admin or root permissions to run.</li>
70+ * <li> LF_ALL_USERS: This flag is specifically designed for Windows and should be used for system-wide activations.</li>
71+ * </ul>
72+ * @throws LexFloatClientException
73+ */
74+ public static void SetPermissionFlag (int flag ) throws LexFloatClientException {
75+ int status ;
76+ status = LexFloatClientNative .SetPermissionFlag (flag )
77+
78+ if (LF_OK != status ) {
79+ throw new LexFloatClientException (status );
80+ }
81+ }
82+
5983 /**
6084 * Sets the renew license callback function.<br>
6185 * Whenever the license lease is about to expire, a renew request is sent to
@@ -113,6 +137,24 @@ public static void SetFloatingClientMetadata(String key, String value) throws Le
113137 }
114138 }
115139
140+ /**
141+ * Gets the lease expiry date timestamp of the floating client.
142+ *
143+ * @return Returns the timestamp
144+ * @throws LexFloatClientException
145+ */
146+ public static int GetFloatingClientLeaseExpiryDate () throws LexFloatClientException {
147+ int status ;
148+ IntByReference expiryDate = new IntByReference (0 );
149+ status = LexFloatClientNative .GetFloatingClientLeaseExpiryDate (expiryDate );
150+ switch (status ) {
151+ case LF_OK :
152+ return expiryDate .getValue ();
153+ default :
154+ throw new LexFloatClientException (status );
155+ }
156+ }
157+
116158 /**
117159 * Gets the version of this library.
118160 *
@@ -138,6 +180,53 @@ public static String GetFloatingClientLibraryVersion() throws LexFloatClientExce
138180 throw new LexFloatClientException (status );
139181 }
140182
183+ /**
184+ * Gets the host configuration.
185+ * This function sends a network request to LexFloatServer to get the configuration details.
186+
187+ * @return Returns host configuration.
188+ * @throws LexFloatClientException
189+ * @throws UnsupportedEncodingException
190+ */
191+ public static HostConfig GetHostConfig () throws LexFloatClientException , UnsupportedEncodingException {
192+ int status ;
193+ int bufferSize = 1024 ;
194+ if (Platform .isWindows ()) {
195+ CharBuffer buffer = CharBuffer .allocate (bufferSize );
196+ status = LexFloatClientNative .GetHostConfigInternal (buffer , bufferSize );
197+ if (LF_OK == status ) {
198+ String hostConfigJson = buffer .toString ().trim ();
199+ if (!hostConfigJson .isEmpty ()) {
200+ HostConfig hostConfig = null ;
201+ ObjectMapper objectMapper = new ObjectMapper ();
202+ try {
203+ hostConfig = objectMapper .readValue (hostConfigJson , HostConfig .class );
204+ } catch (JsonProcessingException e ) {}
205+ return hostConfig ;
206+ } else {
207+ return null ;
208+ }
209+ }
210+ } else {
211+ ByteBuffer buffer = ByteBuffer .allocate (bufferSize );
212+ status = LexFloatClientNative .GetHostConfigInternal (buffer , bufferSize );
213+ if (LF_OK == status ) {
214+ String hostConfigJson = new String (buffer .array (), "UTF-8" ).trim ();
215+ if (!hostConfigJson .isEmpty ()) {
216+ HostConfig hostConfig = null ;
217+ ObjectMapper objectMapper = new ObjectMapper ();
218+ try {
219+ hostConfig = objectMapper .readValue (hostConfigJson , HostConfig .class );
220+ } catch (JsonProcessingException e ) {}
221+ return hostConfig ;
222+ } else {
223+ return null ;
224+ }
225+ }
226+ }
227+ throw new LexFloatClientException (status );
228+ }
229+
141230 /**
142231 * Gets the product version name.
143232 *
@@ -246,6 +335,32 @@ public static String GetHostLicenseMetadata(String key) throws LexFloatClientExc
246335 throw new LexFloatClientException (status );
247336 }
248337
338+ /**
339+ * Get the value of the license metadata field associated with the LexFloatServer license.
340+ *
341+ * @param key key of the metadata field whose value you want to get
342+ * @return Returns the metadata key value
343+ * @throws LexFloatClientException
344+ * @throws UnsupportedEncodingException
345+ */
346+ public static String GetFloatingClientMetadata (String key ) throws LexFloatClientException , UnsupportedEncodingException {
347+ int status ;
348+ if (Platform .isWindows ()) {
349+ CharBuffer buffer = CharBuffer .allocate (256 );
350+ status = LexFloatClientNative .GetFloatingClientMetadata (new WString (key ), buffer , 256 );
351+ if (LF_OK == status ) {
352+ return buffer .toString ().trim ();
353+ }
354+ } else {
355+ ByteBuffer buffer = ByteBuffer .allocate (256 );
356+ status = LexFloatClientNative .GetFloatingClientMetadata (key , buffer , 256 );
357+ if (LF_OK == status ) {
358+ return new String (buffer .array (), "UTF-8" );
359+ }
360+ }
361+ throw new LexFloatClientException (status );
362+ }
363+
249364 /**
250365 * Gets the license meter attribute allowed uses and total uses associated
251366 * with the LexFloatServer license.
@@ -293,6 +408,31 @@ public static int GetHostLicenseExpiryDate() throws LexFloatClientException {
293408 }
294409 }
295410
411+ /**
412+ * Gets the mode of the floating license (online or offline).
413+ *
414+ * @return mode - Returns the floating license mode.
415+ * @throws LexFloatClientException
416+ * @throws UnsupportedEncodingException
417+ */
418+ public static String GetFloatingLicenseMode () throws LexFloatClientException , UnsupportedEncodingException {
419+ int status ;
420+ if (Platform .isWindows ()) {
421+ CharBuffer buffer = CharBuffer .allocate (256 );
422+ status = LexFloatClientNative .GetFloatingLicenseMode (buffer , 256 );
423+ if (LF_OK == status ) {
424+ return buffer .toString ().trim ();
425+ }
426+ } else {
427+ ByteBuffer buffer = ByteBuffer .allocate (256 );
428+ status = LexFloatClientNative .GetFloatingLicenseMode (buffer , 256 );
429+ if (LF_OK == status ) {
430+ return new String (buffer .array (), "UTF-8" ).trim ();
431+ }
432+ }
433+ throw new LexFloatClientException (status );
434+ }
435+
296436 /**
297437 * Gets the meter attribute uses consumed by the floating client.
298438 *
@@ -318,6 +458,21 @@ public static int GetFloatingClientMeterAttributeUses(String name) throws LexFlo
318458 throw new LexFloatClientException (status );
319459 }
320460
461+ /**
462+ * Sends the request to lease the license from the LexFloatServer for offline usage.
463+ * The maximum value of lease duration is configured in the config.yml of LexFloatServer.
464+ *
465+ * @param leaseDuration value of the lease duration.
466+ * @throws LexFloatClientException
467+ */
468+ public static void RequestOfflineFloatingLicense (int leaseDuration ) throws LexFloatClientException {
469+ int status ;
470+ status = LexFloatClientNative .RequestOfflineFloatingLicense (leaseDuration );
471+ if (LF_OK != status ) {
472+ throw new LexFloatClientException (status );
473+ }
474+ }
475+
321476 /**
322477 * Sends the request to lease the license from the LexFloatServer
323478 *
0 commit comments