| LicenseSpring C++ SDK 7.32.0 Easily add Software Licensing to your application

Public Types | Public Member Functions | Static Public Attributes | List of all members
LicenseSpring::License Class Referenceabstract

Class that encapsulates license information. More...

`#include <LicenseSpring/License.h>`

## Public Types
using | ptr_t = std::shared_ptr< License >

## Public Member Functions
virtual | ~License ()
| Destructor for license. More...
virtual const LicenseID & | id () const =0
| Getter for license ID. More...
virtual const std::string & | key () const =0
| Getter for license key. More...
virtual const std::string & | user () const =0
| Getter for user. More...
virtual LicenseType | type () const =0
| Getter for license type. More...
virtual Customer | owner () const =0
| Getter for license owner. More...
virtual LicenseUser::ptr_t | licenseUser () const =0
| Getter for license user, it's a person assigned to the license. More...
virtual ProductDetails | productDetails () const =0
| Getter for product details. More...
virtual std::string | status () const =0
| Getter for license status. More...
virtual bool | isActive () const =0
| Checker for if the license is active. More...
virtual bool | isEnabled () const =0
| Checker for if the license is enabled. More...
virtual bool | isValid () const =0
| Checker for if the license is valid. More...
virtual bool | isTrial () const =0
| Checker for if the license is a trial. More...
virtual bool | isAirGapped () const =0
| Checker for if the license is air gapped. More...
virtual uint32_t | policyId () const =0
| Policy id of the license. More...
virtual bool | isOfflineActivated () const =0
| Checker for if license is offline activated. More...
virtual bool | isVMAllowed () const =0
| Checker for whether the license is allowed to work under virtual machine or not. More...
virtual bool | isFloating () const =0
| Checker for whether the license is floating or not. More...
virtual bool | isBorrowed () const =0
| Checker for whether the license is borrowed. More...
virtual bool | isSubscriptionGracePeriodStarted () const =0
| Check if grace period started for subscription license. More...
virtual bool | isGracePeriodStarted () const =0
| Check if grace period started for a license. More...
virtual tm | gracePeriodEndDateTime () const =0
| Getter for grace period end date time in local time. More...
virtual tm | gracePeriodEndDateTimeUTC () const =0
| Getter for grace period end date time in UTC. More...
virtual int | gracePeriodHoursRemaining () const =0
| How many hours remaining till grace period ends. More...
virtual uint32_t | trialPeriod () const =0
| Trial duration of current license. More...
virtual uint32_t | maxFloatingUsers () const =0
| Getter for max simultaneous license users (devices or instances). More...
virtual uint32_t | floatingInUseCount () const =0
| Getter for current floatings slots in use count, including this user (instance). More...
virtual uint32_t | floatingTimeout () const =0
| Getter for timeout of the floating license in minutes. More...
virtual const std::string & | floatingClientId () const =0
| Getter for floating user (client) or instance id. More...
virtual tm | validityPeriod () const =0
| Getter for license validity period in local time. More...
virtual tm | validityPeriodUtc () const =0
| Getter for license validity period in UTC. More...
virtual tm | validityWithGracePeriod () const =0
| Getter for license validity period including grace period in local time. More...
virtual tm | validityWithGracePeriodUtc () const =0
| Getter for license validity period including grace period in UTC. More...
virtual uint32_t | subscriptionGracePeriod () const =0
| Getter for grace period of the Subscription license in hours. More...
virtual uint32_t | maxBorrowTime () const =0
| Maximum borrowing period in hours. More...
virtual tm | maintenancePeriod () const =0
| Getter for license maintenance period in local time. More...
virtual tm | maintenancePeriodUtc () const =0
| Getter for license maintenance period in UTC. More...
virtual tm | lastCheckDate () const =0
| Getter for license last check date in local time. More...
virtual tm | lastCheckDateUtc () const =0
| Getter for license last check date in UTC. More...
virtual tm | floatingEndDateTime () const =0
| Getter for floating license validity end date time in local time zone. More...
virtual tm | floatingEndDateTimeUtc () const =0
| Floating license validity end date time in UTC. More...
virtual const std::string & | startDate () const =0
| Getter method license start date. More...
virtual const std::string & | metadata () const =0
| Getter for license metadata. More...
virtual LicenseFeature | feature (const std::string &featureCode) const =0
| Getter method for license feature. More...
virtual std::vector< LicenseFeature > | features () const =0
| Getter for list of license features associated with the license. More...
virtual std::vector< CustomField > | customFields () const =0
| Getter for list of custom fields associated with the license. More...
virtual const std::vector< CustomField > & | userData () const =0
| Returns user data stored within license object. More...
virtual std::string | userData (const std::string &key) const =0
| Getter for user data by given key. More...
virtual void | addUserData (const CustomField &data, bool saveLicense=true)=0
| Adds user data to the license object. This method allows you to store custom data securely inside license file. More...
virtual void | removeUserData (const std::string &key=std::string(), bool saveLicense=true)=0
| Removes user data from the license. More...
virtual int32_t | totalConsumption () const =0
| Returns license current total consumption. More...
virtual int32_t | maxConsumption () const =0
| Returns license maximum consumption. More...
virtual int32_t | maxOverages () const =0
| Returns maximum overage allowed for the license. More...
virtual bool | isOveragesAllowed () const =0
| Checks if overage is allowed for Consumption license. More...
virtual bool | isUnlimitedConsumptionAllowed () const =0
| Checks if unlimited consumption is allowed for Consumption license. More...
virtual ConsumptionPeriod | consumptionPeriod () const =0
| Returns period of time after which consumption is reset. More...
virtual bool | isResetConsumptionEnabled () const =0
| Checks if consumption reset is allowed for Consumption license. More...
virtual uint32_t | timesActivated () const =0
| How many times license already been activated. More...
virtual uint32_t | maxActivations () const =0
| How many times license can be activated. More...
virtual uint32_t | transferCount () const =0
| How many times license has been transferred between devices. More...
virtual int32_t | transferLimit () const =0
| Maximum number of allowed license transfers between devices. More...
virtual bool | isDeviceTransferAllowed () const =0
| Checks if license can be transferred between devices. More...
virtual bool | isDeviceTransferLimited () const =0
| Checks if the license allows only limited number of transfers between devices. More...
virtual bool | isAutoReleaseSet () const =0
| Returns auto release flag. Meaningful only for floating license. More...
virtual void | setAutoRelease (bool autoRelease)=0
| Sets auto release flag. Meaningful only for floating license. More...
virtual void | updateConsumption (int32_t value=1, bool saveLicense=true)=0
| Increase or decrease license consumption by given value. More...
virtual void | updateFeatureConsumption (const std::string &featureCode, int32_t value=1, bool saveLicense=true)=0
| Increase or decrease feature consumption by given value. More...
virtual bool | isExpired () const =0
| Compare system date time with license validity date time. More...
virtual bool | isMaintenancePeriodExpired () const =0
| Compare system date time with maintenance period time. More...
virtual int | daysRemainingUtc () const =0
| How many days remaining till license expires. More...
virtual int | daysRemaining () const =0
| Almost the same as UTC counterpart, but days counter will be changed on local midnight. More...
virtual int | maintenanceDaysRemaining () const =0
| How many days remaining till end of maintenance days. More...
virtual int | daysPassedSinceLastCheck () const =0
| How many days passed from last online check. More...
virtual void | localCheck ()=0
| Check license local without connection to the backend. More...
virtual bool | deactivate (bool removeLocalData=false)=0
| Sends deactivate license request to the backend. More...
virtual bool | changePassword (const std::string &password, const std::string &newPassword)=0
| Change password for user based license. More...
virtual InstallationFile::ptr_t | check (const InstallFileFilter &filter=InstallFileFilter(), bool includeExpiredFeatures=false)=0
| Online license check, sync the license with the backend, throws exceptions in case of errors. More...
virtual bool | syncConsumption (int32_t requestOverage=-1)=0
| Sync Consumption license with the server. More...
virtual bool | syncFeatureConsumption (const std::string &featureCode=std::string())=0
| Sync Consumption Feature(s) with the backend, if code not provided sync all consumption features. More...
virtual void | addDeviceVariable (const std::string &name, const std::string &value, bool saveLicense=true)=0
| Add new or update existing device variable to license daata. More...
virtual void | addDeviceVariable (const DeviceVariable &variable, bool saveLicense=true)=0
| Add new or update existing device variable to license daata. More...
virtual void | addDeviceVariables (const std::vector< DeviceVariable > &variables)=0
| Add new or update existing device variables to license daata. More...
virtual bool | sendDeviceVariables ()=0
| Send current device variables list to the backend (see device variables on the platform) More...
virtual std::vector< DeviceVariable > | getDeviceVariables (bool getFromBackend=false)=0
| Get device variables from the local license or from the backend. More...
virtual DeviceVariable | deviceVariable (const std::string &name) const =0
| Get device variable by name. More...
virtual const std::string & | deviceVariableValue (const std::string &name) const =0
| Get device variable value by name. More...
virtual void | setupLicenseWatchdog (LicenseWatchdogCallback callback, uint32_t timeout=0)=0
| Setup and run license watchdog, a background thread which periodically checks the license. More...
virtual void | resumeLicenseWatchdog ()=0
| Resume background thread, you can call this within your callback in order to resume periodic license checks (registrations). More...
virtual void | stopLicenseWatchdog ()=0
| Stops license watchdog background thread. More...
virtual void | setupFeatureWatchdog (LicenseWatchdogCallback callback, uint32_t timeout=0)=0
| Setup and run feature watchdog, a background thread which periodically checks floating license features. More...
virtual void | resumeFeatureWatchdog ()=0
| Resume background thread, you can call this within your callback in order to resume periodic feature checks (registrations). More...
virtual void | stopFeatureWatchdog ()=0
| Stops feature watchdog background thread. More...
virtual void | registerFloatingLicense ()=0
| Register floating license using floatingClientId. More...
virtual void | releaseFloatingLicense (bool throwExceptions=false)=0
| Revoke floating license, typically should be called at the end of app execution. More...
virtual void | borrow (uint32_t hours, uint32_t days=0)=0
| Borrow floating license for provided time interval. More...
virtual void | borrow (const std::string &borrowEndDateTime=std::string())=0
| Borrow floating license till provided end date time. More...
virtual std::wstring | deactivateOffline (const std::wstring &deactivationRequestFile=std::wstring())=0
| Creates offline deactivation file request. More...
virtual bool | updateOffline (const std::wstring &path, bool resetConsumption=false)=0
| Update license data accordingly to provided file. More...
virtual void | unlinkFromDevice ()=0
| Unlinks license from cuurent device ID. More...
virtual std::string | getAirGapDeactivationCode (const std::string &initializationCode)=0
| Get air gap Deactivation code. More...
virtual void | deactivateAirGap (const std::string &confirmationCode)=0
| Verify Confirmation code and deactivate air gap license. More...
virtual bool | isLicenseBelongsToThisDevice (DeviceIDAlgorithm deviceIDAlgorithm)=0
| Checks if license belongs to this DeviceIDAlgorithm. More...
virtual bool | checkLicenseBelongsToThisDevice ()=0
| Checks if license belongs to any of the DeviceIDAlgorithm values. More...
virtual void | registerFloatingFeature (const std::string &featureCode, bool addToWatchdog=true)=0
| Register a floating feature and occupy a floating slot. More...
virtual void | releaseFloatingFeature (const std::string &featureCode)=0
| Release a floating feature and free a floating slot. More...

