|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.License
public final class License
a License provides and limits access to certain functionality based on individual classes or packages. Note that for a License to be accepted by the LicenseManager, the License must be properly signed. A method for properly signing a License is not available under GPL, but there are License objects freely available on request.
LicenseManager,
LicensingException,
Serialized Form| Field Summary | |
|---|---|
static int |
INDEFINATE
|
| Constructor Summary | |
|---|---|
License(Class<?> licenseeClass,
String issuedFor,
Date expirationDate,
int usageLimit)
only usable if properly signed |
|
License(Package licenseePackage,
String issuedFor,
Date expirationDate,
int usageLimit)
only usable if properly signed |
|
License(Package licenseePackage,
String issuedFor,
Date expirationDate,
int usageLimit,
boolean includeSubPackages)
only usable if properly signed |
|
License(String classOrPackageName,
String issuedFor,
Date expirationDate,
int usageLimit,
boolean includeSubPackagesForPackage)
only usable if properly signed |
|
| Method Summary | |
|---|---|
void |
addBoundEnvironment(String envVariable,
String value)
allows to add a condition where this license can only be used if the given environment variable corresponds to the given value. |
void |
addBoundProperty(String key,
String value)
allows to add a condition where this license can only be used in an environment where the given system or settings property corresponds to the given value. |
void |
checkValidation()
checks whether this license is properly singed, not expired, still has usage left and has no other boundaries that prevent its validation on this system. |
boolean |
equals(Object obj)
|
Date |
expiration()
returns the date after which this license expires. |
Map<String,String> |
getBoundEnvironment()
returns an unmodifiable view of the bound environment variables of this license |
String |
getBoundMacAddress()
|
Map<String,String> |
getBoundProperties()
returns an unmodifiable view of the bound system properties of this license |
Date |
getCreationDate()
returns the time when this license was created. |
String |
getLicensee()
returns a String representing either a Class or a Package object |
LicenseKey |
getLicenseKey()
returns the associated LicenseKey object - if any |
byte[] |
getSignature()
returns a copy of the signature that is used to verify that this license has been created by an authorized issuer |
Date |
getSigningDate()
returns the date this license was signed (if at all) |
int |
hashCode()
|
boolean |
includesSubPackages()
determines whether this license is also valid for sub-packages |
boolean |
isBound()
returns true only if this license is either bound to one or more properties or environment variables. |
String |
issuedFor()
a hint to whom this license was issued |
boolean |
isValid()
returns true only if this license passes checkValidation(). |
static License |
loadLicense(byte[] bytes)
deserializes a license object from a byte pattern; license is not validated |
static License |
loadLicense(File file)
loads a single serialized license from a file; license is not validated |
static License |
loadLicense(InputStream stream)
loads a single serialized license from a stream; license is not validated |
static License |
loadLicense(URL url)
loads a single serialized license from a URL; license is not validated |
void |
saveTo(File file)
convenience method; overwrites the file if it exists |
void |
setBoundMacAddress(String macAddress)
bounds this license to the given macAddress (no bound if null is given) |
void |
setLicenseKey(LicenseKey key)
allows to set an individual license key for a license; must be set before signing. |
void |
setSignature(byte[] signature)
the method that signs the license and thus makes it usable. |
String |
toString()
includes only a subset of restrictions for this license |
int |
usageLeft()
returns how many times use() can be called. |
int |
use()
uses this license; if usage is limited, the return value of usageLeft() is decreased by one after a call to this method. |
byte[] |
verification()
returns the data that serves as a basis for generating the signature. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int INDEFINATE
| Constructor Detail |
|---|
public License(Package licenseePackage,
String issuedFor,
Date expirationDate,
int usageLimit)
public License(Package licenseePackage,
String issuedFor,
Date expirationDate,
int usageLimit,
boolean includeSubPackages)
public License(Class<?> licenseeClass,
String issuedFor,
Date expirationDate,
int usageLimit)
public License(String classOrPackageName,
String issuedFor,
Date expirationDate,
int usageLimit,
boolean includeSubPackagesForPackage)
| Method Detail |
|---|
public int hashCode()
hashCode in class Objectpublic boolean equals(Object obj)
equals in class Objectpublic byte[] verification()
toString() method
is stable, too.
public LicenseKey getLicenseKey()
public void setLicenseKey(LicenseKey key)
throws IllegalStateException
IllegalStateException - if the license has already been signedpublic boolean includesSubPackages()
public void addBoundEnvironment(String envVariable,
String value)
throws IllegalStateException
IllegalStateException - if the license has already been signed
public void addBoundProperty(String key,
String value)
throws IllegalStateException
IllegalStateException - if the license has already been signedSettings.getProperties(),
System.getProperties()
public void setBoundMacAddress(String macAddress)
throws IllegalStateException
IllegalStateException - if the license has already been signedMisc.getMacAddress()public String getBoundMacAddress()
public boolean isBound()
getBoundProperties(),
getBoundEnvironment()public Map<String,String> getBoundProperties()
public Map<String,String> getBoundEnvironment()
public Date getCreationDate()
public String issuedFor()
public byte[] getSignature()
public void setSignature(byte[] signature)
throws LicensingException
IllegalStateException - if the license has already been signed
LicensingException - if the signature is invalidpublic Date getSigningDate()
public void saveTo(File file)
throws IOException
IOExceptionloadLicense(File)
public static License loadLicense(File file)
throws IOException,
LicensingException
IOException
LicensingExceptionsaveTo(File)
public static License loadLicense(URL url)
throws IOException,
LicensingException
IOException
LicensingException
public static License loadLicense(InputStream stream)
throws IOException,
LicensingException
IOException
LicensingException
public static License loadLicense(byte[] bytes)
throws IOException,
LicensingException
IOException
LicensingExceptionData.serialize(Object)public String getLicensee()
public boolean isValid()
checkValidation().
If you require more detail, call checkValidation() directly.
checkValidation()
public void checkValidation()
throws LicensingException
LicensingExceptionuse(),
LicenseManager.verifyLicense(License)public Date expiration()
public int usageLeft()
use() can be called.
if INDEFINATE is returned, this license is not limited by usage.
if 0 is returned, this license will throw a LicensingException on next use.
use()
public int use()
throws LicensingException
usageLeft() is decreased by one after a call to this method.
LicensingExceptionisValid()public String toString()
toString in class Object
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||