anon.crypto
Class SignatureVerifier

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

public class SignatureVerifier
extends java.lang.Object
implements IXMLEncodable

Manages the verification of all signatures.


Field Summary
static int DOCUMENT_CLASS_INFOSERVICE
          This is the class for all documents coming from infoservices (infoserviceinfo).
static int DOCUMENT_CLASS_MIX
          This is the class for all documents coming from mixes (mixinfo, cascadeinfo, status).
static int DOCUMENT_CLASS_NONE
           
static int DOCUMENT_CLASS_PAYMENT
           
static int DOCUMENT_CLASS_TERMS
           
static int DOCUMENT_CLASS_UPDATE
          This is the class for all documents with JAP update specific stuff (WebStart files, minimal JAP version).
private  boolean m_checkSignatures
          Stores whether signature checking is enabled or disabled.
private  java.util.Hashtable m_hashSignatureChecks
          Stores whether signature checks for a document type are done or not.
private  CertificateStore m_trustedCertificates
          Stores all trusted certificates.
private static SignatureVerifier ms_svInstance
          Stores the instance of SignatureVerifier (Singleton).
private static java.lang.String XML_ATTR_CHECK
           
private static java.lang.String XML_ATTR_CLASS
           
private static java.lang.String XML_DOCUMENT_CLASS
           
static java.lang.String XML_ELEMENT_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_LANGUAGE, XML_ATTR_VERSION
 
Constructor Summary
private SignatureVerifier()
          Creates a new instance of SignatureVerifier.
 
Method Summary
static SignatureVerifier getInstance()
          Returns the instance of SignatureVerifier (Singleton).
 CertificateStore getVerificationCertificateStore()
          Returns the certificate store used for the verification of all signatures.
 XMLSignature getVerifiedXml(org.w3c.dom.Element a_rootNode, int a_documentClass)
          Verifies the signature of an XML document against the store of trusted certificates.
static java.lang.String getXmlSettingsRootNodeName()
          Returns the name of the XML node used to store all settings of the SignatureVerifier instance.
 boolean isCheckSignatures()
          Returns whether signature verification is enabled or not.
 boolean isCheckSignatures(int a_documentClass)
           
 void loadSettingsFromXml(org.w3c.dom.Element a_signatureVerificationNode)
           
 void loadSettingsFromXml(org.w3c.dom.Element a_signatureVerificationNode, java.util.Hashtable a_ignoredDocClasses)
          Restores the settings of this instance of SignatureVerifier with the settings stored in the specified XML node.
 void setCheckSignatures(boolean a_checkSignaturesEnabled)
          Enables or disables the check of signatures.
 void setCheckSignatures(int a_documentClass, boolean a_bCheckignatures)
           
 org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
          Returns all settings (including the verification certificate store) as an XML node.
 boolean verifyXml(org.w3c.dom.Document a_rootNode, int a_documentClass)
          Verifies the signature of an XML document against the store of trusted certificates.
 boolean verifyXml(org.w3c.dom.Element a_rootNode, int a_documentClass)
          Verifies the signature of an XML document against the store of trusted certificates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOCUMENT_CLASS_NONE

public static final int DOCUMENT_CLASS_NONE
See Also:
Constant Field Values

DOCUMENT_CLASS_MIX

public static final int DOCUMENT_CLASS_MIX
This is the class for all documents coming from mixes (mixinfo, cascadeinfo, status).

See Also:
Constant Field Values

DOCUMENT_CLASS_INFOSERVICE

public static final int DOCUMENT_CLASS_INFOSERVICE
This is the class for all documents coming from infoservices (infoserviceinfo).

See Also:
Constant Field Values

DOCUMENT_CLASS_UPDATE

public static final int DOCUMENT_CLASS_UPDATE
This is the class for all documents with JAP update specific stuff (WebStart files, minimal JAP version).

See Also:
Constant Field Values

DOCUMENT_CLASS_PAYMENT

public static final int DOCUMENT_CLASS_PAYMENT
See Also:
Constant Field Values

DOCUMENT_CLASS_TERMS

public static final int DOCUMENT_CLASS_TERMS
See Also:
Constant Field Values

XML_ELEMENT_NAME

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

See Also:
Constant Field Values

XML_ATTR_CHECK

private static final java.lang.String XML_ATTR_CHECK
See Also:
Constant Field Values

XML_DOCUMENT_CLASS

private static final java.lang.String XML_DOCUMENT_CLASS
See Also:
Constant Field Values

XML_ATTR_CLASS

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

ms_svInstance

private static SignatureVerifier ms_svInstance
Stores the instance of SignatureVerifier (Singleton).


m_hashSignatureChecks

private java.util.Hashtable m_hashSignatureChecks
Stores whether signature checks for a document type are done or not. It holde the document type as Integer key and a Boolean.


