com.cinnabarsystems.clm
Class LicenseUtility

java.lang.Object
  extended by com.cinnabarsystems.clm.LicenseUtility

public class LicenseUtility
extends Object

Class used to perform utility operations on license streams.


Constructor Summary
LicenseUtility()
           
 
Method Summary
static License acquireLicense(InputStream clmLicenseStream, File licenseDirectory, String licenseFileExtension, InputStream publicKeyInputStream, String product, String feature)
          Test directory-based license acquisition using astream containing an encoded public key.
static License acquireLicense(InputStream clmLicenseStream, File licenseDirectory, String licenseFileExtension, PublicKey verificationKey, String product, String feature)
          Test directory-based license acquisition using an existing PublicKey object.
static License acquireLicense(InputStream clmLicenseStream, InputStream licenseStream, InputStream publicKeyInputStream, String product, String feature)
          Test license acquisition using astream containing an encoded public key.
static License acquireLicense(InputStream clmLicenseStream, InputStream licenseStream, PublicKey verificationKey, String product, String feature)
          Test license acquisition using an existing PublicKey object.
static void dumpLicense(InputStream licenseStream)
          Prints a summary of license parameters.
static void dumpLicense(InputStream licenseStream, PrintStream output)
          Prints a summary of license parameters
static License getLicenseObject(InputStream licenseStream)
          Get a License object from a license file.
static void verifyLicense(InputStream clmLicenseStream, InputStream licenseStream, InputStream publicKeyInputStream)
          Verify a license stream using a stream containing an encoded public key.
static void verifyLicense(InputStream clmLicenseStream, InputStream licenseStream, PublicKey verificationKey)
          Verify a license stream using an existing PublicKey object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LicenseUtility

public LicenseUtility()
Method Detail

verifyLicense

public static void verifyLicense(InputStream clmLicenseStream,
                                 InputStream licenseStream,
                                 PublicKey verificationKey)
                          throws IOException,
                                 LicenseManagerException,
                                 GeneralSecurityException
Verify a license stream using an existing PublicKey object. Verification of a license consists of checking that the license file is in the proper format, and that the signature on the license file is valid.

Parameters:
licenseStream - stream containing a license file
verificationKey - public key to use to verify the license
Throws:
IOException
LicenseManagerException
GeneralSecurityException

verifyLicense

public static void verifyLicense(InputStream clmLicenseStream,
                                 InputStream licenseStream,
                                 InputStream publicKeyInputStream)
                          throws IOException,
                                 GeneralSecurityException,
                                 LicenseManagerException
Verify a license stream using a stream containing an encoded public key. Verification of a license consists of checking that the license file is in the proper format, and that the signature on the license file is valid.

Parameters:
licenseStream - stream containing a license file
publicKeyInputStream - stream from which an encoded public key can be read and used to verify the license
Throws:
IOException
GeneralSecurityException
LicenseManagerException

acquireLicense

public static License acquireLicense(InputStream clmLicenseStream,
                                     InputStream licenseStream,
                                     PublicKey verificationKey,
                                     String product,
                                     String feature)
                              throws IOException,
                                     LicenseManagerException,
                                     GeneralSecurityException
Test license acquisition using an existing PublicKey object. This method internally creates a LicenseManager object, verifies the license file using the public key provided, and attempts to acquire a license for the given product and feature. If the method returns without throwing any exception, a license was succesfully acquired. Note that this method is for testing only- deployed applications should acquire licenses by creating their own LicenseManager instances.

Parameters:
licenseStream - stream containing a license file
verificationKey - public key to use to verify the license
product - product for which to acquire a license
feature - feature for which to acquire a license
Throws:
IOException
LicenseManagerException
GeneralSecurityException

acquireLicense

public static License acquireLicense(InputStream clmLicenseStream,
                                     InputStream licenseStream,
                                     InputStream publicKeyInputStream,
                                     String product,
                                     String feature)
                              throws IOException,
                                     GeneralSecurityException,
                                     LicenseManagerException
Test license acquisition using astream containing an encoded public key. This method internally creates a LicenseManager object, verifies the license file using the public key provided, and attempts to acquire a license for the given product and feature. If the method returns without throwing any exception, a license was succesfully acquired. Note that this method is for testing only- deployed applications should acquire licenses by creating their own LicenseManager instances.

Parameters:
licenseStream - stream containing a license file
publicKeyInputStream - stream from which an encoded public key can be read and used to verify the license
product - product for which to acquire a license
feature - feature for which to acquire a license
Throws:
IOException
GeneralSecurityException
LicenseManagerException

acquireLicense

public static License acquireLicense(InputStream clmLicenseStream,
                                     File licenseDirectory,
                                     String licenseFileExtension,
                                     PublicKey verificationKey,
                                     String product,
                                     String feature)
                              throws IOException,
                                     LicenseManagerException,
                                     GeneralSecurityException
Test directory-based license acquisition using an existing PublicKey object. This method internally creates a LicenseManager for the given directory and file extension and attempts to acquire a license for the given product and feature. If the method returns without throwing any exception, a license was succesfully acquired. Note that this method is for testing only- deployed applications should acquire licenses by creating their own LicenseManager instances.

Parameters:
licenseDirectory - directory containing license files
licenseFileExtension - extension for license files (wildcards not supported)
verificationKey - public key to use to verify the license
product - product for which to acquire a license
feature - feature for which to acquire a license
Throws:
IOException
LicenseManagerException
GeneralSecurityException

acquireLicense

public static License acquireLicense(InputStream clmLicenseStream,
                                     File licenseDirectory,
                                     String licenseFileExtension,
                                     InputStream publicKeyInputStream,
                                     String product,
                                     String feature)
                              throws IOException,
                                     GeneralSecurityException,
                                     LicenseManagerException
Test directory-based license acquisition using astream containing an encoded public key. This method internally creates a LicenseManager object for the given directory and file extension and attempts to acquire a license for the given product and feature. If the method returns without throwing any exception, a license was succesfully acquired. Note that this method is for testing only- deployed applications should acquire licenses by creating their own LicenseManager instances.

Parameters:
licenseDirectory - directory containing license files
licenseFileExtension - extension for license files (wildcards not supported)
publicKeyInputStream - stream from which an encoded public key can be read and used to verify the license
product - product for which to acquire a license
feature - feature for which to acquire a license
Throws:
IOException
GeneralSecurityException
LicenseManagerException

getLicenseObject

public static License getLicenseObject(InputStream licenseStream)
                                throws IOException,
                                       LicenseManagerException
Get a License object from a license file. Note that this method does not verify that any of the conditions in the license file are satisfied.

Parameters:
licenseStream - stream containing a license file
Returns:
the License object
Throws:
IOException
LicenseManagerException

dumpLicense

public static void dumpLicense(InputStream licenseStream,
                               PrintStream output)
                        throws IOException,
                               LicenseManagerException
Prints a summary of license parameters

Parameters:
licenseStream - stream containing a license file
output - destination for license parameter summary information
Throws:
IOException
LicenseManagerException

dumpLicense

public static void dumpLicense(InputStream licenseStream)
                        throws IOException,
                               LicenseManagerException
Prints a summary of license parameters. The summary is printed to System.out.

Parameters:
licenseStream - stream containing a license file
Throws:
IOException
LicenseManagerException