Class RevocableLicense
- java.lang.Object
-
- javax0.license3j.RevocableLicense
-
public class RevocableLicense extends java.lang.Object
Extended license works with a license object and provides features that are not core license functionalities.- Author:
- Peter Verhas
-
-
Constructor Summary
Constructors Constructor Description RevocableLicense(License license)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.net.URL
getRevocationURL()
Get the revocation URL of the license.boolean
isRevoked()
Check if the license was revoked or not.boolean
isRevoked(boolean defaultRevocationState)
Check if the license is revoked or not.void
setRevocationURL(java.lang.String url)
Set the revocation URL.void
setRevocationURL(java.net.URL url)
Set the revocation URL.
-
-
-
Constructor Detail
-
RevocableLicense
public RevocableLicense(License license)
-
-
Method Detail
-
getRevocationURL
public java.net.URL getRevocationURL() throws java.net.MalformedURLException
Get the revocation URL of the license. This feature is stored in the license under the namerevocationUrl
. 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 be replaced using the fingerprint of the license.
- Returns:
- the revocation URL with the license id place holder filled in, or
null
if there is no revocation URL template defined in the license. - Throws:
java.net.MalformedURLException
- when the revocation url is not well formatted
-
setRevocationURL
public void setRevocationURL(java.lang.String url)
Set the revocation URL. This method accepts the url as a string that makes it possible to use a string that contains the${licenseId}
place holder.- Parameters:
url
- the url from where the revocation information can be downloaded
-
setRevocationURL
public void setRevocationURL(java.net.URL url)
Set the revocation URL. Using this method is discouraged in case the URL contains the${licenseId}
place holder. In that case it is recommended to use thesetRevocationURL(String)
method instead.- Parameters:
url
- the revocation url
-
isRevoked
public boolean isRevoked()
Check if the license was revoked or not. For more information see the documentation of the methodisRevoked(boolean)
. Calling this method is equivalent to callingisRevoked(false)
, meaning that the license is signaled not revoked if the revocation URL can not be reached.- Returns:
true
if the license was revoked andfalse
if the license was not revoked. It also returnstrue
if the revocation url is unreachable.
-
isRevoked
public boolean isRevoked(boolean defaultRevocationState)
Check if the license is revoked or not. To get the revocation information the method tries to issue a http connection (GET) to the url specified in the license featurerevocationUrl
. If the URL returns anything with http status code200
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 valuelicenseId
. 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.
- Parameters:
defaultRevocationState
- should betrue
to treat the license revoked when the revocation service is not reachable. Setting this argumentfalse
makes the revocation handling more polite: if the license revocation service is not reachable then the license is treated as not revoked.- Returns:
true
if the license is revoked andfalse
if the license is not revoked.
-
-