## Static Public Attributes
static const int | MaxDaysRemainingValue
| Maximum value for daysRemaining, e.g. in case of perpetual license. More...

## Detailed Description

Class that encapsulates license information.

Used for checking, editing, and deleting characteristics of licenses

Definition at line 33 of file License.h.

## Member Typedef Documentation

## ◆ ptr_t

using LicenseSpring::License::ptr_t = std::shared_ptr<License>

Definition at line 36 of file License.h.

## Constructor & Destructor Documentation

## ◆ ~License()

virtual LicenseSpring::License::~License | ( |  | ) |
| inline virtual

Destructor for license.

Definition at line 39 of file License.h.

## Member Function Documentation

## ◆ id()

virtual const LicenseID& LicenseSpring::License::id | ( |  | ) | const
| pure virtual

Getter for license ID.

Returns
  license ID object.

## ◆ key()

virtual const std::string& LicenseSpring::License::key | ( |  | ) | const
| pure virtual

Getter for license key.

Returns
  String of license key.

## ◆ user()

virtual const std::string& LicenseSpring::License::user | ( |  | ) | const
| pure virtual

Getter for user.

Returns
  String of user.

## ◆ type()

virtual LicenseType LicenseSpring::License::type | ( |  | ) | const
| pure virtual

Getter for license type.

Returns
  LicenseType object.

## ◆ owner()

virtual Customer LicenseSpring::License::owner | ( |  | ) | const
| pure virtual

Getter for license owner.

Returns
  Information about license owner, commonly it's a person or organization associated with the license.

## ◆ licenseUser()

virtual LicenseUser::ptr_t LicenseSpring::License::licenseUser | ( |  | ) | const
| pure virtual

Getter for license user, it's a person assigned to the license.

Currently this method make sense only for user-based licenses.

Returns
  Information about license owner, commonly it's a person or organization associated with the license.

## ◆ productDetails()

virtual ProductDetails LicenseSpring::License::productDetails | ( |  | ) | const
| pure virtual

Getter for product details.

Returns cached data from local license, does not perform a request to backend.
See also BaseManager::getProductDetails

Returns
  Information about the product.

## ◆ status()

virtual std::string LicenseSpring::License::status | ( |  | ) | const
| pure virtual

Getter for license status.

Returns
  String of license status, either 'Active', 'Disabled', 'Expired' or 'Inactive'.

## ◆ isActive()

virtual bool LicenseSpring::License::isActive | ( |  | ) | const
| pure virtual

Checker for if the license is active.

Returns
  True if active, false if not.

## ◆ isEnabled()

virtual bool LicenseSpring::License::isEnabled | ( |  | ) | const
| pure virtual

Checker for if the license is enabled.

Returns
  True if enabled, false if not.

## ◆ isValid()

virtual bool LicenseSpring::License::isValid | ( |  | ) | const
| pure virtual

Checker for if the license is valid.

Returns
  True if isActive() && isEnabled() && !isExpired() are all true, false if not.

## ◆ isTrial()

virtual bool LicenseSpring::License::isTrial | ( |  | ) | const
| pure virtual

Checker for if the license is a trial.

Returns
  True if it is a trial, false if not.

## ◆ isAirGapped()

virtual bool LicenseSpring::License::isAirGapped | ( |  | ) | const
| pure virtual

Checker for if the license is air gapped.

Returns
  True if it is air gapped, false if not.

## ◆ policyId()

virtual uint32_t LicenseSpring::License::policyId | ( |  | ) | const
| pure virtual

Policy id of the license.

Meaningful only for air gapped licenses.

Returns
  Integer of license policy id.

## ◆ isOfflineActivated()

virtual bool LicenseSpring::License::isOfflineActivated | ( |  | ) | const
| pure virtual

Checker for if license is offline activated.

Returns
  True if offline activated, false if not.

## ◆ isVMAllowed()

virtual bool LicenseSpring::License::isVMAllowed | ( |  | ) | const
| pure virtual

Checker for whether the license is allowed to work under virtual machine or not.

See product and license settings on the LicenseSpring platform for more details.

Returns
  True if VM is allowed, false if not.

## ◆ isFloating()

virtual bool LicenseSpring::License::isFloating | ( |  | ) | const
| pure virtual

Checker for whether the license is floating or not.

Returns
  True if floating, false if not.

## ◆ isBorrowed()

virtual bool LicenseSpring::License::isBorrowed | ( |  | ) | const
| pure virtual

Checker for whether the license is borrowed.

Meaningful only for Floating license, see License::borrow

Returns
  True if borrowed, false if not.

## ◆ isSubscriptionGracePeriodStarted()

virtual bool LicenseSpring::License::isSubscriptionGracePeriodStarted | ( |  | ) | const
| pure virtual

Check if grace period started for subscription license.

Meaningful only for Subscription licenses.

Returns
  Returns true if grace period started and false otherwise.

## ◆ isGracePeriodStarted()

virtual bool LicenseSpring::License::isGracePeriodStarted | ( |  | ) | const
| pure virtual

Check if grace period started for a license.

Returns
  Returns true if grace period started and false otherwise.

## ◆ gracePeriodEndDateTime()

virtual tm LicenseSpring::License::gracePeriodEndDateTime | ( |  | ) | const
| pure virtual

Getter for grace period end date time in local time.

Returns
  Time structure of grace period in local time.

## ◆ gracePeriodEndDateTimeUTC()

virtual tm LicenseSpring::License::gracePeriodEndDateTimeUTC | ( |  | ) | const
| pure virtual

Getter for grace period end date time in UTC.

Returns
  Time structure of grace period in UTC.

## ◆ gracePeriodHoursRemaining()

virtual int LicenseSpring::License::gracePeriodHoursRemaining | ( |  | ) | const
| pure virtual

How many hours remaining till grace period ends.

Returns
  Integer representing hours remaining till grace period ends.

## ◆ trialPeriod()

virtual uint32_t LicenseSpring::License::trialPeriod | ( |  | ) | const
| pure virtual

Trial duration of current license.

In case trial duration of product changes, this returns the trial duration at time of license issuing.

Returns
  Trial duration of current license in days.

## ◆ maxFloatingUsers()

virtual uint32_t LicenseSpring::License::maxFloatingUsers | ( |  | ) | const
| pure virtual

Getter for max simultaneous license users (devices or instances).

Meaningful only for floating license.

Returns
  Integer of max simutaneous license users.

