|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.smardec.license4j.LicenseManager
The main class for managing licenses.
Method Summary | |
static java.lang.String |
generateStringKey(int length,
java.lang.String secret)
The method generates string key that can later be checked for validity by isStringKeyValid(String,String) . |
static boolean |
isSerializeStrings()
Indicates whether String feature values
will be stored in the license in the serialized form. |
static boolean |
isStringKeyValid(java.lang.String key,
java.lang.String secret)
Validates string key generated by generateStringKey(int,String) . |
static boolean |
isValid(License license)
Indicates whether the license is valid. |
static License |
loadLicense(java.io.InputStream stream)
Loads license from the specified InputStream . |
static License |
loadLicense(java.lang.String filename)
Loads license from the specified file. |
static void |
saveLicense(License license,
java.lang.String filename)
Saves the license to the specified file. |
static void |
saveLicense(License license,
java.io.Writer writer)
Saves the license to the specified Writer . |
static void |
setPrivateKey(java.lang.String key)
Sets private key. |
static void |
setPublicKey(java.lang.String key)
Sets public key. |
static void |
setSerializeStrings(boolean serializeStrings)
Specifies whether String feature values
will be stored in the license in the serialized form. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static boolean isSerializeStrings()
String
feature values
will be stored in the license in the serialized form.
If true
than String
objects will be serialized.
The default is false
.
true
if String
objects will be serialized,
false
otherwise. The default is false
.public static void setSerializeStrings(boolean serializeStrings)
String
feature values
will be stored in the license in the serialized form.
If true
than String
objects will be serialized.
The default is false
.
serializeStrings
- true
if String
objects should be serialized,
false
otherwise. The default is false
public static void setPrivateKey(java.lang.String key)
key
- private keypublic static void setPublicKey(java.lang.String key)
key
- public keypublic static License loadLicense(java.lang.String filename) throws LicenseNotFoundException
filename
- name of the license file
License
object.
LicenseNotFoundException
- if the license cannot be readpublic static License loadLicense(java.io.InputStream stream) throws LicenseNotFoundException
InputStream
.
stream
- InputStream
that contains license information
License
object.
LicenseNotFoundException
- if the license cannot be readpublic static void saveLicense(License license, java.lang.String filename) throws java.security.GeneralSecurityException, java.lang.IllegalArgumentException, java.io.IOException
license
- License
object to writefilename
- name of the file
java.security.GeneralSecurityException
- if private key is not initialized by setPrivateKey(String)
java.lang.IllegalArgumentException
- if license has no features
java.io.IOException
- if the specified file exists but is a directory rather
than a regular file, does not exist but cannot be
created, or cannot be opened for any other reasonpublic static void saveLicense(License license, java.io.Writer writer) throws java.security.GeneralSecurityException, java.lang.IllegalArgumentException, java.io.IOException
Writer
.
Note that Writer.close()
method is not invoked after writing the license.
license
- License
object to writewriter
- Writer
object
java.security.GeneralSecurityException
- if private key is not initialized by setPrivateKey(String)
java.lang.IllegalArgumentException
- if license has no features
java.io.IOException
- if an I/O error occurspublic static boolean isValid(License license) throws java.security.GeneralSecurityException
license
- license to check
true
if the license is valid,
false
otherwise.
java.security.GeneralSecurityException
- if public key is not initialized by setPublicKey(String)
public static java.lang.String generateStringKey(int length, java.lang.String secret)
isStringKeyValid(String,String)
.
length
- the desired length of the key in symbols, should be even number greater than 8
secret
- secret string used to generate and validate keys (your passphrase)
public static boolean isStringKeyValid(java.lang.String key, java.lang.String secret)
generateStringKey(int,String)
.
key
- the keysecret
- secret string used to generate and validate keys (your passphrase)
true
if the key is valid, false
otherwise
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |