IActivation interface
The license state can be accessed and manipulated through the IActivation interface. Let's look more closely at the most common licensing use cases and how they can be handled using our SDK.
Info
The IActivation
interface is the central component of the Zentitle C++ SDK. It provides a complete abstraction for managing license activation in online and offline modes, tracking state transitions, and accessing licensing features.
All licensing-related operations, such as activation, deactivation, lease refresh, and feature usage, are exposed through this interface. The stateful nature of IActivation
ensures that your application logic can always make informed decisions based on the current license state.
Features
You can access the activation features using the features() method.
To retrieve the set of features bound to a license:
std::shared_ptr<Activation> activation = Activation::create(
// configure the options by following the instructions below }
);
Or request a specific feature using. get
API:
auto feature = features->get("feature-key");
if (feature) {
std::cout << "Feature " << feature->toString() << std::endl;
}
State
The seat's activation state can be accessed through the activation.State
property.
Possible activation states:
Uninitialized
: The local activation state has not yet been initialized from the local persistence.Active
: The seat and its entitlement (license) are active.LeaseExpired
: Seat activation's lease period expired.NotActivated
: The seat has not been activated yet, or it has been deactivated, or the activation seat has been deleted on the server.EntitlementNotActive
: The seat has been activated, but the entitlement (license) is not active (disabled, expired, etc.)
Usage
ActivationState
is used in the IActivation
An interface to represent the current state of the activation. It helps understand the context and make decisions based on the activation's state during various activation-related operations.
For example, when calling the Initialize
method in the IActivation
interface, the activation state should be Uninitialized
. After successful initialization, the state may transition to Active
, LeaseExpired
, NotActivated
, or EntitlementNotActive
based on specific conditions.
Understanding the activation state is crucial for implementing robust licensing logic within your application. Refer to the methods' documentation below for more details on using activation states in the licensing client.
Methods
Initialize
[[nodiscard]] virtual std::future<void> initialize() = 0;
Description: Initializes the activation from the locally persisted state.
Allowed in States:
Uninitialized
Transitions To:
Active
- When the seat has been successfully activated, and its lease has not expired.LeaseExpired
- When the seat has been activated, but its lease has expired.NotActivated
- When there is no activated seat.EntitlementNotActive
- When there is an activated seat, but the entitlement has expired or has been disabled.
Activate
[[nodiscard]] virtual std::future<void> initialize() = 0;
Description: Activates the seat in online mode.
Allowed in States:
NotActivated
,EntitlementNotActive
Transitions To:
Active
- When the seat has been successfully activated on the server.
GenerateOfflineActivationRequestToken
[[nodiscard]] virtual std::future<std::string> generateOfflineActivationRequestToken(
const std::string& activationCode,
const std::string& seatName = "",
const std::string& stateMetadata = "") = 0;
Description: Generates a request token for offline activation.
Allowed in States:
NotActivated
,LeaseExpired
,EntitlementNotActive
Transitions To: None.
ActivateOffline
[[nodiscard]] virtual std::future<std::string> activateOffline(
const std::string& offlineActivationResponseToken) = 0;
Description: Activates the seat offline with the token received from the EUP.
Allowed in States:
NotActivated
,LeaseExpired
,EntitlementNotActive
Transitions To:
Active
- When the offline activation response token was successfully applied.
DeactivateOffline
[[nodiscard]] virtual std::future<std::string> deactivateOffline() = 0;
Description: Deactivate the offline-activated seat.
Allowed in States:
Active
,LeaseExpired
,EntitlementNotActive
(whenInfo.Mode
:ActivationMode.Offline
)Transitions To:
NotActivated
- When the deactivation token has been successfully generated, and the activation state has been deleted from local storage.
Deactivate
[[nodiscard]] virtual std::future<ActivationOperationRes> deactivate() = 0;
Description: Deletes the online-activated seat from the Licensing Server.
Allowed in States:
Active
,LeaseExpired
,EntitlementNotActive
(whenInfo.Mode
:ActivationMode.Online
)Transitions To:
NotActivated
- When the seat deactivation has been successful and the activation has been removed from the licensing server.EntitlementNotActive
- When the entitlement has expired or has been disabled.
RefreshLease
[[nodiscard]] virtual std::future<ActivationOperationRes> refreshLease() = 0;
Description: Refreshes the online activation's lease time. They should be called periodically before the activation's lease period expires; otherwise, the activation transitions into the
LeaseExpired
state.Allowed in States:
Active
,LeaseExpired
(WhenInfo.Mode
:ActivationMode.Online
)Transitions To:
None - When called in
Active
state and the lease period is successfully refreshed.Active
- When called inLeaseExpired
state, and the lease period is successfully refreshed.NotActivated
- When the seat activation has been deleted on the server.EntitlementNotActive
- When the seat activation exists on the server, but the entitlement has expired or been disabled.
RefreshLeaseOffline
[[nodiscard]] virtual std::future<void> refreshLeaseOffline(
const std::string& offlineRefreshToken) = 0;
Description: Refreshes the offline activation's lease period.
Allowed in States:
Active
,LeaseExpired
(WhenInfo.Mode
:ActivationMode.Offline
)Transitions To:
None - When called in
Active
The state and the lease period are successfully refreshed.Active
- When called inLeaseExpired
The state and the lease period are successfully refreshed.
PullRemoteState
[[nodiscard]] virtual std::future<ActivationStateModel> pullRemoteState() = 0;
Description: Pulls the current activation's state from the remote Licensing server and updates the local activation's state accordingly.
Allowed in States:
Active
,LeaseExpired
,EntitlementNotActive
(whenInfo.Mode
:ActivationMode.Online
)Transitions To:
None - When the activation state on the server matches the local activation state.
Active
- When the seat and the entitlement are active on the Licensing server.LeaseExpired
- When the seat has been activated, but its lease has expired.NotActivated
- When the seat activation has been deleted on the server.EntitlementNotActive
- When the seat activation exists on the server, but the entitlement has expired or been disabled.
PullPersistedState
[[nodiscard]] virtual std::future<Persistence::PersistentData> pullPersistedState() = 0;
Description: Pulls the current activation's state from persistent storage and updates the activation's in-memory state if necessary.
Allowed in States:
NotActivated
,Active
,LeaseExpired
,EntitlementNotActive
Transitions To:
None - When the activation state in persistent storage matches the in-memory activation state.
Active
LeaseExpired
NotActivated
EntitlementNotActive
GetActivationEntitlement
[[nodiscard]] virtual std::future<ActivationEntitlementModel> getActivationEntitlement() = 0;
Description: Returns details about the entitlement associated with the current activation.
Allowed in States:
Active
,LeaseExpired
,EntitlementNotActive
Transitions To: None.
Features operations
Checkout a Feature
Checkout feature to track consumption of a consumable or element pool resource:
virtual std::future<void> checkoutFeature(
const std::string& key,
long amount) = 0;
Return a Feature
virtual std::future<void> returnFeature(
const std::string& key,
long amount) = 0;
Track Feature Usage
virtual std::future<void> trackUsage(
const std::string& key) = 0;
Last updated
Was this helpful?