From 4d8aa6955331c9d82a2be6fb34b0714fc7bf939a Mon Sep 17 00:00:00 2001 From: muneebkq Date: Tue, 16 Jul 2024 14:26:08 +0530 Subject: [PATCH] feat: request-float-license --- cryptlex/lexfloatclient/lexfloatclient.py | 16 ++++- .../lexfloatclient/lexfloatclient_native.py | 4 ++ .../lexfloatclient/lexfloatstatus_codes.py | 70 +++++++++++-------- 3 files changed, 61 insertions(+), 29 deletions(-) diff --git a/cryptlex/lexfloatclient/lexfloatclient.py b/cryptlex/lexfloatclient/lexfloatclient.py index 13f2e2c..6076116 100644 --- a/cryptlex/lexfloatclient/lexfloatclient.py +++ b/cryptlex/lexfloatclient/lexfloatclient.py @@ -270,7 +270,7 @@ def GetFloatingClientMeterAttributeUses(name): @staticmethod def RequestFloatingLicense(): """Sends the request to lease the license from the LexFloatServer. - + Raises: LexFloatClientException """ @@ -278,6 +278,20 @@ def RequestFloatingLicense(): if LexFloatStatusCodes.LF_OK != status: raise LexFloatClientException(status) + @staticmethod + def RequestOfflineFloatingLicense(leaseDuration): + """Sends the request to lease the license from the LexFloatServer for offline usage. + + Args: + leaseDuration (int): seconds for which the lease should be obtained. + + Raises: + LexFloatClientException + """ + status = LexFloatClientNative.RequestOfflineFloatingLicense(leaseDuration) + if LexFloatStatusCodes.LF_OK != status: + raise LexFloatClientException(status) + @staticmethod def DropFloatingLicense(): """Sends the request to the LexFloatServer to free the license. diff --git a/cryptlex/lexfloatclient/lexfloatclient_native.py b/cryptlex/lexfloatclient/lexfloatclient_native.py index e116d62..6ab42c1 100644 --- a/cryptlex/lexfloatclient/lexfloatclient_native.py +++ b/cryptlex/lexfloatclient/lexfloatclient_native.py @@ -163,6 +163,10 @@ def byte_to_string(input): RequestFloatingLicense.argtypes = [] RequestFloatingLicense.restype = c_int +RequestOfflineFloatingLicense = library.RequestOfflineFloatingLicense +RequestOfflineFloatingLicense.argtypes = [c_uint32] +RequestOfflineFloatingLicense.restype = c_int + DropFloatingLicense = library.DropFloatingLicense DropFloatingLicense.argtypes = [] DropFloatingLicense.restype = c_int diff --git a/cryptlex/lexfloatclient/lexfloatstatus_codes.py b/cryptlex/lexfloatclient/lexfloatstatus_codes.py index d8bacad..c0cedb4 100644 --- a/cryptlex/lexfloatclient/lexfloatstatus_codes.py +++ b/cryptlex/lexfloatclient/lexfloatstatus_codes.py @@ -1,59 +1,73 @@ class LexFloatStatusCodes: - + LF_OK = 0 LF_FAIL = 1 - + LF_E_PRODUCT_ID = 40 - + LF_E_CALLBACK = 41 - + LF_E_HOST_URL = 42 - + LF_E_TIME = 43 - + LF_E_INET = 44 - + LF_E_NO_LICENSE = 45 - + LF_E_LICENSE_EXISTS = 46 - + LF_E_LICENSE_NOT_FOUND = 47 - + LF_E_LICENSE_EXPIRED_INET = 48 - + LF_E_LICENSE_LIMIT_REACHED = 49 - + LF_E_BUFFER_SIZE = 50 - + LF_E_METADATA_KEY_NOT_FOUND = 51 - + LF_E_METADATA_KEY_LENGTH = 52 - + LF_E_METADATA_VALUE_LENGTH = 53 - + LF_E_FLOATING_CLIENT_METADATA_LIMIT = 54 - + LF_E_METER_ATTRIBUTE_NOT_FOUND = 55 - + LF_E_METER_ATTRIBUTE_USES_LIMIT_REACHED = 56 - + LF_E_PRODUCT_VERSION_NOT_LINKED = 57 - + LF_E_FEATURE_FLAG_NOT_FOUND = 58 - + + LF_E_SYSTEM_PERMISSION = 59 + LF_E_IP = 60 - + + LF_E_INVALID_PERMISSION_FLAG = 61 + + LF_E_OFFLINE_FLOATING_LICENSE_NOT_ALLOWED = 62 + + LF_E_MAX_OFFLINE_LEASE_DURATION_EXCEEDED = 63 + + LF_E_ALLOWED_OFFLINE_FLOATING_CLIENTS_LIMIT_REACHED = 64 + + LF_E_WMIC = 65 + + LF_E_MACHINE_FINGERPRINT = 66 + LF_E_CLIENT = 70 - + LF_E_SERVER = 71 - + LF_E_SERVER_TIME_MODIFIED = 72 - + LF_E_SERVER_LICENSE_NOT_ACTIVATED = 73 - + LF_E_SERVER_LICENSE_EXPIRED = 74 - + LF_E_SERVER_LICENSE_SUSPENDED = 75 - + LF_E_SERVER_LICENSE_GRACE_PERIOD_OVER = 76