public class ExtendedLicense extends License
licenseProperties| Constructor and Description |
|---|
ExtendedLicense() |
| Modifier and Type | Method and Description |
|---|---|
UUID |
generateLicenseId()
Generates a new license id.
|
<T> T |
getFeature(String name,
Class<? extends T> klass) |
UUID |
getLicenseId() |
URL |
getRevocationURL()
Get the revocation URL of the license.
|
boolean |
isExpired()
Checks the expiration date of the license and returns true if the license
has expired.
|
boolean |
isRevoked()
Check if the license was revoked or not.
|
boolean |
isRevoked(boolean defaultRevocationState)
Check if the license is revoked or not.
|
void |
setExpiry(Date expiryDate)
Set the expiration date of the license.
|
void |
setFeature(String name,
Date date)
Set a date feature in the license.
|
void |
setFeature(String name,
Integer i)
Set an integer feature in the license.
|
void |
setFeature(String name,
URL url)
Set a URL feature in the license.
|
void |
setFeature(String name,
UUID uuid)
Set an UUID feature in the license.
|
void |
setLicenseId(UUID licenseId)
Set the UUID of a license.
|
void |
setRevocationURL(String url)
Set the revocation URL.
|
void |
setRevocationURL(URL url)
Set the revocation URL.
|
calculatePublicKeyRingDigest, dumpLicense, dumpLicense, dumpLicense, dumpPublicKeyRingDigest, encodeLicense, fromResource, getDecodeKeyId, getFeature, getLicenseString, isVerified, loadKey, loadKey, loadKey, loadKeyRing, loadKeyRing, loadKeyRing, loadKeyRingFromResource, setFeature, setHashAlgorithm, setLicense, setLicense, setLicense, setLicenseEncoded, setLicenseEncoded, setLicenseEncoded, setLicenseEncodedFromFile, setLicenseEncodedFromFile, setLicenseEncodedFromResourcepublic boolean isExpired()
throws ParseException
The expiration date is encoded in the license with the key
expiryDate in the format yyyy-MM-dd. A license is expired
if the current date is after the specified expiryDate. At the given date
the license is still valid.
Note that this method does not ensure license validity. You separately
have to call License.isVerified() to ensure that the license was
successfully verified.
The time is calculated using the default locale, thus licenses expire first in Australia, later in Europe and latest in USA.
true if the license is expiredParseException - if the date is badly formattedpublic void setExpiry(Date expiryDate)
yyyy-MM-dd the actual hours, minutes and so on will be
chopped off.public UUID generateLicenseId()
Note that this ID is also stored in the license thus there is no need to
call setFeature(String, UUID) separately after the UUID was
generated.
Generating UUID can be handy when you want to identify each license individually. For example you want to store revocation information about each license. The url to check the revocation may contain the ${licenseId} place holder that will be replaced by the actual uuid stored in the license.
public void setLicenseId(UUID licenseId)
generateLicenseId(), which method automatically calls
this method setting the generated UUID to be the UUID of the license.licenseId - the uuid that was generated somewhere, presumably not by
generateLicenseId() because the uuid generated by
that method is automatically stored in the license.public UUID getLicenseId()
public void setFeature(String name, Integer i)
name - the name of the featurei - the value of the integer featurepublic void setFeature(String name, Date date)
name - the name of the featuredate - the date to be stored for the feature name in the licensepublic void setFeature(String name, URL url)
name - the name of the featureurl - the url to store in the licensepublic void setFeature(String name, UUID uuid)
name - the name of the featureuuid - the uuid to store in the licensepublic <T> T getFeature(String name, Class<? extends T> klass) throws InstantiationException, IllegalAccessException, ParseException, MalformedURLException
public URL getRevocationURL() throws MalformedURLException
revocationUrl. This URL may contain the
string ${licenseId} which is replaced by the actual license
ID. Thus there is no need to wire into the revocation URL the license ID.
If there is no license id defined in the license then the place holder will not be replaced.
MalformedURLException - when the revocation url is not well formattedpublic void setRevocationURL(String url)
${licenseId} place holder.url - the url from where the revocation information can be
downloadedpublic void setRevocationURL(URL url)
${licenseId} place holder. In that case it is
recommended to use the setRevocationURL(String) method instead.url - the revocation urlpublic boolean isRevoked()
isRevoked(boolean). Calling this
method is equivalent to calling isRevoked(false), meaning that
the license is signaled not revoked if the revocation URL can not be
reached.true if the license was revoked and false if the
license was not revoked. It also returns true if the
revocation url is unreachable.public boolean isRevoked(boolean defaultRevocationState)
revocationUrl. If the URL returns anything
with http status code 200 then the license is not revoked.
The url string in the feature revocationUrl may contain the place
holder ${licenseId}, which is replaced by the feature value
licenseId. This feature makes it possible to setup a revocation
service and use a constant string in the different licenses.
The method can work in two different ways. One way is to ensure that the
license is not revoked and return true only if it is sure that
the license is revoked or revocation information is not available.
The other way is to ensure that the license is revoked and return
false if the license was not revoked or the revocation
information is not available.
The difference is whether to treat the license revoked when the revocation service is not reachable.
defaultRevocationState - should be true to treat the license revoked when the
revocation service is not reachable. Setting this argument
false makes the revocation handling more polite: if
the license revocation service is not reachable then the
license is treated as not revoked.true if the license is revoked and false if the
license is not revoked.Copyright © 2015. All Rights Reserved.