Licensing
Overview
Licensing is a system that controls the usage and distribution of features within an application, ensuring that only authorized users can access specific functionalities based on defined terms and conditions.
Licensing generally falls into two categories:
- User-Based Licensing: Charges users based on the specific features they are entitled to use.
- Transaction-Based Licensing: Charges users based on the number of transactions or actions performed within the application.
Implementation of Licensing
In general, licensing can be implemented in two main ways, depending on the developer's requirements:
If the developer wants to restrict access to specific feature within the application, they can use annotations to manage this at a granular level.
If the developer intends to block access to the entire application, they can implement an interface-based approach to enforce licensing across all components.
Using Annotation: ~@FeatureEntitlement
Developers can secure controllers by annotating them with @FeatureEntitlement
, passing the required product code for feature entitlement checks. This annotation ensures that only authorized users can access the associated features at runtime.
Sample Code:
@RestController("controller-name")
@FeatureEntitlement(PRODUCT_CODE)
public class FeatureController {
// Controller logic here
}
Annotation is used to secure the featureController
with the specified product code (PRODUCT_CODE
),
which ensures that only users with the appropriate entitlement can access the controller's functionality.
Using Interface ~IProductEntitlementCheckEx
Developers can enable feature entitlement checks, using the IFeatureEntitlementCheckEx
interface. Any solution that needs to implement custom feature entitlement logic should implement this interface.
Sample Code:
package com.opentext.d2.rest.context.jc;
import org.springframework.stereotype.Component;
import com.documentum.fc.client.impl.session.ISession;
import com.opentext.common.IProductEntitlementCheckEx;
@Component // Ensures this class is registered as a Spring bean
public class CustomFeatureEntitlementCheck implements IProductEntitlementCheckEx {
@Override
public boolean isEntitled(ISession session) {
boolean isEntitled = false;
// Custom logic to determine if the user has the required feature entitlement
return isEntitled;
}
}
The package of this file needs to be appended in rest-api-runtime.properties file so that spring can load it.
rest.context.config.location=com.opentext.d2.rest.context.jc
For more information on Java Documentation you can refer here