be.fedict.eid.applet.service.signer
Class AbstractXmlSignatureService

java.lang.Object
  extended by be.fedict.eid.applet.service.signer.AbstractXmlSignatureService
All Implemented Interfaces:
SignatureService
Direct Known Subclasses:
AbstractASiCSignatureService, AbstractODFSignatureService, AbstractOOXMLSignatureService

public abstract class AbstractXmlSignatureService
extends Object
implements SignatureService

Abstract base class for an XML Signature Service implementation.

Author:
Frank Cornelis

Constructor Summary
AbstractXmlSignatureService(DigestAlgo digestAlgo)
          Main constructor.
 
Method Summary
protected  void addSignatureFacet(SignatureFacet signatureFacet)
          Adds a signature facet to this XML signature service.
protected  String getCanonicalizationMethod()
           
protected  Document getEnvelopingDocument()
          Gives back the enveloping document.
protected  String getSignatureDescription()
          Gives back the human-readable description of what the citizen will be signing.
protected  DigestAlgo getSignatureDigestAlgorithm()
          Gives back the signature digest algorithm.
protected abstract  OutputStream getSignedDocumentOutputStream()
          Gives back the output stream to which to write the signed XML document.
protected abstract  TemporaryDataStorage getTemporaryDataStorage()
          Gives back a temporary data storage component.
protected  javax.xml.crypto.URIDereferencer getURIDereferencer()
          Override this method to change the URI dereferener used by the signing engine.
protected  Document loadDocument(InputStream documentInputStream)
           
protected  Document loadDocumentNoClose(InputStream documentInputStream)
           
 void postSign(byte[] signatureValue, List<X509Certificate> signingCertificateChain)
           
 DigestInfo preSign(List<DigestInfo> digestInfos, List<X509Certificate> signingCertificateChain)
           
protected  void setSignatureId(String signatureId)
          Sets the signature Id attribute value used to create the XML signature.
protected  void setSignatureNamespacePrefix(String signatureNamespacePrefix)
          Sets the XML Signature namespace prefix to be used for signature creation.
protected  void writeDocument(Document document, OutputStream documentOutputStream)
           
protected  void writeDocumentNoClosing(Document document, OutputStream documentOutputStream)
           
protected  void writeDocumentNoClosing(Document document, OutputStream documentOutputStream, boolean omitXmlDeclaration)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface be.fedict.eid.applet.service.spi.SignatureService
getFilesDigestAlgorithm
 

Constructor Detail

AbstractXmlSignatureService

public AbstractXmlSignatureService(DigestAlgo digestAlgo)
Main constructor.

Method Detail

setSignatureId

protected void setSignatureId(String signatureId)
Sets the signature Id attribute value used to create the XML signature. A null value will trigger an automatically generated signature Id.

Parameters:
signatureId -

setSignatureNamespacePrefix

protected void setSignatureNamespacePrefix(String signatureNamespacePrefix)
Sets the XML Signature namespace prefix to be used for signature creation. A null value will omit the prefixing.

Parameters:
signatureNamespacePrefix -

addSignatureFacet

protected void addSignatureFacet(SignatureFacet signatureFacet)
Adds a signature facet to this XML signature service.

Parameters:
signatureFacet -

getSignatureDigestAlgorithm

protected DigestAlgo getSignatureDigestAlgorithm()
Gives back the signature digest algorithm. Allowed values are SHA-1, SHA-256, SHA-384, SHA-512, RIPEND160. The default algorithm is SHA-1. Override this method to select another signature digest algorithm.

Returns:

getEnvelopingDocument

protected Document getEnvelopingDocument()
                                  throws ParserConfigurationException,
                                         IOException,
                                         SAXException
Gives back the enveloping document. Return null in case ds:Signature should be the top-level element. Implementations can override this method to provide a custom enveloping document.

Returns:
Throws:
SAXException
IOException
ParserConfigurationException

getURIDereferencer

protected javax.xml.crypto.URIDereferencer getURIDereferencer()
Override this method to change the URI dereferener used by the signing engine.

Returns:

getSignatureDescription

protected String getSignatureDescription()
Gives back the human-readable description of what the citizen will be signing. The default value is "XML Document". Override this method to provide the citizen with another description.

Returns:

getTemporaryDataStorage

protected abstract TemporaryDataStorage getTemporaryDataStorage()
Gives back a temporary data storage component. This component is used for temporary storage of the XML signature documents.

Returns:

getSignedDocumentOutputStream

protected abstract OutputStream getSignedDocumentOutputStream()
Gives back the output stream to which to write the signed XML document.

Returns:

preSign

public DigestInfo preSign(List<DigestInfo> digestInfos,
                          List<X509Certificate> signingCertificateChain)
                   throws NoSuchAlgorithmException
Specified by:
preSign in interface SignatureService
Throws:
NoSuchAlgorithmException

postSign

public void postSign(byte[] signatureValue,
                     List<X509Certificate> signingCertificateChain)
Specified by:
postSign in interface SignatureService

getCanonicalizationMethod

protected String getCanonicalizationMethod()

writeDocument

protected void writeDocument(Document document,
                             OutputStream documentOutputStream)
                      throws TransformerConfigurationException,
                             TransformerFactoryConfigurationError,
                             TransformerException,
                             IOException
Throws:
TransformerConfigurationException
TransformerFactoryConfigurationError
TransformerException
IOException

writeDocumentNoClosing

protected void writeDocumentNoClosing(Document document,
                                      OutputStream documentOutputStream)
                               throws TransformerConfigurationException,
                                      TransformerFactoryConfigurationError,
                                      TransformerException,
                                      IOException
Throws:
TransformerConfigurationException
TransformerFactoryConfigurationError
TransformerException
IOException

writeDocumentNoClosing

protected void writeDocumentNoClosing(Document document,
                                      OutputStream documentOutputStream,
                                      boolean omitXmlDeclaration)
                               throws TransformerConfigurationException,
                                      TransformerFactoryConfigurationError,
                                      TransformerException,
                                      IOException
Throws:
TransformerConfigurationException
TransformerFactoryConfigurationError
TransformerException
IOException

loadDocument

protected Document loadDocument(InputStream documentInputStream)
                         throws ParserConfigurationException,
                                SAXException,
                                IOException
Throws:
ParserConfigurationException
SAXException
IOException

loadDocumentNoClose

protected Document loadDocumentNoClose(InputStream documentInputStream)
                                throws ParserConfigurationException,
                                       SAXException,
                                       IOException
Throws:
ParserConfigurationException
SAXException
IOException


Copyright © 2008-2012 FedICT. All Rights Reserved.