SDKs
...
Licensing Scenarios
License Type Options

Time-Limited

10min

In this guide, you'll learn how to manage time-limited licenses using the LicenseSpring SDKs.

This includes understanding validity periods, detecting license expiry with methods like "isExpired," implementing local checks, and gaining insights into remaining days for effective software access management.

By mastering these strategies, you can enhance your software distribution through precise time-based licensing techniques.

Prerequisites

  1. Completed the Getting Started Tutorial, including:
    • Initialized LicenseManager (or LicenseHandler) with your configuration using the appropriate settings.
    • Created a LicenseID using either LicenseID::fromKey or LicenseID::fromUser function, depending on the activation method you prefer.
    • Activated a license of any type.

Interpreting and Retrieving Validity Period

Upon configuring a new product in LicenseSpring, you gain the ability to set the default validity period for generated license keys.

This validity period signifies the duration in days between the initial activation of the license key and its expiration.

Note: A license key can be configured for perpetual validity or restricted within a specific time frame.

Retrieving Validity Period in Local Time

With our SDK, obtaining the validity period of a license key in your local time zone becomes a seamless process.

The validity period is stored within the License object and can be accessed by using the following method:

C++
C#
Java
Swift


Retrieving Validity Period in UTC

Developers also have the ability to get the validity period in UTC, rather than local time.

This is done with the following:

C++
C#
Python


How to Verify if a License has Expired

By employing our system, you can easily determine whether a license has expired or remains valid.

This process empowers you with accurate information to manage software access effectively, ensuring a seamless user experience.

Utilizing the "isExpired" Method to Check License Expiry

The isExpired() method provides an efficient way to check whether a license has reached its expiration date.

Our SDKs offer the ability to check the expiration status through the use of the following License methods:

C++
C#
Java
Swift
Python


Note: Our Java SDK's isExpired() method is called on the LicenseData object.

Implementing Local Checks for License Expiry

A local license check involves assessing the validity and expiration status of a software license within the immediate operating environment.

By performing checks locally, the software verifies the license's authenticity and expiration status without relying on external connections.

If the local license is expired, the SDKs will throw the following exceptions:

C++
C#
Java
Python


See License Checks for more information about local license checks.

Understanding the "Days Remaining" Value

Developers can also access a field within the License object that holds the number of days remiaining until the license expires.

This number of days can be retrieved using the following methods, in the current time zone and UTC, respectively:

C++
C#
Java
Python


Note: The Java SDK only offers the ability to retrieve the days remaining in the current time zone.