blackboard.platform
Class License

java.lang.Object
  extended by blackboard.platform.License

public final class License
extends java.lang.Object

Object to represent different options in the license file. Each license is identified by a "component" name, which is a simple string. There are additional attributes for expiration, key (a validation digest), allowed IP addresses, and a generic "unit" facility to represent any additional, integer-based component-specific options. There is also a facility for free-form "parameters" for additiona, string-based component-specific options.

Since:
Bb 6.0
Version:
$Revision: #1 $ $Date: 2005/06/27 $

Nested Class Summary
static class License.XmlDef
          Class to wrap String constants used in XML parsing.
 
Field Summary
protected  java.lang.String[] _allowedIps
           
protected  java.lang.String _component
           
protected  java.util.Date _expiration
           
protected  java.lang.String _key
           
protected  java.util.Properties _params
           
protected  java.util.Hashtable _unitProps
           
static java.lang.String[] ALLOW_ANY_SERVER_IP
           
static java.util.Date NO_EXPIRATION
           
static java.lang.Integer UNLIMITED_UNITS
           
static java.lang.String UNLIMITED_UNITS_DB_STRING
           
static java.lang.String UNLIMITED_UNITS_STRING
           
 
Constructor Summary
License(java.lang.String component, java.lang.String[] allowedIps, java.util.Date expiration, java.lang.String key, java.util.Hashtable unitProps, java.util.Properties params)
          Constructor initializing License with specified parameters
 
Method Summary
 void assertHasValidKey()
          Identical to hasValidKey(), except that a checked exception is thrown if the key is not valid.
 void assertIsLicensed()
          Assertion that a valid license exists, including validating expiration and valid IP addresses.
 java.lang.String[] getAllowedIps()
          Returns the set of IP addresses that this license is restricted to run on.
 java.lang.String getComponent()
          Returns the component name.
 java.util.Date getExpiration()
          Returns the expiration date for this component.
 java.lang.String getKey()
          Returns the validation digest for this component.
 java.lang.String getParameter(java.lang.String name)
          Returns the value for the specified custom parameter.
 java.lang.Integer getUnitsParameter(java.lang.String propertyName)
          Returns the value for the specified unit.
 boolean hasValidKey()
          Returns whether this component's validation key is correct.
 boolean isExpired()
          Returns whether this component has expired.
 boolean isValidForThisServer()
          Check to see if this server is in the set of valid IP addresses associated for this license component.
 void serializeAsProperties(java.util.Properties p, java.lang.String namePrefix)
          Writes component out in property (name/value) format.
 java.lang.String serializeAsXml(java.lang.String lineSeparator)
          Writes out this license as a String, using the specified lineSeparator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_component

protected java.lang.String _component

_allowedIps

protected java.lang.String[] _allowedIps

_expiration

protected java.util.Date _expiration

_key

protected java.lang.String _key

_params

protected java.util.Properties _params

_unitProps

protected java.util.Hashtable _unitProps

NO_EXPIRATION

public static final java.util.Date NO_EXPIRATION

UNLIMITED_UNITS

public static final java.lang.Integer UNLIMITED_UNITS

UNLIMITED_UNITS_STRING

public static final java.lang.String UNLIMITED_UNITS_STRING
See Also:
Constant Field Values

UNLIMITED_UNITS_DB_STRING

public static final java.lang.String UNLIMITED_UNITS_DB_STRING
See Also:
Constant Field Values

ALLOW_ANY_SERVER_IP

public static final java.lang.String[] ALLOW_ANY_SERVER_IP
Constructor Detail

License

public License(java.lang.String component,
               java.lang.String[] allowedIps,
               java.util.Date expiration,
               java.lang.String key,
               java.util.Hashtable unitProps,
               java.util.Properties params)
Constructor initializing License with specified parameters

Parameters:
component - Component name
allowedIps - IP addresses this license is valid for
expiration - Expiration date for this license
key - Calculated key for this license
unitProps - Any "unit" parameters
params - Any String parameters
Method Detail

getComponent

public java.lang.String getComponent()
Returns the component name. For example, "building.blocks".

Returns:
Component name read from license file.

getAllowedIps

public java.lang.String[] getAllowedIps()
Returns the set of IP addresses that this license is restricted to run on.

Returns:
Array of IP addresses, in String form

getExpiration

public java.util.Date getExpiration()
Returns the expiration date for this component.

Returns:
When this key expires or null if never.

getKey

public java.lang.String getKey()
Returns the validation digest for this component.

Returns:
String representation of digest

getUnitsParameter

public java.lang.Integer getUnitsParameter(java.lang.String propertyName)
Returns the value for the specified unit. A unit is a simple name/value pair to associate arbitrary parameters with the license. Units are always expressed as integers.

Parameters:
propertyName - Name of the unit to retrieve the value for
Returns:
Integer value for the specified parameter

getParameter

public java.lang.String getParameter(java.lang.String name)
Returns the value for the specified custom parameter. Values are returned as Strings.

Parameters:
name - Parameter to retrieve.
Returns:
Value for specified parameter.

isExpired

public boolean isExpired()
Returns whether this component has expired.

Returns:
True, if component's expiration date is past.

hasValidKey

public boolean hasValidKey()
Returns whether this component's validation key is correct.

Returns:
True if the validation key is correct

assertHasValidKey

public void assertHasValidKey()
                       throws BadLicenseKeyException
Identical to hasValidKey(), except that a checked exception is thrown if the key is not valid.

Throws:
BadLicenseKeyException - Thrown if hasValidKey() evaluates to false.

isValidForThisServer

public boolean isValidForThisServer()
Check to see if this server is in the set of valid IP addresses associated for this license component.

Returns:
true if server's IP address is in list of valid IPs, or if the license is for "any" IP.

assertIsLicensed

public void assertIsLicensed()
                      throws LicenseExpiredException,
                             UnlicensedServerException
Assertion that a valid license exists, including validating expiration and valid IP addresses.

Throws:
LicenseExpiredException - If the license is expired
UnlicensedServerException - If the IP address for the server is not valid

serializeAsProperties

public void serializeAsProperties(java.util.Properties p,
                                  java.lang.String namePrefix)
Writes component out in property (name/value) format.

Parameters:
p - Properties object to insert values into
namePrefix - Prefix for property names

serializeAsXml

public java.lang.String serializeAsXml(java.lang.String lineSeparator)
Writes out this license as a String, using the specified lineSeparator

Returns:
String representation of XML element for this license.


Copyright © 2003 Blackboard, Inc. All Rights Reserved.