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.
-
HostAndDurationLicensePolicy()
- Constructs a HostAndDurationLicensePolicy object.
-
getEncodedSignature()
- Gets the X.509 encoded signature.
-
getExpirationDate()
- Gets the license expiration date property of the license policy.
-
getHost()
- Gets the host name property of the license policy.
-
getPrivateKey()
- Gets the PrivateKey property of the license policy.
-
getPublicKey()
- Gets the PublicKey property of the license policy.
-
setEncodedSignature(byte[])
- Sets the encoded signature property of the license policy.
-
setExpirationDate(Date)
- Sets the license expiration date property of the license policy.
-
setHost(String)
- Sets the host name property of the license policy.
-
setPrivateKey(PrivateKey)
- Sets the PrivateKey property of the license policy.
-
setPublicKey(PublicKey)
- Sets the PublicKey property of the license policy.
-
sign()
- Creates a license based on current property
settings.
-
update()
- Encapsulates the
update methods of the Signature class to ensure the proper data
is being validated.
-
verify()
- Validates a license based on the current property
settings.
HostAndDurationLicensePolicy
public HostAndDurationLicensePolicy()
- Constructs a HostAndDurationLicensePolicy object.
getPrivateKey
public PrivateKey getPrivateKey()
- Gets the PrivateKey property of the license policy.
- Returns:
- The private key property object.
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.
getPublicKey
public PublicKey getPublicKey()
- Gets the PublicKey property of the license policy.
- Returns:
- The public key property object.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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