public final class LicenseManager extends Object
LicenseManagerProperties. The values in this class will be used to instantiate the license
manager. After setting all the necessary properties there, one can retrieve an instance using
getInstance(). Be sure to set all the properties first; once getInstance() is called for the first
time, any changes to LicenseManagerProperties will be ignored.LicenseSecurityManager.createInstance is
called and cannot be disabled. For more information on how it works, see the JavaDoc for the
LicenseSecurityManager.LicenseSecurityManager,
InsecureEnvironmentException| Modifier and Type | Method and Description |
|---|---|
void |
clearLicenseCache()
Clears the cache of licenses, forcing all license data to be re-retrieved from the license data provider on the
next call to
getLicense(Object). |
License |
decryptAndVerifyLicense(SignedLicense signedLicense)
This method verifies the signed license object's signature, then decrypts the signed license and returns the
decrypted license.
|
static LicenseManager |
getInstance()
Returns the license manager instance.
|
License |
getLicense(Object context)
If the license has already been cached for the specified context (account, client, etc.) and the cache has not
become stale (its age has not surpassed the cache time limitation configured for this manager), this returns the
cached license.
|
boolean |
hasLicenseForAllFeatures(Object context,
FeatureObject... features)
Checks whether the license assigned to the specified context is licensed to use all of the features specified.
|
boolean |
hasLicenseForAllFeatures(Object context,
String... featureNames)
Checks whether the license assigned to the specified context is licensed to use all of the features specified.
|
boolean |
hasLicenseForAnyFeature(Object context,
FeatureObject... features)
Checks whether the license assigned to the specified context is licensed to use any of the features specified.
|
boolean |
hasLicenseForAnyFeature(Object context,
String... featureNames)
Checks whether the license assigned to the specified context is licensed to use any of the features specified.
|
boolean |
hasLicenseForFeature(Object context,
FeatureObject feature)
Checks whether the license assigned to the specified context is licensed to use the feature specified.
|
boolean |
hasLicenseForFeature(Object context,
String featureName)
Checks whether the license assigned to the specified context is licensed to use the feature specified.
|
boolean |
hasLicenseForFeatures(Object context,
AnnotatedElement target)
Checks whether the license assigned to the specified context is licensed to use the feature(s) in the
FeatureRestriction annotation value, if the target is annotated with that annotation. |
boolean |
hasLicenseForFeatures(Object context,
FeatureRestriction annotation)
Checks whether the license assigned to the specified context is licensed to use the feature(s) in the annotation value.
|
void |
validateLicense(License license)
This method calls
LicenseValidator.validateLicense(License) on the validator that was provided, if one
was provided. |
void |
verifyLicenseSignature(SignedLicense signedLicense)
This method verifies the signed license object's signature.
|
public static LicenseManager getInstance()
LicenseManagerProperties. See the documentation for that class for more details.IllegalArgumentException - if licenseProvider, publicKeyPasswordProvider or publicKeyDataProvider are null.InsecureEnvironmentException - if the LicenseSecurityManager cannot be instantiatedfor more information on the security features that protect the license managerpublic final void validateLicense(License license) throws InvalidLicenseException
LicenseValidator.validateLicense(License) on the validator that was provided, if one
was provided.license - The license to validateInvalidLicenseException - when the license is invalid for any reason.ExpiredLicenseException - when the license is expired.public final boolean hasLicenseForFeature(Object context, String featureName) throws InvalidLicenseException
getLicense(Object) and for the same reasons.context - The context (account, client, etc.) for which to check the feature(s) against its licensefeatureName - The feature (or features) to check against the licensetrue if the license exists and has this feature enabled, false otherwise.InvalidLicenseException - when the license is invalid for any reason.ExpiredLicenseException - when the license is expired.public final boolean hasLicenseForFeature(Object context, FeatureObject feature) throws InvalidLicenseException
getLicense(Object) and for the same reasons.context - The context (account, client, etc.) for which to check the feature(s) against its licensefeature - The feature (or features) to check against the licensetrue if the license exists and has this feature enabled, false otherwise.InvalidLicenseException - when the license is invalid for any reason.ExpiredLicenseException - when the license is expired.public final boolean hasLicenseForAnyFeature(Object context, String... featureNames) throws InvalidLicenseException
getLicense(Object) and for the same reasons.context - The context (account, client, etc.) for which to check the feature(s) against its licensefeatureNames - The feature (or features) to check against the licensetrue if the license exists and has this feature enabled, false otherwise.InvalidLicenseException - when the license is invalid for any reason.ExpiredLicenseException - when the license is expired.public final boolean hasLicenseForAnyFeature(Object context, FeatureObject... features) throws InvalidLicenseException
getLicense(Object) and for the same reasons.context - The context (account, client, etc.) for which to check the feature(s) against its licensefeatures - The feature (or features) to check against the licensetrue if the license exists and has this feature enabled, false otherwise.InvalidLicenseException - when the license is invalid for any reason.ExpiredLicenseException - when the license is expired.public final boolean hasLicenseForAllFeatures(Object context, String... featureNames) throws InvalidLicenseException
getLicense(Object) and for the same reasons.context - The context (account, client, etc.) for which to check the feature(s) against its licensefeatureNames - The feature (or features) to check against the licensetrue if the license exists and has this feature enabled, false otherwise.InvalidLicenseException - when the license is invalid for any reason.ExpiredLicenseException - when the license is expired.public final boolean hasLicenseForAllFeatures(Object context, FeatureObject... features) throws InvalidLicenseException
getLicense(Object) and for the same reasons.context - The context (account, client, etc.) for which to check the feature(s) against its licensefeatures - The feature (or features) to check against the licensetrue if the license exists and has this feature enabled, false otherwise.InvalidLicenseException - when the license is invalid for any reason.ExpiredLicenseException - when the license is expired.public final boolean hasLicenseForFeatures(Object context, FeatureRestriction annotation) throws InvalidLicenseException
getLicense(Object) and for the same reasons.context - The context (account, client, etc.) for which to check the feature(s) against its licenseannotation - The annotation object whose value(s) is(are) the feature(s) to check against the licensetrue if the license exists and has this feature(s) enabled, false otherwise.InvalidLicenseException - when the license is invalid for any reason.ExpiredLicenseException - when the license is expired.public final boolean hasLicenseForFeatures(Object context, AnnotatedElement target) throws InvalidLicenseException
FeatureRestriction annotation value, if the target is annotated with that annotation.getLicense(Object) and for the same reasons.context - The context (account, client, etc.) for which to check the feature(s) against its licensetarget - The target (a package reflection object, class reflection object or method reflection object) to check for the FeatureRestriction annotation and check its value against the licensefalse if the license does not exist, true if the target is not annotated with FeatureRestriction and, if it is annotated, true if the feature(s) is(are) licensed or false if the feature(s) is(are) not licensedInvalidLicenseException - when the license is invalid for any reason.ExpiredLicenseException - when the license is expired.public final License getLicense(Object context) throws KeyNotFoundException, AlgorithmNotSupportedException, InappropriateKeySpecificationException, InappropriateKeyException, CorruptSignatureException, InvalidSignatureException, FailedToDecryptException
context - The context (account, client, etc.) for which to retrieve the license objectKeyNotFoundException - if the public key data could not be found.AlgorithmNotSupportedException - if the signature algorithm is not supported on this system.InappropriateKeySpecificationException - if an inappropriate key specification is provided.InappropriateKeyException - if there is a problem initializing the verification mechanism with the public key.CorruptSignatureException - if the signature data has been corrupted (most likely tampered with).InvalidSignatureException - if the signature is invalid (most likely tampered with).FailedToDecryptException - if the license or signature could not be decrypted.ObjectTypeNotExpectedException - if the license data was tampered with.public final void clearLicenseCache()
getLicense(Object).public final void verifyLicenseSignature(SignedLicense signedLicense) throws AlgorithmNotSupportedException, InappropriateKeyException, CorruptSignatureException, InvalidSignatureException
getLicense(Object)). This is a
convenience method useful for verifying the signature of an individual license without going through all of the
retrieval and caching mechanisms normally used when calling getLicense(Object).signedLicense - The signed license object to verifyAlgorithmNotSupportedException - if the signature algorithm is not supported on this system.InappropriateKeyException - if there is a problem initializing the verification mechanism with the public key.CorruptSignatureException - if the signature data has been corrupted (most likely tampered with).InvalidSignatureException - if the signature is invalid (most likely tampered with).public final License decryptAndVerifyLicense(SignedLicense signedLicense)
getLicense(Object)). This is a convenience method useful for verifying the
signature of and interpreting an individual license without going through all of the retrieval and caching
mechanisms normally used when calling getLicense(Object).signedLicense - The signed license object to verifyAlgorithmNotSupportedException - if the signature algorithm is not supported on this system.InappropriateKeyException - if there is a problem initializing the verification mechanism with the public key.CorruptSignatureException - if the signature data has been corrupted (most likely tampered with).InvalidSignatureException - if the signature is invalid (most likely tampered with).FailedToDecryptException - if the license could not be decrypted.Copyright © 2010-2013 NWTS Java Code. All Rights Reserved. Licensed Under the Apache License version 2.0.