## ◆ floatingInUseCount()

virtual uint32_t LicenseSpring::License::floatingInUseCount | ( |  | ) | const
| pure virtual

Getter for current floatings slots in use count, including this user (instance).

Meaningful only for Floating license, please query this value only after online license check or registration (for Offline floating).

Returns
  Integer of current floating slots in use.

## ◆ floatingTimeout()

virtual uint32_t LicenseSpring::License::floatingTimeout | ( |  | ) | const
| pure virtual

Getter for timeout of the floating license in minutes.

Returns
  Integer of timeout of the floating license in minutes.

## ◆ floatingClientId()

virtual const std::string& LicenseSpring::License::floatingClientId | ( |  | ) | const
| pure virtual

Getter for floating user (client) or instance id.

Meaningful only for offline floating license.

Returns
  String of floating client identifier that was set during registration, see FloatingClient::register.

## ◆ validityPeriod()

virtual tm LicenseSpring::License::validityPeriod | ( |  | ) | const
| pure virtual

Getter for license validity period in local time.

Returns
  Time structure of license validity period in local time.

## ◆ validityPeriodUtc()

virtual tm LicenseSpring::License::validityPeriodUtc | ( |  | ) | const
| pure virtual

Getter for license validity period in UTC.

Returns
  Time structure of validity period in UTC.

## ◆ validityWithGracePeriod()

virtual tm LicenseSpring::License::validityWithGracePeriod | ( |  | ) | const
| pure virtual

Getter for license validity period including grace period in local time.

Currently grace period meaningful only for Subscription licenses.

Returns
  Time structure of license validity period in local time.

## ◆ validityWithGracePeriodUtc()

virtual tm LicenseSpring::License::validityWithGracePeriodUtc | ( |  | ) | const
| pure virtual

Getter for license validity period including grace period in UTC.

Currently grace period meaningful only for Subscription licenses.

Returns
  Time structure of validity period in UTC.

## ◆ subscriptionGracePeriod()

virtual uint32_t LicenseSpring::License::subscriptionGracePeriod | ( |  | ) | const
| pure virtual

Getter for grace period of the Subscription license in hours.

For other type of licenses or if grace period is not set it returns 0.

Returns
  Unsigned integer of grace period of the Subscription license in hours.

## ◆ maxBorrowTime()

virtual uint32_t LicenseSpring::License::maxBorrowTime | ( |  | ) | const
| pure virtual

Maximum borrowing period in hours.

Meaningful only for floating license.

Returns
  Max borrow time or 0 if license borrowing is not allowed.

## ◆ maintenancePeriod()

virtual tm LicenseSpring::License::maintenancePeriod | ( |  | ) | const
| pure virtual

Getter for license maintenance period in local time.

Returns
  Time structure of the maintenance period in local time.

## ◆ maintenancePeriodUtc()

virtual tm LicenseSpring::License::maintenancePeriodUtc | ( |  | ) | const
| pure virtual

Getter for license maintenance period in UTC.

Returns
  Time structure of the maintenance period in UTC.

## ◆ lastCheckDate()

virtual tm LicenseSpring::License::lastCheckDate | ( |  | ) | const
| pure virtual

Getter for license last check date in local time.

Returns
  Time structure of the last check date in local time.

## ◆ lastCheckDateUtc()

virtual tm LicenseSpring::License::lastCheckDateUtc | ( |  | ) | const
| pure virtual

Getter for license last check date in UTC.

Returns
  Time structure of the last check date in UTC.

## ◆ floatingEndDateTime()

virtual tm LicenseSpring::License::floatingEndDateTime | ( |  | ) | const
| pure virtual

Getter for floating license validity end date time in local time zone.

Meaningful only for floating licenses.

Returns
  Time structure representing end datetime of the floating license in local time.

## ◆ floatingEndDateTimeUtc()

virtual tm LicenseSpring::License::floatingEndDateTimeUtc | ( |  | ) | const
| pure virtual

Floating license validity end date time in UTC.

Meaningful only for floating licenses.

Returns
  Time structure representing end datetime of the floating license.

## ◆ startDate()

virtual const std::string& LicenseSpring::License::startDate | ( |  | ) | const
| pure virtual

Getter method license start date.

See https://docs.licensespring.com/docs/license-start-date

Returns
  License start date in a format Y-m-d, if start date is not set for the License the string is empty.

## ◆ metadata()

virtual const std::string& LicenseSpring::License::metadata | ( |  | ) | const
| pure virtual

Getter for license metadata.

Returns
  String of license metadata json.

## ◆ feature()

virtual LicenseFeature LicenseSpring::License::feature | ( | const std::string & | featureCode | ) | const
| pure virtual

Getter method for license feature.

Parameters

  featureCode | Feature code of the feature to get.

Returns
  LicenseFeature structure with the provided feature code.

Exceptions

  InvalidLicenseFeatureException | If license feature with given code not found

## ◆ features()

virtual std::vector<LicenseFeature> LicenseSpring::License::features | ( |  | ) | const
| pure virtual

Getter for list of license features associated with the license.

Returns
  List of LicenseFeature objects associated with the license.

## ◆ customFields()

virtual std::vector<CustomField> LicenseSpring::License::customFields | ( |  | ) | const
| pure virtual

Getter for list of custom fields associated with the license.

Returns
  List of CustomField objects associated with the license.

## ◆ userData() [1/2]

virtual const std::vector<CustomField>& LicenseSpring::License::userData | ( |  | ) | const
| pure virtual

Returns user data stored within license object.

Returns
  Reference to const std::vector of CustomField objects.

Note
  There are multiple methods with the same name and different parameters.

## ◆ userData() [2/2]

virtual std::string LicenseSpring::License::userData | ( | const std::string & | key | ) | const
| pure virtual

Getter for user data by given key.

Parameters

  key | Key of data field to search.

Returns
  Data field value or empty string if provided key was not found.

Note
  There are multiple methods with the same name and different parameters.

## ◆ addUserData()

