Class PDSignature
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature
-
- All Implemented Interfaces:
COSObjectable
public class PDSignature extends java.lang.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
Fields Modifier and Type Field Description static COSNameFILTER_ADOBE_PPKLITEA signature filter value.static COSNameFILTER_CICI_SIGNITA signature filter value.static COSNameFILTER_ENTRUST_PPKEFA signature filter value.static COSNameFILTER_VERISIGN_PPKVSA signature filter value.static COSNameSUBFILTER_ADBE_PKCS7_DETACHEDA signature subfilter value.static COSNameSUBFILTER_ADBE_PKCS7_SHA1A signature subfilter value.static COSNameSUBFILTER_ADBE_X509_RSA_SHA1A signature subfilter value.static COSNameSUBFILTER_ETSI_CADES_DETACHEDA signature subfilter value.
-
Constructor Summary
Constructors Constructor Description PDSignature()Default constructor.PDSignature(COSDictionary dict)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int[]getByteRange()Read out the byterange from the file.java.lang.StringgetContactInfo()Returns the contact info.byte[]getContents(byte[] pdfFile)Will return the embedded signature between the byterange gap.byte[]getContents(java.io.InputStream pdfFile)Will return the embedded signature between the byterange gap.COSBasegetCOSObject()Convert this standard java object to a COS object.COSDictionarygetDictionary()Convert this standard java object to a COS dictionary.java.lang.StringgetFilter()Returns the filter.java.lang.StringgetLocation()Returns the location.java.lang.StringgetName()Returns the name.PDPropBuildgetPropBuild()PDF signature build dictionary.java.lang.StringgetReason()Returns the reason.java.util.CalendargetSignDate()Returns the sign date.byte[]getSignedContent(byte[] pdfFile)Will return the signed content of the document.byte[]getSignedContent(java.io.InputStream pdfFile)Will return the signed content of the document.java.lang.StringgetSubFilter()Returns the subfilter.voidsetByteRange(int[] range)Sets the byte range.voidsetContactInfo(java.lang.String contactInfo)Sets the contact info.voidsetContents(byte[] bytes)Sets the contents.voidsetFilter(COSName filter)Set the filter.voidsetLocation(java.lang.String location)Sets the location.voidsetName(java.lang.String name)Sets the name.voidsetPropBuild(PDPropBuild propBuild)PDF signature build dictionary.voidsetReason(java.lang.String reason)Sets the reason.voidsetSignDate(java.util.Calendar cal)Set the sign date.voidsetSubFilter(COSName subfilter)Set a subfilter that specify the signature that should be used.voidsetType(COSName type)Set the dictionary type.
-
-
-
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:
getCOSObjectin interfaceCOSObjectable- 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.
-
setType
public void setType(COSName type)
Set the dictionary type.- Parameters:
type- is the dictionary type.
-
setFilter
public void setFilter(COSName filter)
Set the filter.- Parameters:
filter- the filter to be used
-
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(java.lang.String name)
Sets the name.- Parameters:
name- the name to be used
-
setLocation
public void setLocation(java.lang.String location)
Sets the location.- Parameters:
location- the location to be used
-
setReason
public void setReason(java.lang.String reason)
Sets the reason.- Parameters:
reason- the reason to be used
-
setContactInfo
public void setContactInfo(java.lang.String contactInfo)
Sets the contact info.- Parameters:
contactInfo- the contact info to be used
-
setSignDate
public void setSignDate(java.util.Calendar cal)
Set the sign date.- Parameters:
cal- the date to be used as sign date
-
getFilter
public java.lang.String getFilter()
Returns the filter.- Returns:
- the filter
-
getSubFilter
public java.lang.String getSubFilter()
Returns the subfilter.- Returns:
- the subfilter
-
getName
public java.lang.String getName()
Returns the name.- Returns:
- the name
-
getLocation
public java.lang.String getLocation()
Returns the location.- Returns:
- the location
-
getReason
public java.lang.String getReason()
Returns the reason.- Returns:
- the reason
-
getContactInfo
public java.lang.String getContactInfo()
Returns the contact info.- Returns:
- teh contact info
-
getSignDate
public java.util.Calendar getSignDate()
Returns the sign date.- Returns:
- the sign date
-
setByteRange
public void setByteRange(int[] range)
Sets the byte range.- Parameters:
range- the byte range to be used
-
getByteRange
public int[] getByteRange()
Read out the byterange from the file.- Returns:
- a integer array with the byterange
-
getContents
public byte[] getContents(java.io.InputStream pdfFile) throws java.io.IOExceptionWill return the embedded signature between the byterange gap.- Parameters:
pdfFile- The signed pdf file as InputStream- Returns:
- a byte array containing the signature
- Throws:
java.io.IOException- if the pdfFile can't be read
-
getContents
public byte[] getContents(byte[] pdfFile) throws java.io.IOExceptionWill 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:
java.io.IOException- if the pdfFile can't be read
-
setContents
public void setContents(byte[] bytes)
Sets the contents.- Parameters:
bytes- contents to be used
-
getSignedContent
public byte[] getSignedContent(java.io.InputStream pdfFile) throws java.io.IOExceptionWill 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:
java.io.IOException- if the pdfFile can't be read
-
getSignedContent
public byte[] getSignedContent(byte[] pdfFile) throws java.io.IOExceptionWill 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:
java.io.IOException- if the pdfFile can't be read
-
getPropBuild
public PDPropBuild getPropBuild()
PDF signature build dictionary. Provides informations about the signature handler.- Returns:
- the pdf signature build dictionary.
-
setPropBuild
public void setPropBuild(PDPropBuild propBuild)
PDF signature build dictionary. Provides informations about the signature handler.- Parameters:
propBuild- the prop build
-
-