org.jscience.util.license
Class LicenseManager

java.lang.Object
  extended by org.jscience.util.license.LicenseManager

public final class LicenseManager
extends java.lang.Object

LicenseManager provides the ability to use limited licenses based on classes and package names. Note that the LicenseManager only accepts Licenses that are properly signed, i.e. they will have to be created by an authorized issuer.

Once the LicenseManager is initialized, a set of licenses is installed from the licenses.dat file in the resource directory from the distribution; if any licenses therein are invalid or the file is non-existent, the resulting errors are ignored and the LicenseManager contains no licenses to begin with.

Generally, an application can go without using the LicenseManager explicitly. The class org.jscience.util.Settings provides a few convenience methods that may suffice for a standard application.

Since:
12/31/2003
See Also:
Settings, License, Licensed, LicenseHandler, LicensingException, Settings.checkLicense(Object), Settings.installLicenses(java.io.InputStream), org.jscience.util.Settings#installLicense(org.jscience.License)

Method Summary
 void check(java.lang.Object licensee)
          checks for a valid license for the given object and only returns gracefully if a valid license was found.
 License getLicense(java.lang.Object licensee)
          returns the license in use for the given licensee
static LicenseManager getLicenseManager()
          returns the global LicenseManager object (there is only one)
 java.util.Collection<License> getLicenses()
          returns an umnodifiable view of the embedded licenses
 Logger getLogger()
          returns the logger that logs changes and access to the LicenseManager
 License install(License l)
          installs the given license into this LicenseManager, so that it can be found if a check on the licensee is made.
 void loadFrom(java.io.File file)
          a convenience method that installs serialized licenses from a file
 void loadFrom(java.io.InputStream stream)
          a convenience method that installs serialized licenses from a stream.
 void loadFrom(java.net.URL url)
          a convenience method that installs serialized licenses from a URL
 void removeAllLicenses()
           
 License removeLicense(License l)
           
 void store(java.io.OutputStream stream)
          each license is written as a serialized byte array
 void verifyLicense(License l)
          checks the signature against the certificate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLogger

public Logger getLogger()
returns the logger that logs changes and access to the LicenseManager


getLicenseManager

public static LicenseManager getLicenseManager()
                                        throws java.lang.SecurityException
returns the global LicenseManager object (there is only one)

Throws:
java.lang.SecurityException - if the correct certificate cannot be found

loadFrom

public void loadFrom(java.io.File file)
              throws java.io.FileNotFoundException,
                     LicensingException
a convenience method that installs serialized licenses from a file

Throws:
java.io.FileNotFoundException
LicensingException

loadFrom

public void loadFrom(java.net.URL url)
              throws java.io.IOException,
                     LicensingException
a convenience method that installs serialized licenses from a URL

Throws:
java.io.IOException
LicensingException

loadFrom

public void loadFrom(java.io.InputStream stream)
              throws LicensingException
a convenience method that installs serialized licenses from a stream. Possible IOExceptions are ignored.

Throws:
LicensingException

store

public void store(java.io.OutputStream stream)
           throws java.io.IOException
each license is written as a serialized byte array

Throws:
java.io.IOException

getLicenses

public java.util.Collection<License> getLicenses()
returns an umnodifiable view of the embedded licenses


check

public void check(java.lang.Object licensee)
           throws LicensingException
checks for a valid license for the given object and only returns gracefully if a valid license was found. The use() method of the license object will be called if a valid license was found.

Throws:
LicensingException - if either no license was found or the found license was invalid
See Also:
License.use()

install

public License install(License l)
                throws LicensingException
installs the given license into this LicenseManager, so that it can be found if a check on the licensee is made. Only properly signed licenses can be installed.

Returns:
the previously installed license for the licensee embedded within the given license - if any
Throws:
LicensingException - if the license cannot be verified (i.e. if it is not properly signed)
See Also:
check(Object), verifyLicense(License)

removeLicense

public License removeLicense(License l)

removeAllLicenses

public void removeAllLicenses()

getLicense

public License getLicense(java.lang.Object licensee)
returns the license in use for the given licensee


verifyLicense

public void verifyLicense(License l)
                   throws LicensingException
checks the signature against the certificate. Note: a license passing this verification may still be invalid due to expiration or other constrains.

Throws:
LicensingException