virtual void LicenseSpring::License::addUserData | ( | const CustomField & | data,
|  | bool | saveLicense = `true`
| ) |  |
| pure virtual

Adds user data to the license object. This method allows you to store custom data securely inside license file.

Parameters

  data | Key/value entry to be saved.
  saveLicense | Optional parameter indicating whether license should be saved to the file after modification.

To correctly store strings that contain Unicode characters, make sure the string is encoded in UTF-8,
when creating CustomField, for example: std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes( L"示例文本" )

## ◆ removeUserData()

virtual void LicenseSpring::License::removeUserData | ( | const std::string & | key = `std::string()`,
|  | bool | saveLicense = `true`
| ) |  |
| pure virtual

Removes user data from the license.

Parameters

  key | Key of data field that should be removed, if key is empty this method clears entire user data.
  saveLicense | Optional parameter indicating whether license should be saved to the file after modification.

## ◆ totalConsumption()

virtual int32_t LicenseSpring::License::totalConsumption | ( |  | ) | const
| pure virtual

Returns license current total consumption.

Meaningful only for Consumption license type.

## ◆ maxConsumption()

virtual int32_t LicenseSpring::License::maxConsumption | ( |  | ) | const
| pure virtual

Returns license maximum consumption.

Meaningful only for Consumption license type.

## ◆ maxOverages()

virtual int32_t LicenseSpring::License::maxOverages | ( |  | ) | const
| pure virtual

Returns maximum overage allowed for the license.

Meaningful only for Consumption license type, returns maximum possible value in case of unlimited overages.

## ◆ isOveragesAllowed()

virtual bool LicenseSpring::License::isOveragesAllowed | ( |  | ) | const
| pure virtual

Checks if overage is allowed for Consumption license.

Meaningful only for Consumption license type.

## ◆ isUnlimitedConsumptionAllowed()

virtual bool LicenseSpring::License::isUnlimitedConsumptionAllowed | ( |  | ) | const
| pure virtual

Checks if unlimited consumption is allowed for Consumption license.

Meaningful only for Consumption license type.

## ◆ consumptionPeriod()

virtual ConsumptionPeriod LicenseSpring::License::consumptionPeriod | ( |  | ) | const
| pure virtual

Returns period of time after which consumption is reset.

Meaningful only for Consumption license type

## ◆ isResetConsumptionEnabled()

virtual bool LicenseSpring::License::isResetConsumptionEnabled | ( |  | ) | const
| pure virtual

Checks if consumption reset is allowed for Consumption license.

Meaningful only for Consumption license type

## ◆ timesActivated()

virtual uint32_t LicenseSpring::License::timesActivated | ( |  | ) | const
| pure virtual

How many times license already been activated.

Returns
  Current number of activations for the license.

## ◆ maxActivations()

virtual uint32_t LicenseSpring::License::maxActivations | ( |  | ) | const
| pure virtual

How many times license can be activated.

Returns
  Maximum number of activations for the license.

## ◆ transferCount()

virtual uint32_t LicenseSpring::License::transferCount | ( |  | ) | const
| pure virtual

How many times license has been transferred between devices.

Returns
  Transfer count of the license.

## ◆ transferLimit()

virtual int32_t LicenseSpring::License::transferLimit | ( |  | ) | const
| pure virtual

Maximum number of allowed license transfers between devices.

Returns
  Maximum device transfer limit of the license, -1 for unlimited device transfers, 0 if device transfers are not allowed.

## ◆ isDeviceTransferAllowed()

virtual bool LicenseSpring::License::isDeviceTransferAllowed | ( |  | ) | const
| pure virtual

Checks if license can be transferred between devices.

Returns
  True if license is transferable between devices, otherwise returns false.

## ◆ isDeviceTransferLimited()

virtual bool LicenseSpring::License::isDeviceTransferLimited | ( |  | ) | const
| pure virtual

Checks if the license allows only limited number of transfers between devices.

Returns
  True if license device transfers are limited, otherwise returns false.

## ◆ isAutoReleaseSet()

virtual bool LicenseSpring::License::isAutoReleaseSet | ( |  | ) | const
| pure virtual

Returns auto release flag. Meaningful only for floating license.

By default this flag is true for floating license.

Returns
  Boolean value indicating if license will be automatically released in the destructor.

## ◆ setAutoRelease()

virtual void LicenseSpring::License::setAutoRelease | ( | bool | autoRelease | ) |
| pure virtual

Sets auto release flag. Meaningful only for floating license.

Parameters

  autoRelease | Indicates whether SDK should automatically release floating license in the destructor.

## ◆ updateConsumption()

virtual void LicenseSpring::License::updateConsumption | ( | int32_t | value = `1`,
|  | bool | saveLicense = `true`
| ) |  |
| pure virtual

Increase or decrease license consumption by given value.

Parameters

  value | Consumption value to be added, note it can be negative, so you can decrease consumption.
  saveLicense | Controls whether license should be saved to file.

Exceptions

  NotEnoughConsumptionException | If license run out of resource.
  LicenseSpringException | If license is not of Consumption type.

## ◆ updateFeatureConsumption()

virtual void LicenseSpring::License::updateFeatureConsumption | ( | const std::string & | featureCode,
|  | int32_t | value = `1`,
|  | bool | saveLicense = `true`
| ) |  |
| pure virtual

Increase or decrease feature consumption by given value.

Parameters

  featureCode | Feature code.
  value | Consumption value to be added, note it can be negative, so you can decrease consumption.
  saveLicense | Controls whether license should be saved to file.

Exceptions

  NotEnoughConsumptionException | If license run out of resource.
  LicenseSpringException | If license is not of Consumption type.

## ◆ isExpired()

virtual bool LicenseSpring::License::isExpired | ( |  | ) | const
| pure virtual

Compare system date time with license validity date time.

This method also returns true if floating period expired for floating license.

Returns
  True if expired (system date time is later than validity date time), false if not.

## ◆ isMaintenancePeriodExpired()

virtual bool LicenseSpring::License::isMaintenancePeriodExpired | ( |  | ) | const
| pure virtual

