com.smardec.license4j
Class LicenseManager

java.lang.Object
  |
  +--com.smardec.license4j.LicenseManager

public final class LicenseManager
extends java.lang.Object

The main class for managing licenses.


Constructor Summary
LicenseManager()
           
 
Method Summary
static boolean isValid(License license)
          Indicates whether license is valid.
static License loadLicense(java.io.InputStream stream)
          Loads license from the specified stream.
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 setPrivateKey(java.lang.String key)
          Sets private key.
static void setPublicKey(java.lang.String key)
          Sets public key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LicenseManager

public LicenseManager()
Method Detail

setPrivateKey

public static void setPrivateKey(java.lang.String key)
Sets private key. Needed to create licenses.

Parameters:
key - private key

setPublicKey

public static void setPublicKey(java.lang.String key)
Sets public key. Needed to validate licenses.

Parameters:
key - public key

loadLicense

public static License loadLicense(java.lang.String filename)
                           throws LicenseNotFoundException
Loads license from the specified file.

Parameters:
filename - name of the file
Returns:
License object
Throws:
LicenseNotFoundException - if the license can not be read

loadLicense

public static License loadLicense(java.io.InputStream stream)
                           throws LicenseNotFoundException
Loads license from the specified stream.

Parameters:
stream - stream containing license information
Returns:
License object
Throws:
LicenseNotFoundException - if the license can not be read

saveLicense

public static void saveLicense(License license,
                               java.lang.String filename)
                        throws java.security.GeneralSecurityException,
                               java.lang.IllegalArgumentException,
                               java.io.IOException
Saves the license to the specified file.

Parameters:
license - License object to write
filename - name of the file
Throws:
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 reason

isValid

public static boolean isValid(License license)
                       throws java.security.GeneralSecurityException
Indicates whether license is valid.

Parameters:
license - license to check
Returns:
true if the license is valid false otherwise
Throws:
java.security.GeneralSecurityException - if public key is not initialized by setPublicKey(String)


Copyright © 2003-2004 Smardec. All Rights Reserved.