org.faceless.pdf2.viewer2.feature
Class FormBlankSignatureWidgetFactory

java.lang.Object
  extended by org.faceless.pdf2.viewer2.ViewerFeature
      extended by org.faceless.pdf2.viewer2.AnnotationComponentFactory
          extended by org.faceless.pdf2.viewer2.feature.FormBlankSignatureWidgetFactory

public class FormBlankSignatureWidgetFactory
extends AnnotationComponentFactory

Create annotations to handle WidgetAnnotation objects belonging to unsigned FormSignature fields. As supplied, this class will prompt the user for a KeyStore and and then to select the alias and password required to sign the PDF, but it's possible to create an instance of this factory that has any one of these fields pre-set. Then just remove the default FormBlankSignatureWidgetFactory from the features passed in to the PDFViewer constructor and replace it with that new instance. The name of this feature is "FormBlankSignatureWidgetFactory".

This code is copyright the Big Faceless Organization. You're welcome to use, modify and distribute it in any form in your own projects, provided those projects continue to make use of the Big Faceless PDF library.

Since:
2.8

Constructor Summary
FormBlankSignatureWidgetFactory()
          Create a new FormBlankSignatureWidgetFactory
 
Method Summary
 JComponent createComponent(PagePanel pagepanel, PDFAnnotation annot)
          Return a JComponent that will visually represent the specified PDFAnnotation.
 void initialize(PDFViewer viewer)
          Called when the feature is first added to a viewer
 boolean matches(PDFAnnotation annot)
          Return true if this AnnotationComponentFactory could create a JComponent for the specified PDFAnnotation.
 void setAlias(String alias, char[] password)
          Set the alias to use from the KeyStore.
 void setCertificationType(int type)
          Set the certification type
 void setKeyStoreManager(KeyStoreManager manager)
          Set the KeyStoreManager
 void setLocation(String location)
          Set the location of the signing, which may be null.
 void setName(String name)
          Set the name of the individual applying the signature.
 void setReason(String reason)
          Set the reason for signing, which may be null.
 void setSignatureHandlerFactory(SignatureHandlerFactory factory)
          Set the SignatureHandlerFactory to be used to sign this PDF.
 void sign(FormSignature field, DocumentPanel panel)
          Sign the field.
 
Methods inherited from class org.faceless.pdf2.viewer2.AnnotationComponentFactory
bindComponentLocation, bindComponentLocation, bindComponentLocation, createEditComponent, createNewAnnotation, getAnnotationType, paintComponent, toString
 
Methods inherited from class org.faceless.pdf2.viewer2.ViewerFeature
getAllFeatures, getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FormBlankSignatureWidgetFactory

public FormBlankSignatureWidgetFactory()
Create a new FormBlankSignatureWidgetFactory

Method Detail

initialize

public void initialize(PDFViewer viewer)
Description copied from class: ViewerFeature
Called when the feature is first added to a viewer

Overrides:
initialize in class ViewerFeature

matches

public boolean matches(PDFAnnotation annot)
Description copied from class: AnnotationComponentFactory
Return true if this AnnotationComponentFactory could create a JComponent for the specified PDFAnnotation.

Specified by:
matches in class AnnotationComponentFactory

createComponent

public JComponent createComponent(PagePanel pagepanel,
                                  PDFAnnotation annot)
Description copied from class: AnnotationComponentFactory
Return a JComponent that will visually represent the specified PDFAnnotation.

Specified by:
createComponent in class AnnotationComponentFactory
Parameters:
pagepanel - the panel the JComponent will be added to
annot - the annotation

setReason

public void setReason(String reason)
Set the reason for signing, which may be null.

Parameters:
reason - the signing reason

setLocation

public void setLocation(String location)
Set the location of the signing, which may be null.

Parameters:
location - the signers location

setName

public void setName(String name)
Set the name of the individual applying the signature. If not set the name will be take from the X.509 certificate used to sign.

Parameters:
name - the signers name

setCertificationType

public void setCertificationType(int type)
Set the certification type

Parameters:
type - one of FormSignature.CERTIFICATION_UNCERTIFIED, FormSignature.CERTIFICATION_NOCHANGES, FormSignature.CERTIFICATION_ALLOWFORMS or FormSignature.CERTIFICATION_ALLOWCOMMENTS

setAlias

public void setAlias(String alias,
                     char[] password)
Set the alias to use from the KeyStore. If not specified (the default) the user will be optionally be prompted with a list of aliases available in the KeyStore.

Parameters:
alias - the alias
password - the password to use to extract the key

setKeyStoreManager

public void setKeyStoreManager(KeyStoreManager manager)
Set the KeyStoreManager

Parameters:
manager - the KeyStoreManager to use
Since:
2.8.3

setSignatureHandlerFactory

public void setSignatureHandlerFactory(SignatureHandlerFactory factory)
Set the SignatureHandlerFactory to be used to sign this PDF. This can be used to set custom features like key size, TimeStamp server and more. If not set a default AcrobatSignatureHandlerFactory is used.

Parameters:
factory - the factory

sign

public void sign(FormSignature field,
                 DocumentPanel panel)
          throws IOException,
                 GeneralSecurityException
Sign the field.

Parameters:
field - the Signature Field to sign
panel - the panel
Throws:
IOException
GeneralSecurityException


Copyright © 2001-2008 Big Faceless Organization