IActivation interface

The license state can be accessed and manipulated through the IActivationinterface. Let's take a better look into the most common licensing use cases and how they can be handled using our SDK.

Info

Information such as activation ID, entitlement ID, lease expiry, seat name, etc. can be retrieved via the activation.getInfo() method.

Features

You can access and manipulate the activation features using the activation.getFeatures() method.

Available methods:

  • ActivationFeature get(String featureKey);

    Returns activation feature by the given key. If there is no such a feature, null is returned.

  • void checkout(String key, long amount);

    Check out the feature from the licensing server.

    ! Only available in Active state.

  • void returnFeature(String key, long amount);

    Return the previously checked-out feature to the licensing server.

    ! Only available in Active state.

  • void trackUsage(String key);

    Check if the feature is available at the licensing server.

    ! Only available in Active state.

State

The seat's activation state can be accessed through the activation.getState() method.

Possible activation states:

  • UNINITIALIZED: The local activation state has not been initialized from the local persistence yet.

  • ACTIVE: The seat and its entitlement (license) are active.

  • LEASE_EXPIRED: Seat activation's lease period expired.

  • NOT_ACTIVATED: The seat has not been activated yet, or it has been deactivated, or the activation seat has been deleted on the server.

  • ENTITLEMENT_NOT_ACTIVE: The seat has been activated, but the entitlement (license) is not active (disabled, expired, etc.)

Usage

ActivationState is used in the IActivation interface to represent the current state of the activation. It helps in understanding the context and making 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, LEASE_EXPIRED, NOT_ACTIVATED, or ENTITLEMENT_NOT_ACTIVE 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

void initialize()
  • 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.

    • LEASE_EXPIRED - When the seat has been activated, but its lease has expired.

    • NOT_ACTIVATED - When there is no activated seat.

    • ENTITLEMENT_NOT_ACTIVE - When there is an activated seat, but the entitlement has expired or has been disabled.

Activate

void activate(ActivationCredentialsModel activationCredentials, String seatName)
  • Description: Activates the seat in online mode.

  • Allowed in States: NOT_ACTIVATED, ENTITLEMENT_NOT_ACTIVE

  • Transitions To:

    • ACTIVE - When the seat has been successfully activated on the server.

GenerateOfflineActivationRequestToken

String generateOfflineActivationRequestToken(String activationCode, String seatName, String stateMetadata)
  • Description: Generates a request token for offline activation.

  • Allowed in States: NOT_ACTIVATED, LEASE_EXPIRED, ENTITLEMENT_NOT_ACTIVE

  • Transitions To: None.

ActivateOffline

String activateOffline(String offlineActivationResponseToken)
  • Description: Activates the seat offline with the token received from the EUP.

  • Allowed in States: NOT_ACTIVATED, LEASE_EXPIRED, ENTITLEMENT_NOT_ACTIVE

  • Transitions To:

    • ACTIVE - When the offline activation response token was successfully applied.

DeactivateOffline

String deactivateOffline()
  • Description: Deactivate the offline-activated seat.

  • Allowed in States: ACTIVE, LEASE_EXPIRED, ENTITLEMENT_NOT_ACTIVE

  • Transitions To:

    • NOT_ACTIVATED - When the deactivation token has been successfully generated, and the activation state has been deleted from local storage.

Deactivate

ActivationOperationRes deactivate()
  • Description: Deletes the online-activated seat from the Licensing Server.

  • Allowed in States: ACTIVE, LEASE_EXPIRED (when getInfo().getMode(): ActivationMode.ONLINE), ENTITLEMENT_NOT_ACTIVE

  • Transitions To:

    • NOT_ACTIVATED - When the seat deactivation has been successful and the activation has been removed from the licensing server.

RefreshLease

