anon.crypto
Class CertificateContainer

java.lang.Object
  extended by anon.crypto.CertificateContainer
All Implemented Interfaces:
IXMLEncodable

public class CertificateContainer
extends java.lang.Object
implements IXMLEncodable

This class stores additional settings for every certificate stored within a CertificateStore. Any instance of this class should be visible only within the parent CertificateStore it belongs to.


Field Summary
private  boolean m_bNotRemovable
          Thsi certifcate is NOT removable - used at the moment for some default certs
private  boolean m_certificateNeedsVerification
          Stores, whether this certificate needs verification by a parent certificate in order to get activated within the certificate store.
private  int m_certificateType
          Stores the certificate type of this certificate.
private  CertPath m_certPath
           
private  boolean m_enabled
          Stores, whether this certificate is enabled within the certificate store.
private  java.util.Vector m_lockList
          Stores all locks on this certificate.
private  boolean m_onlyHardRemovable
          Stores, whether the certificate can only be removed from the certificate store by calling the removeCertificate() method.
private  JAPCertificate m_parentCertificate
          Stores the parent certificate (the certificate against which verification of this certificate was successful) of this certificate.
private static java.lang.String XML_SETTINGS_ROOT_NODE_NAME
          Stores the name of the root node of the XML settings for this class.
 
Fields inherited from interface anon.util.IXMLEncodable
FIELD_XML_ELEMENT_CONTAINER_NAME, FIELD_XML_ELEMENT_NAME, XML_ATTR_ID, XML_ATTR_VERSION
 
Constructor Summary
CertificateContainer(CertPath a_certPath, int a_certificateType, boolean a_certificateNeedsVerification)
          Creates a new instance of CertificateContainer.
CertificateContainer(org.w3c.dom.Element a_certificateContainerNode)
          Creates a new instance of CertificateContainer.
CertificateContainer(JAPCertificate a_certificate, int a_certificateType, boolean a_certificateNeedsVerification)
          Creates a new instance of CertificateContainer.
 
Method Summary
 void enableNotRemovable()
          This certifcate is not removeable - this is a workaround for default certificates
 void enableOnlyHardRemovable()
          Disables the possibility of removing the certificate automatically from the certificate store.
 boolean equals(java.lang.Object a_certificateContainer)
          Note: Only checks if the certificate in the container is the same
 JAPCertificate getCertificate()
          Returns the corresponding certificate for this CertificateContainer.
 boolean getCertificateNeedsVerification()
          Returns, whether this certificate needs verification by a parent certificate in order to get activated within the certificate store.
 int getCertificateType()
          Returns the certificate type of this certificate.
 CertPath getCertPath()
           
 java.lang.String getId()
          Returns a unique id for this CertificateContainer.
 CertificateInfoStructure getInfoStructure()
          Creates an information structure with the settings stored within this certificate container.
 java.util.Vector getLockList()
          Returns the list with all locks on this certificate.
 JAPCertificate getParentCertificate()
          Returns the parent certificate (the certificate against which verification of this certificate was successful) of this certificate.
