com.cafesoft.core.license
Class AbstractProductLicense

java.lang.Object
  |
  +--com.cafesoft.core.license.AbstractProductLicense
All Implemented Interfaces:
ProductLicense

public abstract class AbstractProductLicense
extends Object
implements ProductLicense

AbstractProductLicense implements some of the more mundane methods of a ProductLicense and leaves a few abstract methods for implementation by concrete classes.

Since:
9/30/2002

Constructor Summary
AbstractProductLicense()
           
 
Method Summary
 void addAttribute(String attrName, String attrValue)
          Add an attribute.
abstract  void assertValid()
          Assert that the ProductLicense is valid.
protected  String computeKey(String password)
          Compute the key based on current ProductLicense attributes and the specified password.
 String[] getAttributeNames()
          Get all attribute names.
 String getAttributeValue(String attrName)
          Get an attribute value.
 String getKey()
          Get the ProductLicense key.
 String getName()
          Get the ProductLicense name.
abstract  void initialize(Object config)
          Initialize the ProductLicense.
 boolean isLocked()
          Check the ProductLicense locked status
 void lock()
          Lock the ProductLicense.
 void setKey(String key)
          Set the ProductLicense key.
 void setName(String name)
          Set the ProductLicense name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractProductLicense

public AbstractProductLicense()
Method Detail

initialize

public abstract void initialize(Object config)
                         throws ProductLicenseException
Initialize the ProductLicense.

Specified by:
initialize in interface ProductLicense
Parameters:
config - an implementation-specific configuration parameter. This may be a Properties object, a File, or any other object specific to the ProductLicenseManager implementation.
Throws:
ProductLicenseException - if an error initializing the ProductLicense.

setName

public final void setName(String name)
                   throws ProductLicenseException
Set the ProductLicense name.

Specified by:
setName in interface ProductLicense
Parameters:
name - the ProductLicense name.
Throws:
ProductLicenseException - if the name is null, empty, or the ProductLicense is locked.

getName

public final String getName()
Get the ProductLicense name.

Specified by:
getName in interface ProductLicense
Returns:
the ProductLicense name.

setKey

public final void setKey(String key)
                  throws ProductLicenseException
Set the ProductLicense key.

Specified by:
setKey in interface ProductLicense
Parameters:
key - the ProductLicense key.
Throws:
ProductLicenseException - if the key is null, empty, or the ProductLicense is locked.

getKey

public final String getKey()
Get the ProductLicense key.

Specified by:
getKey in interface ProductLicense
Returns:
the ProductLicense key.

addAttribute

public final void addAttribute(String attrName,
                               String attrValue)
                        throws ProductLicenseException
Add an attribute.

Specified by:
addAttribute in interface ProductLicense
Parameters:
attrName - the product attribute name.
attrValue - the product attribute value.
Throws:
ProductLicenseException - if an invalid or unknown attribute is added, or if the ProductLicense is locked and cannot be modified.

getAttributeNames

public final String[] getAttributeNames()
Get all attribute names.

Specified by:
getAttributeNames in interface ProductLicense
Returns:
an String array of all attribute names. If no attributes have been added, the array length is 0. Attribute names are returned in the order they were added.

getAttributeValue

public final String getAttributeValue(String attrName)
Get an attribute value.

Specified by:
getAttributeValue in interface ProductLicense
Parameters:
attrName - the name of the attribute for which a value is desired.
Returns:
the attribute value or null if the attribute has not been added.

lock

public final void lock()
Lock the ProductLicense. Once locked, the ProductLicense cannot be modified and attempting to do so will throw a ProductLicenseException.

Specified by:
lock in interface ProductLicense

isLocked

public final boolean isLocked()
Check the ProductLicense locked status

Specified by:
isLocked in interface ProductLicense
Returns:
true if the ProductLicense is locked, else false.

assertValid

public abstract void assertValid()
                          throws ProductLicenseException
Assert that the ProductLicense is valid.

Specified by:
assertValid in interface ProductLicense
Throws:
ProductLicenseException - if the ProductLicense is not valid.

computeKey

protected String computeKey(String password)
                     throws ProductLicenseException
Compute the key based on current ProductLicense attributes and the specified password.

Parameters:
password - the password used during key computation.
ProductLicenseException


Generated on 10:40:31 AM September 10, 2003, © 1996-2003 Cafésoft LLC. All rights reserved.