ActivationOperationRes refreshLease()
  • Description: Refreshes the online activation's lease time. Should be called periodically before the activation's lease period expires, otherwise the activation transitions into the LEASE_EXPIRED state.

  • Allowed in States: ACTIVE, LEASE_EXPIRED (When getInfo().getMode(): ActivationMode.ONLINE)

  • Transitions To:

    • None - When called in ACTIVE state and the lease period is successfully refreshed.

    • ACTIVE - When called in LEASE_EXPIRED state and the lease period is successfully refreshed.

    • NOT_ACTIVATED - When the seat activation has been deleted on the server.

    • ENTITLEMENT_NOT_ACTIVE - When the seat activation exists on the server, but the entitlement has expired or has been disabled.

RefreshLeaseOffline

void refreshLeaseOffline(String offlineRefreshToken)
  • Description: Refreshes the offline activation's lease period.

  • Allowed in States: ACTIVE, LEASE_EXPIRED (When getInfo().getMode(): ActivationMode.OFFLINE)

  • Transitions To:

    • None - When called in ACTIVE state and the lease period is successfully refreshed.

    • ACTIVE - When called in LEASE_EXPIRED state and the lease period is successfully refreshed.

PullRemoteState

void pullRemoteState()
  • Description: Pulls the current activation's state from the remote Licensing server and updates the local activation's state accordingly.

  • Allowed in States: ACTIVE, LEASE_EXPIRED, ENTITLEMENT_NOT_ACTIVE (when getInfo().getMode(): ActivationMode.ONLINE)

  • Transitions To:

    • None - When the activation state on the server matches the local activation state.

    • ACTIVE - When both the seat and the entitlement are active on the Licensing server.

    • LEASE_EXPIRED - When the seat has been activated, but its lease already expired.

    • NOT_ACTIVATED - When the seat activation has been deleted on the server.

    • ENTITLEMENT_NOT_ACTIVE - When the seat activation exists on the server, but the entitlement has expired or has been disabled.

PullPersistedState

void pullPersistedState()
  • Description: Pulls the current activation's state from persistent storage and updates the activation's in-memory state if necessary.

  • Allowed in States: NOT_ACTIVATED, ACTIVE, LEASE_EXPIRED, ENTITLEMENT_NOT_ACTIVE

  • Transitions To:

    • None - When the activation state in persistent storage matches the in-memory activation state.

    • ACTIVE

    • LEASE_EXPIRED

    • NOT_ACTIVATED

    • ENTITLEMENT_NOT_ACTIVE

GetActivationEntitlement

ActivationEntitlementData getActivationEntitlement()
  • Description: Returns details about the entitlement associated with the current activation.

  • Allowed in States: ACTIVE, LEASE_EXPIRED, ENTITLEMENT_NOT_ACTIVE

  • Transitions To: None.

Features operations

Checkout a Feature

Checkout feature to track consumption of a consumable or element pool resource:

// First, get the feature reference
Optional<IActivationFeature> feature = activation.getFeatures().tryGet("feature-key");
if (feature.isPresent())
{
    // Check if we have enough available
    if (feature.get().getAvailable() >= 5)
    {
        // Checkout 5 units of the feature
        activation.checkoutFeature(feature.get(), 5);

        // After checkout, the feature object is updated with the new available amount
        System.out.println("Remaining amount: " + feature.get().getAvailable());
    }
}

Note: The CheckoutFeature method is only available when the activation is in the Active state.

Return a Feature

Return previously checked-out units of an element pool feature:

// First, get the feature reference
Optional<IActivationFeature> feature = activation.getFeatures().tryGet("feature-key");
if (feature.isPresent()) {
    // Return 3 units of the feature
    activation.returnFeature(feature.get(), 3);

    // After return, the feature object is updated with the new available amount
    System.out.println("Available amount after return: " + feature.get().getAvailable());
}

Note: The ReturnFeature method is only available when the activation is in the Active state.

Track Feature Usage

For boolean features (enabled/disabled), you can track usage:

// First, get the feature reference
Optional<IActivationFeature> feature = activation.getFeatures().tryGet("feature-key");
if (feature.isPresent())
{
    // Track that this feature was used
    activation.trackFeatureUsage(feature);

    // Application code that uses the feature
    System.out.println("Feature used successfully");
}

Note: The TrackFeatureUsage method is only available when the activation is in the Active state, and only works with boolean features that are enabled on entitlement level.

Last updated

Was this helpful?