static java.lang.String getXmlSettingsRootNodeName()
          Returns the name of the XML node created by the instances of this class ('CertificateContainer').
 int hashCode()
          The hash code is derived from the certificate`s id.
 boolean isAvailable()
          Returns whether this certificate is activated within the certificate store.
 boolean isEnabled()
          Stores, whether this certificate is enabled within the certificate store.
 boolean isNotRemovable()
           
 boolean isOnlyHardRemovable()
          Returns, whether the certificate can only be removed from the certificate store by calling the removeCertificate() method.
 void setEnabled(boolean a_enabled)
          Changes the value which stores, whether this certificate is enabled within the certificate store.
 void setParentCertificate(JAPCertificate a_parentCertificate)
          Changes the parent certificate (the certificate against which verification of this certificate was successful) of this certificate.
 org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
          Creates an XML node with most of the settings stored within this certificate container.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_SETTINGS_ROOT_NODE_NAME

private static final java.lang.String XML_SETTINGS_ROOT_NODE_NAME
Stores the name of the root node of the XML settings for this class.

See Also:
Constant Field Values

m_parentCertificate

private JAPCertificate m_parentCertificate
Stores the parent certificate (the certificate against which verification of this certificate was successful) of this certificate. This value is only not null, if this certificate needs verification and the parent certificate is activated within the same certificate store.


m_certPath

private CertPath m_certPath

m_certificateType

private int m_certificateType
Stores the certificate type of this certificate. See the CERTIFICATE_TYPE constants within JAPCertificate.


m_enabled

private boolean m_enabled
Stores, whether this certificate is enabled within the certificate store.


m_certificateNeedsVerification

private boolean m_certificateNeedsVerification
Stores, whether this certificate needs verification by a parent certificate in order to get activated within the certificate store.


m_onlyHardRemovable

private boolean m_onlyHardRemovable
Stores, whether the certificate can only be removed from the certificate store by calling the removeCertificate() method. If this value is false, the certificate will be removed also from the certificate store automatically, if there are no more active locks on the certificate (removeCertificateLock() was called for all locks on the certificate). Also the certificate will be persistent (included in the XML structure created by the certificate store) only, if this value is true (persistence wouldn't make sense for automatically removable certificates).


m_bNotRemovable

private boolean m_bNotRemovable
Thsi certifcate is NOT removable - used at the moment for some default certs


m_lockList

private java.util.Vector m_lockList
Stores all locks on this certificate. Attention: This list can also include locks, if this certificate cannot be removed automatically from the certificate store.

Constructor Detail

CertificateContainer

public CertificateContainer(JAPCertificate a_certificate,
                            int a_certificateType,
                            boolean a_certificateNeedsVerification)
Creates a new instance of CertificateContainer. Only instances of CertificateStore should call this constructor.

Parameters:
a_certificate - The certificate for which the container is built.
a_certificateType - The type of the certificate.
a_certificateNeedsVerification - Whether this certificate is only valid within the certificate store, if it can be verified against an active root certificate from the store.

CertificateContainer

public CertificateContainer(CertPath a_certPath,
                            int a_certificateType,
                            boolean a_certificateNeedsVerification)
Creates a new instance of CertificateContainer. Only instances of CertificateStore should call this constructor.

Parameters:
a_certificate - The certificate for which the container is built.
a_certificateType - The type of the certificate.
a_certificateNeedsVerification - Whether this certificate is only valid within the certificate store, if it can be verified against an active root certificate from the store.

CertificateContainer

public CertificateContainer(org.w3c.dom.Element a_certificateContainerNode)
                     throws java.lang.Exception
Creates a new instance of CertificateContainer. Only instances of CertificateStore should call this constructor. Certificates loaded via this constructor cannot be removed automatically from the certifcate store and will be persistent (isOnlyHardRemovable() will return true).

Parameters:
a_certificateContainerNode - The XML node to load the settings from ('CertificateContainer' node). Such a node can be created by calling toXmlElement().
Throws:
java.lang.Exception
Method Detail

getXmlSettingsRootNodeName

public static java.lang.String getXmlSettingsRootNodeName()
Returns the name of the XML node created by the instances of this class ('CertificateContainer').

Returns:
The name of the XML node created by the instances of this class.

getCertificate

public JAPCertificate getCertificate()
Returns the corresponding certificate for this CertificateContainer.

Returns:
The certificate where the settings stored within this container are belonging to.

getCertPath

public CertPath getCertPath()

setParentCertificate

public void setParentCertificate(JAPCertificate a_parentCertificate)
Changes the parent certificate (the certificate against which verification of this certificate was successful) of this certificate. This value will be null, if the certificate store doesn't contain a matching parent certificate (or if that certificate is not active). This value is not meaningful, if this certificate doesn't need verification.

Parameters:
a_parentCertificate - The parent certificate of this certificate (maybe null).

getParentCertificate

public JAPCertificate getParentCertificate()
Returns the parent certificate (the certificate against which verification of this certificate was successful) of this certificate. This value will be null, if the certificate store doesn't contain a matching parent certificate (or if that certificate is not active). This value is not meaningful, if this certificate doesn't need verification.

Returns:
a_parentCertificate The parent certificate of this certificate (maybe null).

getCertificateType

public int getCertificateType()
Returns the certificate type of this certificate. See the CERTIFICATE_TYPE constants within JAPCertificate.

Returns:
The certificate type of this certificate.

getCertificateNeedsVerification

public boolean getCertificateNeedsVerification()
Returns, whether this certificate needs verification by a parent certificate in order to get activated within the certificate store.

Returns:
Whether this certificate needs to be verified against a root certificate in order to get activated within the certificate store.

isAvailable

public boolean isAvailable()
Returns whether this certificate is activated within the certificate store. Only activated certificates should be used to verify signatures and other certificates. A certificate is activated, if it is enabled and can be verified against a root certificate from the certificate store (only if the certificate requires verification, see getCertificateNeedsVerification() ).

Returns:
Whether this certificate is active within the certificate store.

isEnabled

public boolean isEnabled()
Stores, whether this certificate is enabled within the certificate store.

Returns:
Whether this certificate is enabled within the certificate store.

setEnabled

public void setEnabled(boolean a_enabled)
Changes the value which stores, whether this certificate is enabled within the certificate store.

Parameters:
a_enabled - Whether this certificate shall be enabled within the certificate store.

enableOnlyHardRemovable

public void enableOnlyHardRemovable()
Disables the possibility of removing the certificate automatically from the certificate store. Then the certificate can only be removed from the store by calling removeCertificate(). Without calling this method, the certificate will be removed also from the certificate store automatically, if there are no more active locks on the certificate (removeCertificateLock() was called for all locks on the certificate). Also the certificate will be persistent (included in the XML structure created by the certificate store) any more, if this method is called (persistence wouldn't make sense for automatically removable certificates).


isOnlyHardRemovable

public boolean isOnlyHardRemovable()
Returns, whether the certificate can only be removed from the certificate store by calling the removeCertificate() method. If this value is false, the certificate will be removed also from the certificate store automatically, if there are no more active locks on the certificate (removeCertificateLock() was called for all locks on the certificate). Also the certificate will be persistent (included in the XML structure created by the certificate store) only, if this value is true (persistence wouldn't make sense for automatically removable certificates).

Returns:
Whether the certificate can only be removed from the certificate store by calling removeCertificate() and also whether the certificate will be persistent.

enableNotRemovable

public void enableNotRemovable()
This certifcate is not removeable - this is a workaround for default certificates


isNotRemovable

public boolean isNotRemovable()

getLockList

public java.util.Vector getLockList()
Returns the list with all locks on this certificate. Attention: This list can also include locks, if this certificate cannot be removed automatically from the certificate store.

Returns:
The list with all locks on this certificate within the context of the certificate store this certificate container belongs to.

getInfoStructure

public CertificateInfoStructure getInfoStructure()
Creates an information structure with the settings stored within this certificate container. This structure can also be used outside the certificate store (while this container should not be used outside the certificate store because of the possibility of changing the settings to inconsistent states). The created structure can be used by an application to display the settings of the certificate. But if some of the settings shall be changed, it is necessary to call the corresponding method of the CertificateStore (if available).

Returns:
An information structure with the settings stored within this certificate container.

toXmlElement

public org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
Creates an XML node with most of the settings stored within this certificate container. This node can be used later again to construct a new instance of CertificateContainer.

Specified by:
toXmlElement in interface IXMLEncodable
Parameters:
a_doc - The XML document, which is the environment for the created XML node.
Returns:
The XML node with the settings stored within this certificate container ('CertificateContainer' node).

equals

public boolean equals(java.lang.Object a_certificateContainer)
Note: Only checks if the certificate in the container is the same

Overrides:
equals in class java.lang.Object
See Also:
JAPCertificate.equals()

getId

public java.lang.String getId()
Returns a unique id for this CertificateContainer. The Container has the same id as the included certifacte

Returns:
a unique id for this CertificateContainer
See Also:
JAPCertificate.getId()

hashCode

public int hashCode()
The hash code is derived from the certificate`s id.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code of the certificate
See Also:
JAPCertificate.hashCode()