Class CreateSignedTimeStamp

  • All Implemented Interfaces:
    SignatureInterface

    public class CreateSignedTimeStamp
    extends java.lang.Object
    implements SignatureInterface
    An example for timestamp-signing a PDF for PADeS-Specification. The document will be extended by a signed TimeStamp (another kind of signature) (Signed TimeStamp and Hash-Value of the document are signed by a Time Stamp Authority (TSA)).
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static org.apache.commons.logging.Log LOG  
      private java.lang.String tsaUrl  
    • Constructor Summary

      Constructors 
      Constructor Description
      CreateSignedTimeStamp​(java.lang.String tsaUrl)
      Initialize the signed timestamp creator
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void main​(java.lang.String[] args)  
      byte[] sign​(java.io.InputStream content)
      Creates a cms signature for the given content
      void signDetached​(java.io.File file)
      Signs the given PDF file.
      void signDetached​(java.io.File inFile, java.io.File outFile)
      Signs the given PDF file.
      void signDetached​(PDDocument document, java.io.OutputStream output)
      Prepares the TimeStamp-Signature and starts the saving-process.
      private static void usage()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOG

        private static final org.apache.commons.logging.Log LOG
      • tsaUrl

        private final java.lang.String tsaUrl
    • Constructor Detail

      • CreateSignedTimeStamp

        public CreateSignedTimeStamp​(java.lang.String tsaUrl)
        Initialize the signed timestamp creator
        Parameters:
        tsaUrl - The url where TS-Request will be done.
    • Method Detail

      • signDetached

        public void signDetached​(java.io.File file)
                          throws java.io.IOException
        Signs the given PDF file. Alters the original file on disk.
        Parameters:
        file - the PDF file to sign
        Throws:
        java.io.IOException - if the file could not be read or written
      • signDetached

        public void signDetached​(java.io.File inFile,
                                 java.io.File outFile)
                          throws java.io.IOException
        Signs the given PDF file.
        Parameters:
        inFile - input PDF file
        outFile - output PDF file
        Throws:
        java.io.IOException - if the input file could not be read
      • signDetached

        public void signDetached​(PDDocument document,
                                 java.io.OutputStream output)
                          throws java.io.IOException
        Prepares the TimeStamp-Signature and starts the saving-process.
        Parameters:
        document - given Pdf
        output - Where the file will be written
        Throws:
        java.io.IOException
      • sign

        public byte[] sign​(java.io.InputStream content)
                    throws java.io.IOException
        Description copied from interface: SignatureInterface
        Creates a cms signature for the given content
        Specified by:
        sign in interface SignatureInterface
        Parameters:
        content - is the content as a (Filter)InputStream
        Returns:
        signature as a byte array
        Throws:
        java.io.IOException - if the signature could not be created
      • main

        public static void main​(java.lang.String[] args)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • usage

        private static void usage()