Compare system date time with maintenance period time.

Returns
  True if maintenance period expired (system date time is later than maintenance period time), false if not.

## ◆ daysRemainingUtc()

virtual int LicenseSpring::License::daysRemainingUtc | ( |  | ) | const
| pure virtual

How many days remaining till license expires.

For Subscription license it also counts grace period if set.

Returns
  Integer representing days remaining till license expires in UTC.

## ◆ daysRemaining()

virtual int LicenseSpring::License::daysRemaining | ( |  | ) | const
| pure virtual

Almost the same as UTC counterpart, but days counter will be changed on local midnight.

For Subscription license it also counts grace period if set.

Returns
  Integer representing days remaining till license expires in local time.

## ◆ maintenanceDaysRemaining()

virtual int LicenseSpring::License::maintenanceDaysRemaining | ( |  | ) | const
| pure virtual

How many days remaining till end of maintenance days.

Returns
  Integer representing days remaining till end of maintenance days.

## ◆ daysPassedSinceLastCheck()

virtual int LicenseSpring::License::daysPassedSinceLastCheck | ( |  | ) | const
| pure virtual

How many days passed from last online check.

Returns
  Integer representing days passed since last online check.

## ◆ localCheck()

virtual void LicenseSpring::License::localCheck | ( |  | ) |
| pure virtual

Check license local without connection to the backend.

Exceptions

  LicenseStateException | In case license disabled, inactive or expired
  FloatingTimeoutExpiredException | In case floating period expired
  ProductMismatchException | In case license does not belong to configured product
  DeviceNotLicensedException | In case license does not belong to current computer
  VMIsNotAllowedException | If currently running on VM but it is not allowed
  ClockTamperedException | Detected cheating with system clock

## ◆ deactivate()

virtual bool LicenseSpring::License::deactivate | ( | bool | removeLocalData = `false` | ) |
| pure virtual

Sends deactivate license request to the backend.

Parameters

  removeLocalData | If true this method will remove local license file and folders created by the SDK in other words setting this param true is equivalent to call LicenseManager::clearLocalStorage after deactivation.

Exceptions

  LicenseNotFoundException | In case provided license was not found, for example removed by admin using the platform or management API)
  LicenseStateException | In case license is disabled or already inactive
  DeviceNotLicensedException | In case license does not belong to current computer
  DeviceBlacklistedException | If device has been blacklisted by product manager
  NoInternetException | If cannot reach the server
  NetworkTimeoutException | In case of network timeout
  LicenseServerException | In case of internal server error, the backend returned http error code >= 500
  UnknownLicenseSpringException | In rare case if something went wrong, please contact support

## ◆ changePassword()

virtual bool LicenseSpring::License::changePassword | ( | const std::string & | password,
|  | const std::string & | newPassword
| ) |  |
| pure virtual

Change password for user based license.

Parameters

  password | Old password for user.
  newPassword | New password to change to.

Returns
  True if successfully changed and false otherwise.

## ◆ check()

virtual InstallationFile::ptr_t LicenseSpring::License::check | ( | const InstallFileFilter & | filter = `InstallFileFilter()`,
|  | bool | includeExpiredFeatures = `false`
| ) |  |
| pure virtual

Online license check, sync the license with the backend, throws exceptions in case of errors.

Parameters

  filter | Optional, you can filter install files by environment and channel.
  includeExpiredFeatures | Optional, when set to true, the license check includes expired license features.

Returns
  The most recent InstallationFile available for the license (useful for managing software updates). Returns null in case request failed and grace period started.

Exceptions

  LicenseStateException | In case license disabled, was reset or expired
  DeviceNotLicensedException | In case license does not belong to current computer
  DeviceBlacklistedException | If device has been blacklisted by product manager (for Floating license)
  MaxFloatingReachedException | If no more floating licenses are available
  NoInternetException | If cannot reach the server
  NetworkTimeoutException | In case of network timeout
  LicenseServerException | In case of internal server error
  UnknownLicenseSpringException | In rare case if something went wrong, please contact support

## ◆ syncConsumption()

virtual bool LicenseSpring::License::syncConsumption | ( | int32_t | requestOverage = `-1` | ) |
| pure virtual

Sync Consumption license with the server.

Parameters

  requestOverage | Optional argument that allows to request consumption overage. If argument value is negative (default) this means do nothing, if value is 0 it means disable consumption overage. If value is positive it means allow overage and set max overage to provided value.

Returns
  Bool value indicating if consumption was synchronized. Returns false in case request failed and grace period started.

Exceptions

  NotEnoughConsumptionException | If consumption license run out of resource
  DeviceBlacklistedException | If device has been blacklisted by product manager (for Floating license)
  NoInternetException | If cannot reach the server
  NetworkTimeoutException | In case of network timeout
  LicenseServerException | In case of internal server error
  SignatureMismatchException | In case signature returned by LicenseSpring server is not valid
  UnknownLicenseSpringException | In rare case if something went wrong, please contact support

## ◆ syncFeatureConsumption()

virtual bool LicenseSpring::License::syncFeatureConsumption | ( | const std::string & | featureCode = `std::string()` | ) |
| pure virtual

Sync Consumption Feature(s) with the backend, if code not provided sync all consumption features.

Parameters

  featureCode | Code of the license feature that need to be synchronized. Pass empty string to sync all consumption features (default).

Returns
  Bool value indicating if consumption was synchronized. Returns false in case request failed and grace period started.

Exceptions

  NotEnoughConsumptionException | If consumption license feature run out of resource
  InvalidLicenseFeatureException | If license feature with given code not found or not of consumption type
  DeviceBlacklistedException | If device has been blacklisted by product manager (for Floating license)
  NoInternetException | If cannot reach the server
  NetworkTimeoutException | In case of network timeout
  LicenseServerException | In case of internal server error
  SignatureMismatchException | In case signature returned by LicenseSpring server is not valid
  UnknownLicenseSpringException | In rare case if something went wrong, please contact support

## ◆ addDeviceVariable() [1/2]

