Top Description Fields Constructors Methods
org.apache.pdfbox.examples.signature

public Class CreateSignedTimeStamp

extends Object
implements SignatureInterface
Class Inheritance
All Implemented Interfaces
org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface
Imports
java.io.File, .FileNotFoundException, .FileOutputStream, .IOException, .InputStream, .OutputStream, java.net.URISyntaxException, java.security.NoSuchAlgorithmException, org.apache.commons.logging.Log, .LogFactory, org.apache.pdfbox.Loader, org.apache.pdfbox.cos.COSName, org.apache.pdfbox.pdmodel.PDDocument, org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature, .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)).
Authors
Thomas Chojecki, Vakhtang Koroghlishvili, John Hewson, Alexis Suter

Field Summary

Modifier and TypeField and Description
private static final Log
private final String

Constructor Summary

AccessConstructor and Description
public
CreateSignedTimeStamp(String
The url where TS-Request will be done.
tsaUrl
)

Initialize the signed timestamp creator

Method Summary

Modifier and TypeMethod and Description
public static void
main(String[] args)

public byte[]
sign(InputStream
is the content as a (Filter)InputStream
content
)

Implements org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface.sign.

Creates a cms signature for the given content

public void
signDetached(File
the PDF file to sign
file
)

Signs the given PDF file.

public void
signDetached(File
input PDF file
inFile
,
File
output PDF file
outFile
)

Signs the given PDF file.

public void
signDetached(PDDocument
given Pdf
document
,
OutputStream
Where the file will be written
output
)

Prepares the TimeStamp-Signature and starts the saving-process.

private static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGback to summary
private static final Log LOG
tsaUrlback to summary
private final String tsaUrl

Constructor Detail

CreateSignedTimeStampback to summary
public CreateSignedTimeStamp(String tsaUrl)

Initialize the signed timestamp creator

Parameters
tsaUrl:String

The url where TS-Request will be done.

Method Detail

mainback to summary
public static void main(String[] args) throws IOException
signback to summary
public byte[] sign(InputStream content) throws IOException

Implements org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface.sign.

Doc from org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface.sign.

Creates a cms signature for the given content

Parameters
content:InputStream

is the content as a (Filter)InputStream

Returns:byte[]

signature as a byte array

Annotations
@Override
Exceptions
IOException:
if the signature could not be created
signDetachedback to summary
public void signDetached(File file) throws IOException

Signs the given PDF file. Alters the original file on disk.

Parameters
file:File

the PDF file to sign

Exceptions
IOException:
if the file could not be read or written
signDetachedback to summary
public void signDetached(File inFile, File outFile) throws IOException

Signs the given PDF file.

Parameters
inFile:File

input PDF file

outFile:File

output PDF file

Exceptions
IOException:
if the input file could not be read
signDetachedback to summary
public void signDetached(PDDocument document, OutputStream output) throws IOException

Prepares the TimeStamp-Signature and starts the saving-process.

Parameters
document:PDDocument

given Pdf

output:OutputStream

Where the file will be written

usageback to summary
private static void usage()