anon.crypto
Class CertPath

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

public class CertPath
extends java.lang.Object
implements IXMLEncodable

Stores a certification path with all included certificates. Keep in mind, that this CertPath adds a new Certificate to the BEGINNING of the Vector. That means the first Certificate is at the end of the Vector.

Author:
Robert Hirschberger
See Also:
gui.CertDetailsDialog, anon.crypto.XMLSignature

Field Summary
private  int m_certCount
          the number of certificates included in this CertPath
private  java.util.Vector m_certificates
          the included certificates
private  int m_rootCertificateClass
          the certificate class of the rootCerts that may verify this CertPath
static java.lang.String XML_ATTR_CLASS
           
static java.lang.String XML_ELEMENT_NAME
           
 
Fields inherited from interface anon.util.IXMLEncodable
FIELD_XML_ELEMENT_CONTAINER_NAME, FIELD_XML_ELEMENT_NAME, XML_ATTR_ID, XML_ATTR_VERSION
 
Constructor Summary
protected CertPath(org.w3c.dom.Element a_elemCertPath)
           
protected CertPath(JAPCertificate firstCert)
          Creates a new CertPath Object from a given Certificate
 
Method Summary
protected  void add(JAPCertificate a_certificate)
          Adds a certificate to next higher level of this CertPath, if the cert is not already included
 boolean checkValidity(java.util.Date a_date)
          Checks the validity of all certificates in the path.
 int getCertCount()
          Returns the number of certificates in this CertPath
 java.util.Enumeration getCertificates()
          Creates an Enumeration of CertificateInfoStructures of the included certs.
 JAPCertificate getFirstCertificate()
          Returns the certificate from the lowest Level of this CertPath (the one that was added at first).
protected  JAPCertificate getLatestAddedCertificate()
          Returns the top level certificate (it is the one that was last added)
 JAPCertificate getSecondCertificate()
          Returns the certificate from the second lowest Level of this CertPath (the one that was added at Second).
private  CertificateInfoStructure getVerifier(boolean checkValidity)
          Tries to find a verifying root certificate for the top level cert.
protected  void remove(JAPCertificate a_certificate)
          Removes the specified certificate from this CertPath
protected  void removeAllButLast()
          Removes all certificates except the one on the lowest level of this certPath
protected  void setDocType(int a_documentClass)
          Sets the certificate class for the root certificates that can verify this Cert Path.
 java.lang.String toString()
          Creates a human readable List in String-Format using the CommonNames of the included certs.
 org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
          Return an element that can be appended to the document.
 boolean verify()
          Tries to verify the top level certificate in this CertPath against the root certificates.
 boolean verify(JAPCertificate a_certificate)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

XML_ELEMENT_NAME

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

XML_ATTR_CLASS

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

m_certCount

private int m_certCount
the number of certificates included in this CertPath


m_rootCertificateClass

private int m_rootCertificateClass
the certificate class of the rootCerts that may verify this CertPath


m_certificates

private java.util.Vector m_certificates
the included certificates

Constructor Detail

CertPath

protected CertPath(JAPCertificate firstCert)
Creates a new CertPath Object from a given Certificate

Parameters:
firstCert - The first certifiacte of the path (it will be on the lowest Level of the cert hierarchy)

CertPath

protected CertPath(org.w3c.dom.Element a_elemCertPath)
            throws XMLParseException
Throws:
XMLParseException
Method Detail

toXmlElement

public org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
Description copied from interface: IXMLEncodable
Return an element that can be appended to the document. This Method must not change the document in any way!

Specified by:
toXmlElement in interface IXMLEncodable
Parameters:
a_doc - a document
Returns:
the interface as xml element

add

protected void add(JAPCertificate a_certificate)
Adds a certificate to next higher level of this CertPath, if the cert is not already included

Parameters:
a_certificate - the certificate to add

remove

protected void remove(JAPCertificate a_certificate)
Removes the specified certificate from this CertPath

Parameters:
a_certificate - the certificate to remove

removeAllButLast

protected void removeAllButLast()
Removes all certificates except the one on the lowest level of this certPath


getLatestAddedCertificate

protected JAPCertificate getLatestAddedCertificate()
Returns the top level certificate (it is the one that was last added)

Returns:
the last added certificate

getFirstCertificate

public JAPCertificate getFirstCertificate()
Returns the certificate from the lowest Level of this CertPath (the one that was added at first). If this CertPath is from a Mix this would be the Mix Certificate.

Returns:
the first added certificate

getSecondCertificate

public JAPCertificate getSecondCertificate()
Returns the certificate from the second lowest Level of this CertPath (the one that was added at Second). If this CertPath is from a Mix this would be the Operator Certificate.

Returns:
the second added certificate

setDocType

protected void setDocType(int a_documentClass)
Sets the certificate class for the root certificates that can verify this Cert Path. This Method is usually called by the getVerifiedXml()-from the SignatureVerifier. It translates the document class from the SignatureVerifier to the certificate class from JAPCertificate

Parameters:
a_documentClass - a document class from the SignatureVerifier
See Also:
anon.crypto.SignatureVerifier.getVerifiedXml()

getVerifier

private CertificateInfoStructure getVerifier(boolean checkValidity)
Tries to find a verifying root certificate for the top level cert. After that we get the CertificateInfoStructure for this cert from the SignatureVerifier.

Parameters:
checkValidity - shall the validity be checked?
Returns:
the CertificateInfoStructure for the verifing certificate, null if there is none.
See Also:
anon.crypto.SignatureVerifier.getCertificateInfoStructure()

checkValidity

public boolean checkValidity(java.util.Date a_date)
Checks the validity of all certificates in the path. If only one of the certificates is outdated, it returns false.

Parameters:
a_date - the date for which the validity of the path is tested
Returns:
if all certificates in the path are valid at the given time

verify

public boolean verify(JAPCertificate a_certificate)

verify

public boolean verify()
Tries to verify the top level certificate in this CertPath against the root certificates. If this last certificate can be verified the whole CertPath is verified, because we only generate valid CertPaths

Returns:
true if the CertPath could be verified

getCertCount

public int getCertCount()
Returns the number of certificates in this CertPath

Returns:
the number of certificates in this CertPath

getCertificates

public java.util.Enumeration getCertificates()
Creates an Enumeration of CertificateInfoStructures of the included certs. The first element of this Enumeration is the verifier of this CertPath if there is one. The isEnabled() field of the CIS is used to mark if the certs are verified.

Returns:
an Enumeration of CertificateInfoStructures of the included certs plus the verifier as first element if there is one.

toString

public java.lang.String toString()
Creates a human readable List in String-Format using the CommonNames of the included certs. This is mainly used for debugging. To display a CertPath use a CertDetailsDialog and call the getCertificates()-Method

Overrides:
toString in class java.lang.Object
Returns:
a String representation of this CertPath object