virtual void LicenseSpring::License::addDeviceVariable | ( | const std::string & | name,
|  | const std::string & | value,
|  | bool | saveLicense = `true`
| ) |  |
| pure virtual

Add new or update existing device variable to license daata.

Variable will be stored in local license, in order to send device variables to the backend see License::sendDeviceVariables.
To correctly send strings that contain Unicode characters, make sure the string is encoded in UTF-8,
for example: std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes( L"示例文本" )

Parameters

  name | Device variable name
  value | Device variable value
  saveLicense | Optional parameter indicating whether license should be saved localy after modification

Note
  There are multiple methods with the same name and different parameters.

## ◆ addDeviceVariable() [2/2]

virtual void LicenseSpring::License::addDeviceVariable | ( | const DeviceVariable & | variable,
|  | bool | saveLicense = `true`
| ) |  |
| pure virtual

Add new or update existing device variable to license daata.

Variable will be stored in local license, in order to send device variables to the backend see License::sendDeviceVariables

Parameters

  variable | Device variable
  saveLicense | Optional parameter indicating whether license should be saved localy after modification

Note
  There are multiple methods with the same name and different parameters.

## ◆ addDeviceVariables()

virtual void LicenseSpring::License::addDeviceVariables | ( | const std::vector< DeviceVariable > & | variables | ) |
| pure virtual

Add new or update existing device variables to license daata.

Variables will be stored in local license

Parameters

  variables | Device variables

## ◆ sendDeviceVariables()

virtual bool LicenseSpring::License::sendDeviceVariables | ( |  | ) |
| pure virtual

Send current device variables list to the backend (see device variables on the platform)

This method does nothing if local license does not have any variables.

Returns
  Bool value indicating if device variables were sent. Returns false if there are no device variables or in case request failed and grace period started.

Exceptions

  NoInternetException | If cannot reach the server
  NetworkTimeoutException | In case of network timeout
  UnknownLicenseSpringException | In rare case if something went wrong

## ◆ getDeviceVariables()

virtual std::vector<DeviceVariable> LicenseSpring::License::getDeviceVariables | ( | bool | getFromBackend = `false` | ) |
| pure virtual

Get device variables from the local license or from the backend.

This method does not throw exceptions if you getting variables list from local license or during grace period.

Parameters

  getFromBackend | Indicates if you want to request device variables list from local license or backend

Returns
  Variable list for current device

Exceptions

  NoInternetException | If cannot reach the server
  NetworkTimeoutException | In case of network timeout
  UnknownLicenseSpringException | In rare case if something went wrong

## ◆ deviceVariable()

virtual DeviceVariable LicenseSpring::License::deviceVariable | ( | const std::string & | name | ) | const
| pure virtual

Get device variable by name.

Returns empty device variable if the variable does not exist

Returns
  Device variable

## ◆ deviceVariableValue()

virtual const std::string& LicenseSpring::License::deviceVariableValue | ( | const std::string & | name | ) | const
| pure virtual

Get device variable value by name.

Parameters

  name | Device variable name

Returns
  Device variable value or empty string if variable does not exist

## ◆ setupLicenseWatchdog()

virtual void LicenseSpring::License::setupLicenseWatchdog | ( | LicenseWatchdogCallback | callback,
|  | uint32_t | timeout = `0`
| ) |  |
| pure virtual

Setup and run license watchdog, a background thread which periodically checks the license.

