LICENSE4J
Home rarr Documents rarr Licensing Library rarr License Features

License Features

When creating a license, you have the option to specify features using key=value pairs within the license generation window. This allows you to customize the license by clearly defining each feature with a corresponding value, ensuring that the generated license meets your specific requirements. Simply enter the desired keys and their associated values in the designated fields to define the features effectively.

Defined license features can be thoroughly verified either during the initial license validation process on the server or through a manual verification after the validation has taken place. This entails checking specific attributes and functionalities outlined in the license to ensure they align with the terms granted. By validating these features, it can be confirmed that the software is being used in accordance with the agreed-upon licensing conditions, thereby upholding compliance and preventing unauthorized use.
  1. Verify a Feature During Validation
  2. The process of validating licenses and generating records of license usage on the server is contingent upon the condition that the features defined in the Builder match appropriately.
    License.getInstance().getBuilder()
                        .product("some-hash-value")
                        .feature("edition", mySoftwareEdition)
                        .build();
    In the example above, the feature key is labeled as "edition," and any corresponding value related to the edition in your software should be used. In this context, we will validate the license by checking if the software edition matches the edition specified in the license. This allows you to validate licenses based on different editions of your software. If the editions do not match, the license will not be validated, and the status will be marked as invalid.
    License.getInstance().getBuilder()
                        .product("some-hash-value")
                        .feature("version", "1.1.0")
                        .build();
    In the example above, it is possible to validate licenses based on the software version. When generating a license on the server, define a version key with a value, such as 1.999 to ensure that all 1.x.x versions are valid. However, once you release version 2 of your software, the license for version 1.1.2 will no longer be valid.

    Features can be of three types: string, number, and version (which is treated as a number).

    When a string is passed as an argument, the server checks the corresponding key defined in the license and uses the "equals" method to compare it (case-sensitive).

    If a number is passed, the server utilizes the `NumberFormat.getInstance().parse` method to convert the string to a number. It then checks this number against the corresponding key in the license to determine whether it is less than or equal to the specified value.

    To validate version numbers, you should pass the version as a string. The server will convert it to a number using the same `NumberFormat.getInstance().parse` method. Since the conversion treats the string as a double, only one decimal point is allowed. For example, the version "1.2.3" will be converted to "1.2". This number is then compared with the matching key in the license to see if it is less than or equal to the specified maximum version. To allow your software versions to range from 1.0 to 1.999, define the maximum version in the license as 1.999.

    There are several practical use cases for customizing software licenses to enhance security and control access. One example is utilizing the operating system's username to restrict the license validity to specific users. This ensures that only designated individuals can access the software, effectively matching the license to the approved users.

    Another approach involves using the domain name of the client system to establish a site license. This method allows organizations to integrate the license with their network settings, facilitating access for all users within that domain while preventing unauthorized usage from outside. By employing these strategies, companies can better manage their software licenses and ensure compliance with licensing agreements.

  3. Verify a Feature Manually After a Successful Validation
  4. A feature can be validated manually after successful validation. First, validate the license without the desired feature defined. When it is validated, check the feature.
    License.getInstance().getLicenseInformation()
                        .getFeature("Some-Feature-Name").getValue().equals("Some-Value");
    You might consider licensing some of your software features separately. For example, you could sell a license that includes basic features and then offer additional features for purchase. In the software product, when a customer attempts to use a paid feature, you should first check if that feature is included in their license before allowing or rejecting the operation. Another example to disable some features.
    public void runBusinessLogicNo1() {
        boolean businessLogic1 = License.getInstance()
            .getLicenseInformation().getFeature("BusinessLogic1").getValue().equals("SomeValue");
        
        if (!businessLogic1) {
            System.err.println("You dont have "Business Logic 1" feature");
            return;
        }
    }
    Here's a clearer version of the text: Another example involves defining a trial license. First, create a feature with a key/value pair, such as ThisIsATrialLicense=true. After validating the license, check if it is a trial license. If it is, disable certain functions in the software. The trial period can be easily validated by specifying a validity duration during the license generation process.
    public void checkTrial() {
        boolean trial = License.getInstance()
            .getLicenseInformation().getFeature("ThisIsATrialLicense").getValue().equals("true");
        if (trial) {
            // disable some functions etc...
        }
    }

There are a wide range of options available for utilizing specific licensing features effectively. Any element of the software or service can be thoroughly validated either at the time of the license validation process or afterward, which facilitates the implementation of diverse licensing models tailored to different user needs and business scenarios. This flexibility allows organizations to create customized licensing strategies that can enhance compliance and optimize the user experience.


Home rarr Documents rarr License Library rarr License Features