|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jscience.util.license.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
DOCUMENT ME! |
| Constructor Summary | |
|---|---|
License(java.lang.Class licenseeClass,
java.lang.String issuedFor,
java.util.Date expirationDate,
int usageLimit)
only usable if properly signed |
|
License(java.lang.Package licenseePackage,
java.lang.String issuedFor,
java.util.Date expirationDate,
int usageLimit)
only usable if properly signed |
|
License(java.lang.String classOrPackageName,
java.lang.String issuedFor,
java.util.Date expirationDate,
int usageLimit)
only usable if properly signed |
|
| Method Summary | |
|---|---|
void |
addBoundEnvironment(java.lang.String envVariable,
java.lang.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(java.lang.String key,
java.lang.String value)
allows to add a condition where this license can only be used in an environment where the given system property corresponds to the given value. |
void |
checkValidation()
checks whether this license is properly singed, not expired and still has usage left. |
java.util.Map<java.lang.String,java.lang.String> |
getBoundEnvironment()
returns an unmodifiable view of the bound environment variables of this license |
java.util.Map<java.lang.String,java.lang.String> |
getBoundProperties()
returns an unmodifiable view of the bound system properties of this license |
java.util.Date |
getCreationDate()
returns the time when this license was created. |
java.lang.Object |
getLicensee()
returns either a Class or a String representing the Package |
byte[] |
getSignature()
returns a copy of the signature that is used to verify that this license has been created by an authorized issuer |
java.lang.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 |
static License |
loadLicense(java.io.File file)
loads a serialized license from a file |
static License |
loadLicense(java.io.InputStream stream)
loads a serialized license from a stream |
void |
saveTo(java.io.File file)
convenience method; overwrites the file if it exists |
void |
setSignature(byte[] signature)
the method that signes the license and thus makes it usable |
java.lang.String |
toString()
includes only a subset of restrictions for this license |
int |
usageLeft()
returns how many times use() can be called. if
INDEFINATE is returned, this license is not limited by
usage. |
int |
use()
uses this license; if usage is limited, the return value of usageLeft() is decreased by one after a call to this
method. |
java.util.Date |
validUntil()
returns the date after which this license expires. |
byte[] |
verification()
returns the data that serves as a basis for generating the signature. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int INDEFINATE
| Constructor Detail |
|---|
public License(java.lang.Package licenseePackage,
java.lang.String issuedFor,
java.util.Date expirationDate,
int usageLimit)
public License(java.lang.Class licenseeClass,
java.lang.String issuedFor,
java.util.Date expirationDate,
int usageLimit)
public License(java.lang.String classOrPackageName,
java.lang.String issuedFor,
java.util.Date expirationDate,
int usageLimit)
| Method Detail |
|---|
public byte[] verification()
java.lang.RuntimeException - DOCUMENT ME!
public void addBoundEnvironment(java.lang.String envVariable,
java.lang.String value)
throws java.lang.IllegalStateException
envVariable - DOCUMENT ME!value - DOCUMENT ME!
java.lang.IllegalStateException - if the license has already been signed
java.lang.NullPointerException - DOCUMENT ME!
public void addBoundProperty(java.lang.String key,
java.lang.String value)
throws java.lang.IllegalStateException
key - DOCUMENT ME!value - DOCUMENT ME!
java.lang.IllegalStateException - if the license has already been signed
java.lang.NullPointerException - DOCUMENT ME!public java.util.Map<java.lang.String,java.lang.String> getBoundProperties()
public java.util.Map<java.lang.String,java.lang.String> getBoundEnvironment()
public java.util.Date getCreationDate()
public java.lang.String issuedFor()
public byte[] getSignature()
public void setSignature(byte[] signature)
throws LicensingException
signature - DOCUMENT ME!
LicensingException - if the signature is invalid
java.lang.IllegalStateException - if the license has already been signed
public void saveTo(java.io.File file)
throws java.io.IOException
java.io.IOExceptionloadLicense(File)
public static License loadLicense(java.io.File file)
throws java.io.IOException,
LicensingException
java.io.IOException
LicensingExceptionsaveTo(File)
public static License loadLicense(java.io.InputStream stream)
throws java.io.IOException,
LicensingException
java.io.IOException
LicensingExceptionsaveTo(File)
public static License loadLicense(byte[] bytes)
throws java.io.IOException,
LicensingException
java.io.IOException
LicensingExceptionIOUtils.serialize(Object)public java.lang.Object getLicensee()
public boolean isValid()
checkValidation(). If you require more detail, call
checkValidation() directly.
checkValidation()
public void checkValidation()
throws LicensingException
LicensingExceptionuse(),
LicenseManager.verifyLicense(License)public java.util.Date validUntil()
public int usageLeft()
use() can be called. if
INDEFINATE is returned, this license is not limited by
usage.
use()
public int use()
throws LicensingException
usageLeft() is decreased by one after a call to this
method.
LicensingExceptionisValid()public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||