org.apache.pdfbox.pdmodel.interactive.digitalsignature
Class PDSignature

java.lang.Object
  extended by org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature
All Implemented Interfaces:
COSObjectable

public class PDSignature
extends Object
implements COSObjectable

This represents a digital signature that can be attached to a document.

Version:
$Revision: 1.2 $
Author:
Ben Litchfield, Thomas Chojecki

Field Summary
static COSName FILTER_ADOBE_PPKLITE
          A signature filter value.
static COSName FILTER_CICI_SIGNIT
          A signature filter value.
static COSName FILTER_ENTRUST_PPKEF
          A signature filter value.
static COSName FILTER_VERISIGN_PPKVS
          A signature filter value.
static COSName SUBFILTER_ADBE_PKCS7_DETACHED
          A signature subfilter value.
static COSName SUBFILTER_ADBE_PKCS7_SHA1
          A signature subfilter value.
static COSName SUBFILTER_ADBE_X509_RSA_SHA1
          A signature subfilter value.
static COSName SUBFILTER_ETSI_CADES_DETACHED
          A signature subfilter value.
 
Constructor Summary
PDSignature()
          Default constructor.
PDSignature(COSDictionary dict)
          Constructor.
 
Method Summary
 int[] getByteRange()
          Read out the byterange from the file
 byte[] getContents(byte[] pdfFile)
          Will return the embedded signature between the byterange gap.
 byte[] getContents(InputStream pdfFile)
          Will return the embedded signature between the byterange gap.
 COSBase getCOSObject()
          Convert this standard java object to a COS object.
 COSDictionary getDictionary()
          Convert this standard java object to a COS dictionary.
 String getFilter()
           
 String getLocation()
           
 String getName()
           
 String getReason()
           
 Calendar getSignDate()
           
 byte[] getSignedContent(byte[] pdfFile)
          Will return the signed content of the document.
 byte[] getSignedContent(InputStream pdfFile)
          Will return the signed content of the document.
 String getSubFilter()
           
 void setByteRange(int[] range)
           
 void setContents(byte[] bytes)
           
 void setFilter(COSName filter)
           
 void setLocation(String location)
           
 void setName(String name)
           
 void setReason(String reason)
           
 void setSignDate(Calendar cal)
           
 void setSubFilter(COSName subfilter)
          Set a subfilter that specify the signature that should be used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILTER_ADOBE_PPKLITE

public static final COSName FILTER_ADOBE_PPKLITE
A signature filter value.


FILTER_ENTRUST_PPKEF

public static final COSName FILTER_ENTRUST_PPKEF
A signature filter value.


FILTER_CICI_SIGNIT

public static final COSName FILTER_CICI_SIGNIT
A signature filter value.


FILTER_VERISIGN_PPKVS

public static final COSName FILTER_VERISIGN_PPKVS
A signature filter value.


SUBFILTER_ADBE_X509_RSA_SHA1

public static final COSName SUBFILTER_ADBE_X509_RSA_SHA1
A signature subfilter value.


SUBFILTER_ADBE_PKCS7_DETACHED

public static final COSName SUBFILTER_ADBE_PKCS7_DETACHED
A signature subfilter value.


SUBFILTER_ETSI_CADES_DETACHED

public static final COSName SUBFILTER_ETSI_CADES_DETACHED
A signature subfilter value.


SUBFILTER_ADBE_PKCS7_SHA1

public static final COSName SUBFILTER_ADBE_PKCS7_SHA1
A signature subfilter value.

Constructor Detail

PDSignature

public PDSignature()
Default constructor.


PDSignature

public PDSignature(COSDictionary dict)
Constructor.

Parameters:
dict - The signature dictionary.
Method Detail

getCOSObject

public COSBase getCOSObject()
Convert this standard java object to a COS object.

Specified by:
getCOSObject in interface COSObjectable
Returns:
The cos object that matches this Java object.

getDictionary

public COSDictionary getDictionary()
Convert this standard java object to a COS dictionary.

Returns:
The COS dictionary that matches this Java object.

setFilter

public void setFilter(COSName filter)

setSubFilter

public void setSubFilter(COSName subfilter)
Set a subfilter that specify the signature that should be used.

Parameters:
subfilter - the subfilter that shall be used.

setName

public void setName(String name)

setLocation

public void setLocation(String location)

setReason

public void setReason(String reason)

setSignDate

public void setSignDate(Calendar cal)

getFilter

public String getFilter()

getSubFilter

public String getSubFilter()

getName

public String getName()

getLocation

public String getLocation()

getReason

public String getReason()

getSignDate

public Calendar getSignDate()

setByteRange

public void setByteRange(int[] range)

getByteRange

public int[] getByteRange()
Read out the byterange from the file

Returns:
a integer array with the byterange

getContents

public byte[] getContents(InputStream pdfFile)
                   throws IOException
Will return the embedded signature between the byterange gap.

Parameters:
pdfFile - The signed pdf file as InputStream
Returns:
a byte array containing the signature
Throws:
IOException - if the pdfFile can't be read

getContents

public byte[] getContents(byte[] pdfFile)
                   throws IOException
Will return the embedded signature between the byterange gap.

Parameters:
pdfFile - The signed pdf file as byte array
Returns:
a byte array containing the signature
Throws:
IOException - if the pdfFile can't be read

setContents

public void setContents(byte[] bytes)

getSignedContent

public byte[] getSignedContent(InputStream pdfFile)
                        throws IOException
Will return the signed content of the document.

Parameters:
pdfFile - The signed pdf file as InputStream
Returns:
a byte array containing only the signed part of the content
Throws:
IOException - if the pdfFile can't be read

getSignedContent

public byte[] getSignedContent(byte[] pdfFile)
                        throws IOException
Will return the signed content of the document.

Parameters:
pdfFile - The signed pdf file as byte array
Returns:
a byte array containing only the signed part of the content
Throws:
IOException - if the pdfFile can't be read


Copyright © 2002-2012 Apache Software Foundation. All Rights Reserved.