net.java.truelicense.core.LicenseConsumerManager Maven / Gradle / Ivy
Show all versions of truelicense-core Show documentation
/*
* Copyright (C) 2005-2013 Schlichtherle IT Services.
* All rights reserved. Use is subject to license terms.
*/
package net.java.truelicense.core;
import net.java.truelicense.core.io.Source;
import net.java.truelicense.core.util.ContextProvider;
/**
* Defines the life cycle management operations for license keys in consumer
* applications.
*
* How to Preview License Keys?
*
* Unfortunately, this interface lacks a method to preview the license bean
* which is encoded in a given license key.
* However, you can do this by using a
* {@linkplain LicenseConsumerContext license consumer context}
* to configure a license consumer manager which uses a transient
* {@link net.java.truelicense.core.io.MemoryStore} instead of a persistent
* store - see {@link LicenseConsumerContext.ManagerBuilder#storeIn}.
* Once configured, you can {@link #install} the license key to the transient
* memory store and {@link #view} its encoded license bean.
*
* @author Christian Schlichtherle
*/
public interface LicenseConsumerManager
extends ContextProvider,
LicenseSubjectProvider,
LicenseParametersProvider {
/**
* Installs the license key from the given source and returns a
* {@linkplain LicenseValidation#validate validated} duplicate of its
* encoded license bean.
*
* Performing this operation requires prior
* {@linkplain LicenseAuthorization#clearInstall authorization}.
*
* @param source the source for loading the license key.
* @return A {@linkplain LicenseValidation#validate validated} duplicate of
* the license bean which is encoded in the license key.
* @throws LicenseValidationException if validating the license bean fails,
* e.g. if the license has expired.
*/
License install(Source source) throws LicenseManagementException;
/**
* Returns an unvalidated duplicate of the license bean which is encoded in
* the installed license key.
* Unlike {@link #verify}, this operation skips the validation of the
* license bean.
* This enables the caller to obtain a duplicate of the license bean even
* if validation would fail, e.g. if the license has expired.
*
* Performing this operation requires prior
* {@linkplain LicenseAuthorization#clearView authorization}.
*
* @return An unvalidated duplicate of the license bean which is encoded in
* the installed license key.
*/
License view() throws LicenseManagementException;
/**
* Verifies the license bean which is encoded in the installed license key.
* You should call this method whenever you want to "unlock" access to a
* feature of your product.
* Execution needs to be fast in order to support frequent calling.
*
* Performing this operation requires prior
* {@linkplain LicenseAuthorization#clearVerify authorization}.
*
* @throws LicenseValidationException if validating the license bean fails,
* e.g. if the license has expired.
*/
void verify() throws LicenseManagementException;
/**
* Uninstalls the installed license key.
*
* Performing this operation requires prior
* {@linkplain LicenseAuthorization#clearUninstall authorization}.
*/
void uninstall() throws LicenseManagementException;
}