com.qoppa.pdf
Class SigningInformation

java.lang.Object
  extended by com.qoppa.pdf.SigningInformation

public class SigningInformation
extends Object

Object that holds information necessary to digitally sign a PDF file. This object is normally used by the host application to set the information that the library needs to sign a PDF file.

Author:
Qoppa Software

Field Summary
static int PERM_FORMFILL_SIGNATURE
          Certifying signature permission to allow form fill and signing.
static int PERM_FORMFILL_SIGNATURE_COMMENTS
          Certifying signature permission to allow form fill, signing, and comments.
static int PERM_NOCHANGES
          Certifying signature permission to indicate the document is intended to be final.
 
Constructor Summary
SigningInformation(KeyStore ks, String entryAlias, String aliasPWD)
          Constructs a SigningInformation object and gets the digital ID from a Java KeyStore object.
SigningInformation(PrivateKey pk, Certificate signerCert, Certificate[] certChain, String provider)
          Constructs a SigningInformation object given a private key, signer certificate and certificate chain.
SigningInformation(String pkcs12File, String ksPWD, String entryAlias, String aliasPWD)
          Constructs a SigningInformation object and gets the digital ID from a named PKCS#12 file.
 
Method Summary
 Certificate[] getCertificateChain()
          Returns the certificate chain for the issuers of the certificate in the key store.
 String getContactInformation()
          Returns the contact information used in the signature.
 Map getCustomProperties()
          Returns the custom properties table.
 String getCustomProperty(String key)
          This method can be used to retrieve the values of custom properties
 String getJCEProvider()
          Returns the name of the JCE provider to use when accessing the Private Key.
 String getLocation()
          Gets the location to be used in the signature.
 int getPermissions()
          Returns the level of permissions for a certifying signature.
 PrivateKey getPrivateKey()
          Returns the private key retrieved from the KeyStore or PKCS #12 file.
 String getReason()
          Gets the reason for signing to be used in the signature.
 SignatureAppearance getSignatureAppearance()
          Returns the SignatureAppearance to use when creating the signature appearance stream.
 Certificate getSignerCertificate()
          Returns the certificate for the digital id retrieved from the KeyStore or the PKCS#12 file.
 TimestampServer getTimestampServer()
          Returns the Timestamp Server information
 boolean isCertifyingSignature()
          Returns true if this is a certifying signature.
 void setCertifyingSignature(boolean certifyingSignature)
          To create a certifying signature, set this property to true.
 void setContactInformation(String contactInformation)
          Sets the contact information to be used in the signature.
 void setCustomProperty(String key, String value)
          This method can be used to add additional custom properties to the signature dictionary.
 void setLocation(String location)
          Sets the location to be used in the signature.
 void setPermissions(int permissions)
          This property is meaningful only if this is a certifying signature.
 void setReason(String reason)
          Sets the reason for signing to be used in the signature.
 void setSignatureAppearance(SignatureAppearance signAppearance)
          Sets the SignatureAppearance to use when creating the signature appearance stream.
 void setTimestampServer(TimestampServer server)
          Set the Timestamp server information
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PERM_NOCHANGES

public static int PERM_NOCHANGES
Certifying signature permission to indicate the document is intended to be final.


PERM_FORMFILL_SIGNATURE

public static int PERM_FORMFILL_SIGNATURE
Certifying signature permission to allow form fill and signing.


PERM_FORMFILL_SIGNATURE_COMMENTS

public static int PERM_FORMFILL_SIGNATURE_COMMENTS
Certifying signature permission to allow form fill, signing, and comments.

Constructor Detail

SigningInformation

public SigningInformation(String pkcs12File,
                          String ksPWD,
                          String entryAlias,
                          String aliasPWD)
                   throws GeneralSecurityException,
                          IOException,
                          PDFException
Constructs a SigningInformation object and gets the digital ID from a named PKCS#12 file. The method reads the file and gets the digital ID for use in signing.

Parameters:
pkcs12File - The name of the PKCS#12 key store file
ksPWD - The key store password
entryAlias - The alias of the entry to be used in signing.
aliasPWD - The password to the alias entry.
Throws:
GeneralSecurityException
IOException
PDFException

SigningInformation

public SigningInformation(KeyStore ks,
                          String entryAlias,
                          String aliasPWD)
                   throws GeneralSecurityException,
                          PDFException
Constructs a SigningInformation object and gets the digital ID from a Java KeyStore object.