m_trustedCertificates

private CertificateStore m_trustedCertificates
Stores all trusted certificates.


m_checkSignatures

private boolean m_checkSignatures
Stores whether signature checking is enabled or disabled. If this value is false, every document is accept without checking the signature.

Constructor Detail

SignatureVerifier

private SignatureVerifier()
Creates a new instance of SignatureVerifier.

Method Detail

getInstance

public static SignatureVerifier getInstance()
Returns the instance of SignatureVerifier (Singleton). If there is no instance, there is a new one created.

Returns:
The SignatureVerifier instance.

getXmlSettingsRootNodeName

public static java.lang.String getXmlSettingsRootNodeName()
Returns the name of the XML node used to store all settings of the SignatureVerifier instance. This name can be used to find the XML node within a document when the settings shall be loaded.

Returns:
The name of the XML node created when storing the settings.

setCheckSignatures

public void setCheckSignatures(boolean a_checkSignaturesEnabled)
Enables or disables the check of signatures. If signature checking is disabled, the verify methods will return true in every case without checking anything. If this value is enabled, every signature is verified against the internal certificate store.

Parameters:
a_checkSignaturesEnabled - True, if signature checking shall be enabled, false if it shall be disabled.

setCheckSignatures

public void setCheckSignatures(int a_documentClass,
                               boolean a_bCheckignatures)

isCheckSignatures

public boolean isCheckSignatures(int a_documentClass)

isCheckSignatures

public boolean isCheckSignatures()
Returns whether signature verification is enabled or not. If signature checking is disabled, the veriy methods will return true in every case without checking anything. If this value is enabled, every signature is verified against the internal certificate store.

Returns:
True, if every signature is really verified against the internal certificate store or false if the verify methods are successful without performing any verification.

getVerificationCertificateStore

public CertificateStore getVerificationCertificateStore()
Returns the certificate store used for the verification of all signatures.

Returns:
The certificate store used for the signature verification.

verifyXml

public boolean verifyXml(org.w3c.dom.Document a_rootNode,
                         int a_documentClass)
Verifies the signature of an XML document against the store of trusted certificates. This methode returns true, if the signature of the document is valid, the signing certificate can be derived from one of the trusted certificates (or is one of them) and if all of the needed certificates in the path have the permission to sign documents of this class. This method also returns always true if signature checking is disabled.

Parameters:
a_rootNode - The root node of the document. The Signature node must be one of the children of the root node.
a_documentClass - The class of the document. See the constants in this class.
Returns:
True, if the signature (and appended certificate) could be verified against the trusted certificates or false if not.

verifyXml

public boolean verifyXml(org.w3c.dom.Element a_rootNode,
                         int a_documentClass)
Verifies the signature of an XML document against the store of trusted certificates. This methode returns true, if the signature of the document is valid, the signing certificate can be derived from one of the trusted certificates (or is one of them) and if all of the needed certificates in the path have the permission to sign documents of this class. This method also returns always true if signature checking is disabled.

Parameters:
a_rootNode - The root node of the document. The Signature node must be one of the children of the root node.
a_documentClass - The class of the document. See the constants in this class.
Returns:
True, if the signature (and appended certificate) could be verified against the trusted certificates or false if not.

getVerifiedXml

public XMLSignature getVerifiedXml(org.w3c.dom.Element a_rootNode,
                                   int a_documentClass)
Verifies the signature of an XML document against the store of trusted certificates.

Parameters:
a_rootNode - The root node of the document. The Signature node must be one of the children of the root node.
a_documentClass - The class of the document. See the constants in this class.
Returns:
the XMLSignature that should be verified. It is also returned if the verification was NOT successful. Call isVerified() on the returned XMLSignature Object to get the result of the verification.

toXmlElement

public org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
Returns all settings (including the verification certificate store) as an XML node.

Specified by:
toXmlElement in interface IXMLEncodable
Parameters:
a_doc - The parent document for the created XML node.
Returns:
The settings of this instance of SignatureVerifier as an XML node.

loadSettingsFromXml

public void loadSettingsFromXml(org.w3c.dom.Element a_signatureVerificationNode)
                         throws java.lang.Exception
Throws:
java.lang.Exception

loadSettingsFromXml

public void loadSettingsFromXml(org.w3c.dom.Element a_signatureVerificationNode,
                                java.util.Hashtable a_ignoredDocClasses)
                         throws java.lang.Exception
Restores the settings of this instance of SignatureVerifier with the settings stored in the specified XML node.

Parameters:
a_signatureVerificationNode - The XML node for loading the settings from. The name of the needed XML node can be obtained by calling getXmlSettingsRootNodeName().
Throws:
java.lang.Exception