This is especially useful for floating licenses, but can be used for any.
Provided callback will be called in case of errors.
Timeout in minutes, 0 means use default (for Floating license it's floatingTimeout, for others - 1 hour).

Exceptions

  WatchdogException | If cannot start watchdog thread.

## ◆ resumeLicenseWatchdog()

virtual void LicenseSpring::License::resumeLicenseWatchdog | ( |  | ) |
| pure virtual

Resume background thread, you can call this within your callback in order to resume periodic license checks (registrations).

Exceptions

  WatchdogException | If cannot start watchdog thread.

## ◆ stopLicenseWatchdog()

virtual void LicenseSpring::License::stopLicenseWatchdog | ( |  | ) |
| pure virtual

Stops license watchdog background thread.

This method does not revoke floating license, just stops the watchdog.

## ◆ setupFeatureWatchdog()

virtual void LicenseSpring::License::setupFeatureWatchdog | ( | LicenseWatchdogCallback | callback,
|  | uint32_t | timeout = `0`
| ) |  |
| pure virtual

Setup and run feature watchdog, a background thread which periodically checks floating license features.

Useful only for floating features. Provided callback will be called in case of errors.
Timeout in minutes, 0 means use smallest floating timeout between all currently active floating features.

Exceptions

  WatchdogException | If cannot start watchdog thread.

## ◆ resumeFeatureWatchdog()

virtual void LicenseSpring::License::resumeFeatureWatchdog | ( |  | ) |
| pure virtual

Resume background thread, you can call this within your callback in order to resume periodic feature checks (registrations).

Exceptions

  WatchdogException | If cannot start watchdog thread.

## ◆ stopFeatureWatchdog()

virtual void LicenseSpring::License::stopFeatureWatchdog | ( |  | ) |
| pure virtual

Stops feature watchdog background thread.

This method does not release the floating feature, just stops the watchdog.

## ◆ registerFloatingLicense()

virtual void LicenseSpring::License::registerFloatingLicense | ( |  | ) |
| pure virtual

Register floating license using floatingClientId.

In order to keep floating license alive you should check in (register) it periodically. This is equivalent to check license online See also License::setupLicenseWatchdog. Alternatively you can register floating license by calling License::check.

Exceptions

  MaxFloatingReachedException | If no more floating licenses are available

## ◆ releaseFloatingLicense()

virtual void LicenseSpring::License::releaseFloatingLicense | ( | bool | throwExceptions = `false` | ) |
| pure virtual

Revoke floating license, typically should be called at the end of app execution.

This API call will also release (return) borrowed license.

See also
  See also License::setAutoRelease, when set license will be automatically revoked when destroyed.

Exceptions

  LicenseStateException | If license is invalid, disabled or expired
  NoInternetException | If cannot reach the server
  NetworkTimeoutException | In case of network timeout
  LicenseServerException | In case of internal server error
  UnknownLicenseSpringException | In rare case if something went wrong, please contact support

## ◆ borrow() [1/2]

virtual void LicenseSpring::License::borrow | ( | uint32_t | hours,
|  | uint32_t | days = `0`
| ) |  |
| pure virtual

Borrow floating license for provided time interval.

Meaningful only for floating licenses.
If borrowing succeeded watchdog (if set) will be stopped and license auto release flag will be set to false. During borrow period there is no need to register floating license to keep it alive.

Parameters

  hours | Count of hours from now you want borrow license for.
  days | Count of days from now you want borrow license for.

Exceptions

  NoInternetException | If cannot reach the server
  NetworkTimeoutException | In case of network timeout
  BorrowLicenseException | If borrowing is not allowed or provided borrowing period is bigger than max.

Note
  There are multiple methods with the same name and different parameters.

## ◆ borrow() [2/2]

virtual void LicenseSpring::License::borrow | ( | const std::string & | borrowEndDateTime = `std::string()` | ) |
| pure virtual

Borrow floating license till provided end date time.

Meaningful only for floating licenses.
If borrowing succeeded watchdog (if set) will be stopped and license auto release flag will be set to false.

Parameters

  borrowEndDateTime | Borrow end date time in UTC in format "%Y-%m-%dT%H:%M:%SZ", for example "2022-05-28T15:30:00Z" If it's empty the license will be borrowed for max possible period.

Exceptions

  NoInternetException | If cannot reach the server
  NetworkTimeoutException | In case of network timeout
  BorrowLicenseException | If borrowing is not allowed or provided borrowing period is bigger than max.

Note
  There are multiple methods with the same name and different parameters.

## ◆ deactivateOffline()

virtual std::wstring LicenseSpring::License::deactivateOffline | ( | const std::wstring & | deactivationRequestFile = `std::wstring()` | ) |
| pure virtual

Creates offline deactivation file request.

Parameters

  deactivationRequestFile | Deactivation request file path, empty means use default path (Desktop)

Exceptions

  LocalLicenseException | Thrown if could not read license file or if local license corrupted

## ◆ updateOffline()

virtual bool LicenseSpring::License::updateOffline | ( | const std::wstring & | path,
|  | bool | resetConsumption = `false`
| ) |  |
| pure virtual

Update license data accordingly to provided file.

Parameters

  path | Update file path
  resetConsumption | False by default, set to true to reset consumption.

Returns
  True if license successfully updated and false otherwise

Exceptions

  LocalLicenseException | Thrown if could not read license file or if local license corrupted.
  SignatureMismatchException | Thrown if license signature is not valid.
  ProductMismatchException | If license product code does not correspond to configuration product code
  DeviceNotLicensedException | If license refresh file does not correspond to current device.

## ◆ unlinkFromDevice()

virtual void LicenseSpring::License::unlinkFromDevice | ( |  | ) |
| pure virtual

Unlinks license from cuurent device ID.

Checks if license belongs to this device and deactivates it. May throw exceptions same as deactivate method.

Exceptions

  ProductMismatchException | If license product code does not correspond to configuration product code
  DeviceNotLicensedException | If license does not correspond to current device.

## ◆ getAirGapDeactivationCode()

virtual std::string LicenseSpring::License::getAirGapDeactivationCode | ( | const std::string & | initializationCode | ) |
| pure virtual

Get air gap Deactivation code.

Parameters

  initializationCode | Code received from the air gap activation portal.

Returns
  Air gap Dectivation code. Empty string in case of error.

## ◆ deactivateAirGap()

virtual void LicenseSpring::License::deactivateAirGap | ( | const std::string & | confirmationCode | ) |
| pure virtual

Verify Confirmation code and deactivate air gap license.

Parameters

  confirmationCode | Code received from the air gap activation portal.

Exceptions

  AirGapActivationException | In case confirmation code from the air gap activation portal is invalid.

## ◆ isLicenseBelongsToThisDevice()

virtual bool LicenseSpring::License::isLicenseBelongsToThisDevice | ( | DeviceIDAlgorithm | deviceIDAlgorithm | ) |
| pure virtual

Checks if license belongs to this DeviceIDAlgorithm.

Parameters

  deviceIDAlgorithm | DeviceIDAlgorithm value

## ◆ checkLicenseBelongsToThisDevice()

virtual bool LicenseSpring::License::checkLicenseBelongsToThisDevice | ( |  | ) |
| pure virtual

Checks if license belongs to any of the DeviceIDAlgorithm values.

## ◆ registerFloatingFeature()

virtual void LicenseSpring::License::registerFloatingFeature | ( | const std::string & | featureCode,
|  | bool | addToWatchdog = `true`
| ) |  |
| pure virtual

Register a floating feature and occupy a floating slot.

Parameters

  featureCode | Feature code of the feature to register
  addToWatchdog | True by default, set to false to avoid adding floating feature to watchdog

Exceptions

  InvalidLicenseFeatureCodeException | If feature code is not found on license

## ◆ releaseFloatingFeature()

virtual void LicenseSpring::License::releaseFloatingFeature | ( | const std::string & | featureCode | ) |
| pure virtual

Release a floating feature and free a floating slot.

Parameters

  featureCode | Feature code of the feature to register

Exceptions

  InvalidLicenseFeatureCodeException | If feature code is not found on license
  FeatureNotFloatingException | If releasing a device on a non-floating license feature
  FloatingFeatureDeviceNotInUseException | If device was never used to check a license feature

## Member Data Documentation

## ◆ MaxDaysRemainingValue

const int LicenseSpring::License::MaxDaysRemainingValue
| static

Maximum value for daysRemaining, e.g. in case of perpetual license.

Returns
  Integer representing max value for daysRemaining.

Definition at line 367 of file License.h.

The documentation for this class was generated from the following file:

- LicenseSpring/License.h