Parameters:
ks - The KeyStore object that contains the digital ID.
entryAlias - The alias of the entry to be used in signing.
aliasPWD - The password to the alias entry.
Throws:
GeneralSecurityException
PDFException

SigningInformation

public SigningInformation(PrivateKey pk,
                          Certificate signerCert,
                          Certificate[] certChain,
                          String provider)
                   throws PDFException
Constructs a SigningInformation object given a private key, signer certificate and certificate chain.

Parameters:
pk - The private key to use in signing.
signerCert - The singer's certificate.
certChain - The signer's certificate chain
provider - The JCE provider to use when accessing teh private key. If left null, we will use the default Java JCE provider.
Throws:
GeneralSecurityException
PDFException
Method Detail

getContactInformation

public String getContactInformation()
Returns the contact information used in the signature.

Returns:
The contact name

setContactInformation

public void setContactInformation(String contactInformation)
Sets the contact information to be used in the signature.

Parameters:
contactInformation - The new contact information.

getLocation

public String getLocation()
Gets the location to be used in the signature.

Returns:
The location

setLocation

public void setLocation(String location)
Sets the location to be used in the signature.

Parameters:
location - The new location.

getReason

public String getReason()
Gets the reason for signing to be used in the signature.

Returns:
The reason for signing.

setReason

public void setReason(String reason)
Sets the reason for signing to be used in the signature.

Parameters:
reason - The new reason.

getPrivateKey

public PrivateKey getPrivateKey()
Returns the private key retrieved from the KeyStore or PKCS #12 file. This key is used to create the digital signature hash when a document is signed.

Returns:
The private key.

getJCEProvider

public String getJCEProvider()
Returns the name of the JCE provider to use when accessing the Private Key. This value can be null, signifying that the default Java JCE provider will be used.

Returns:
The name of the JCE provider.

getSignerCertificate

public Certificate getSignerCertificate()
Returns the certificate for the digital id retrieved from the KeyStore or the PKCS#12 file.

Returns:
The certificate for the digital id.

getCertificateChain

public Certificate[] getCertificateChain()
Returns the certificate chain for the issuers of the certificate in the key store.

Returns:
The certificate chain.

setSignatureAppearance

public void setSignatureAppearance(SignatureAppearance signAppearance)
Sets the SignatureAppearance to use when creating the signature appearance stream.

Parameters:
signAppearance - the signAppearance to use when creating the signature appearance stream

getSignatureAppearance

public SignatureAppearance getSignatureAppearance()
Returns the SignatureAppearance to use when creating the signature appearance stream.

Returns:
the signAppearance

getCustomProperty

public String getCustomProperty(String key)
This method can be used to retrieve the values of custom properties

Parameters:
key - The key for the custom property

setCustomProperty

public void setCustomProperty(String key,
                              String value)
                       throws PDFException
This method can be used to add additional custom properties to the signature dictionary.

Parameters:
key - A unique key for the custom property
value - The vale of the custom property
Throws:
PDFException

getCustomProperties

public Map getCustomProperties()
Returns the custom properties table. Returns null if no custom properties have been set.


getTimestampServer

public TimestampServer getTimestampServer()
Returns the Timestamp Server information


setTimestampServer

public void setTimestampServer(TimestampServer server)
Set the Timestamp server information

Parameters:
server -

setCertifyingSignature

public void setCertifyingSignature(boolean certifyingSignature)
To create a certifying signature, set this property to true. It is false by default.


isCertifyingSignature

public boolean isCertifyingSignature()
Returns true if this is a certifying signature.


setPermissions

public void setPermissions(int permissions)
                    throws PDFException
This property is meaningful only if this is a certifying signature. Valid values are 1-3 and the default is 2. There are predefined ints in this class to use for the permission levels, PERM_NOCHANGES, PERM_FORMFILL_SIGNATURE, PERM_FORMFILL_SIGNATURE_COMMENTS.
A value of 1 (PERM_NOCHANGES) indicates that the document is intended to be final;
A value of 2 (PERM_FORMFILL_SIGNATURE) allows form filling and signatures;
A value of 3 (PERM_FORMFILL_SIGNATURE_COMMENTS) permits form filling, signatures, and comments.

Parameters:
permissions -
Throws:
PDFException

getPermissions

public int getPermissions()
Returns the level of permissions for a certifying signature.
A value of 1 (PERM_NOCHANGES) indicates that the document is intended to be final;
A value of 2 (PERM_FORMFILL_SIGNATURE) allows form filling and signatures;
A value of 3 (PERM_FORMFILL_SIGNATURE_COMMENTS) permits form filling, signatures, and comments.