All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.beans.samples.dips.license.HostAndDurationLicensePolicy

java.lang.Object
   |
   +----com.ibm.beans.samples.dips.license.HostAndDurationLicensePolicy

public class HostAndDurationLicensePolicy
extends Object
implements Serializable
This class implements methods that restict running to a particular host name up to a date when the license expires.


Constructor Index

 o HostAndDurationLicensePolicy()
Constructs a HostAndDurationLicensePolicy object.

Method Index

 o getEncodedSignature()
Gets the X.509 encoded signature.
 o getExpirationDate()
Gets the license expiration date property of the license policy.
 o getHost()
Gets the host name property of the license policy.
 o getPrivateKey()
Gets the PrivateKey property of the license policy.
 o getPublicKey()
Gets the PublicKey property of the license policy.
 o setEncodedSignature(byte[])
Sets the encoded signature property of the license policy.
 o setExpirationDate(Date)
Sets the license expiration date property of the license policy.
 o setHost(String)
Sets the host name property of the license policy.
 o setPrivateKey(PrivateKey)
Sets the PrivateKey property of the license policy.
 o setPublicKey(PublicKey)
Sets the PublicKey property of the license policy.
 o sign()
Creates a license based on current property settings.
 o update()
Encapsulates the update methods of the Signature class to ensure the proper data is being validated.
 o verify()
Validates a license based on the current property settings.

Constructors

 o HostAndDurationLicensePolicy
 public HostAndDurationLicensePolicy()
Constructs a HostAndDurationLicensePolicy object.

Methods

 o getPrivateKey
 public PrivateKey getPrivateKey()
Gets the PrivateKey property of the license policy.

Returns:
The private key property object.
 o setPrivateKey
 public synchronized void setPrivateKey(PrivateKey key) throws InvalidKeyException
Sets the PrivateKey property of the license policy. Only one of the PrivateKey and PublicKey properties can be set at any time. A key property cannot be set more than once. The keys must be generated using a KeyPairGenerator which uses the DSA algorithm. See java.security.KeyPairGenerator for details.

Parameters:
key - The private key to which the property is set.
Throws: InvalidKeyException
This method throws this exception if the public key is already set, the private key is already set, or an invalid key object is given.
 o getPublicKey
 public PublicKey getPublicKey()
Gets the PublicKey property of the license policy.

Returns:
The public key property object.
 o setPublicKey
 public synchronized void setPublicKey(PublicKey key) throws InvalidKeyException
Sets the PublicKey property of the license policy. Only one of the PrivateKey and PublicKey properties can be set at any time. A key property cannot be set more than once. The keys must be generated using a KeyPairGenerator which uses the DSA algorithm. See java.security.KeyPairGenerator for details.

Parameters:
key - The public key to which the property is set.
Throws: InvalidKeyException
This method throws this exception if the public key is already set, the private key is already set, or an invalid key object is given.
 o getEncodedSignature
 public byte[] getEncodedSignature()
Gets the X.509 encoded signature. The encoded signature is obtained from the sign method.

Returns:
A byte array containing the X.509 encoded signature.
 o setEncodedSignature
 public void setEncodedSignature(byte ec[])
Sets the encoded signature property of the license policy. This information is required to verify a license and is obtained from the sign method.

Parameters:
ec[] - The X.509 encoded signature.
 o getHost
 public String getHost()
Gets the host name property of the license policy. The host name property restricts execution to the specified host.

The property always returns the name of the host the bean is running on if the public key property is set.

Returns:
A string containing the host name property.
 o setHost
 public void setHost(String host)
Sets the host name property of the license policy. The host name property restricts execution to the specified host. The setting of this property is ignored if the policy object has a public key property set. Setting the public key resets the host name.

Parameters:
host - The host name that allows the bean to run.
 o getExpirationDate
 public Date getExpirationDate()
Gets the license expiration date property of the license policy. The verify method will not return true past the specified date.

Returns:
A Date containing the expiration date of the license property.
 o setExpirationDate
 public void setExpirationDate(Date d)
Sets the license expiration date property of the license policy. The verify method does not return true past the specified date.

Parameters:
d - The expiration date of the license.
 o update
 protected void update() throws SignatureException
Encapsulates the update methods of the Signature class to ensure the proper data is being validated. It should be overriden by subclasses to define what data is validated for the license. It is called for both signing and verifying a license.

Throws: SignatureException
The method throws a signature exception if the license policy is not properly initialized.
 o sign
 public byte[] sign() throws SignatureException
Creates a license based on current property settings. This is done by a license issuer.

Returns:
A byte array containing the X.509 encoded signature for the newly created license.
Throws: SignatureException
This method will throw a signature exception if the license policy is not properly initialized.
 o verify
 public boolean verify() throws SignatureException
Validates a license based on the current property settings.

Returns:
true if license is valid; false otherwise.
Throws: SignatureException
This method throws a signature exception if the license policy is not properly initialized.

All Packages  Class Hierarchy  This Package  Previous  Next  Index