com.crionics.jpdf.signer
Class CustomSigner

java.lang.Object
  extended by com.crionics.jpdf.signer.CustomSigner

public abstract class CustomSigner
extends java.lang.Object

Provides the set of methods for use when the PDF signature needs to be generated from the external device such as a smartcard, a hardware signer or a custom signature implementation.

The pseudo code below shows how jPDF calls the different methods

PREPARATION PHASE:

getFilter()
getSubFilter()
getSignatureSize()
getCertificateChain()
reset(); for each bytes of the file to sign update(byte)

GENERATION PHASE

reset();
for each bytes of the file part of the signature calculation
update(byte)
getSignature()


Constructor Summary
CustomSigner()
           
 
Method Summary
 byte[] createPKCS7(java.lang.String hashAlgo, byte[] signedDigest, java.security.cert.X509Certificate[] certificateChain)
          Helper method which create a standard PKCS7 object from the attributes.
abstract  java.security.cert.X509Certificate[] getCertificateChain()
          Returns the list of certificate chain.
 java.util.Calendar getCurrentDate()
          This method is used to fill the signature modification date.
 java.lang.String getFilter()
          return the name of the signature handler, this information can be changed if you need to implement your own signature handler.
abstract  byte[] getSignature()
          Returns the signature value, result of the calculation.
abstract  int getSignatureSize()
          This method is called during the signature preparation phase.
 java.lang.String getSubFilter()
          return the name of the signature type as specified in the PDF Spec By default this method returns "adbe.pkcs7.detached"
abstract  void reset()
          Resets the underlying signer - by resetting the signature to their initial values.
abstract  void update(byte data)
          Updates the signature calculation with the given data.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomSigner

public CustomSigner()
Method Detail

createPKCS7

public byte[] createPKCS7(java.lang.String hashAlgo,
                          byte[] signedDigest,
                          java.security.cert.X509Certificate[] certificateChain)
                   throws java.security.NoSuchAlgorithmException
Helper method which create a standard PKCS7 object from the attributes.

Parameters:
hashAlgo -
signedDigest -
certificateChain -
Returns:
a pkcs7 encoded object
Throws:
java.security.NoSuchAlgorithmException

getCertificateChain

public abstract java.security.cert.X509Certificate[] getCertificateChain()
Returns the list of certificate chain. Entry 0 is the signing certificate.

Returns:
the list of certificate chain with at entry zero, the signing certificate

getCurrentDate

public java.util.Calendar getCurrentDate()
This method is used to fill the signature modification date. It can be overloaded to implement asynchronous custom signers where the generation of the digest is delayed from the generation of the PDF.

Returns:
the current date

getFilter

public java.lang.String getFilter()
return the name of the signature handler, this information can be changed if you need to implement your own signature handler. By default this method returns "Adobe.PPKMS"

Returns:
the name of the signature handler

getSignature

public abstract byte[] getSignature()
                             throws java.security.SignatureException
Returns the signature value, result of the calculation. By default this method should return a PKCS7 object. But if you changed the getFilter and getSubFilter methods, you can return any type of signature as long as it complies with your specifications.

Returns:
the signature
Throws:
java.security.SignatureException

getSignatureSize

public abstract int getSignatureSize()
                              throws java.security.SignatureException
This method is called during the signature preparation phase. It is use to allocate a dummy array which will hold the signature value. Note that if the array is too small you will get an excaption during the generation phase.

Returns:
the size of the array returned by getSignature()
Throws:
java.security.SignatureException

getSubFilter

public java.lang.String getSubFilter()
return the name of the signature type as specified in the PDF Spec By default this method returns "adbe.pkcs7.detached"

Returns:
the name of the signature type as specified in the PDF Spec

reset

public abstract void reset()
                    throws java.security.InvalidKeyException,
                           java.security.NoSuchAlgorithmException
Resets the underlying signer - by resetting the signature to their initial values. This is typically the place where the private key is set.

Throws:
java.security.InvalidKeyException
java.security.NoSuchAlgorithmException

update

public abstract void update(byte data)
                     throws java.security.SignatureException
Updates the signature calculation with the given data. Developpers don't have to worry about skipping the signature range - it is automatically skipped. if the signature is digested, the process is transparent as well - instead of receiving byte from the files - you would get bytes from the result of the digest calculation.

Parameters:
data -
Throws:
java.security.SignatureException


Copyright © 1999-2007 Crionics. All Rights Reserved.