|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.pdf2.AcrobatSignatureHandlerFactory
public class AcrobatSignatureHandlerFactory
An implementation of SignatureHandlerFactory
that returns handlers
suitable for signing documents for use with Acrobat 6.0 or later.
For basic
use it's quite acceptable to use the FormSignature.HANDLER_ACROBATSIX
which is an instance of this factory. If advanced options need to be set
(such as setting a TimeStamp server or changing the hash algorithm) then you
can create an instance of this factory and set the options on that before
passing it in to the FormSignature
constructor.
Constructor Summary | |
---|---|
AcrobatSignatureHandlerFactory()
Create a new SignatureHandlerFactory |
Method Summary | |
---|---|
SignatureHandler |
getHandler()
Return a handler created by this factory |
void |
setContentSize(int size)
This method can be called to fix the space allocated for the "Contents" variable, which contains the encoded signature. |
void |
setCustomAppearance(PDFCanvas canvas,
float x1,
float y1,
float x2,
float y2)
Set a custom appearance for this signature. |
void |
setDigestAlgorithm(String algorithm)
Set the message digest algorithm to use - one of MD5, SHA1, SHA256, SHA384, SHA512 or RIPEMD160 The default is SHA1. |
void |
setTimeStampServer(URL server)
Specify the URL of an RFC3161 Timestamp Server. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AcrobatSignatureHandlerFactory()
Method Detail |
---|
public void setDigestAlgorithm(String algorithm)
algorithm
- the message-digest algorithm to use.public void setTimeStampServer(URL server)
server
- The server to contact for the TimeStamp. May be null
to turn off timestamping (the default). If a username/password are required
they may be specified in the URL, eg "http://user:password@server.com".FormSignature.getSignDate()
,
PKCS7SignatureHandler.getTimeStampCertificates()
public void setCustomAppearance(PDFCanvas canvas, float x1, float y1, float x2, float y2)
Set a custom appearance for this signature. This method allows you to add a signature, thumbprint, logo or any other form of custom image to your signature annotations (technically, this method sets the "n2" layer of the annotation). The canvas may be of any size, and will be scaled to fit the annotation on the page.
Care needs to be taken when setting this value. It's not recommended to use a canvas containing a bitmap image with an opaque background, as this may mask any layers behind this one. In particular, a "?" is typically used on a layer below this one to indicate the signature has not been verified. Specifying an opaque image may result in this being obscured.
As a optional convenience, by specifying non-zero coordinates for the x1,y1,x2 and y2 values, some text describing the signing certificate will be added to the canvas at the specified location. The format for this is fixed, but as it doesn't have to be included, the developer is free to add his or her own text if they don't like the result, simply by setting all four values to zero.
As an example, the default PKCS7 appearance is set with the following code which loads a pre-defined pattern from a resources file:
setCustomAppearance(new PDFCanvas("logo.Adobe", 1), 0, 35, 100, 65);
canvas
- the canvas to display as the "n2" layer of the signature appearance.x1
- the left-most X co-ordinate to place the (optional) certificate texty1
- the bottom-most Y co-ordinate to place the (optional) certificate textx2
- the right-most X co-ordinate to place the (optional) certificate texty2
- the top-most Y co-ordinate to place the (optional) certificate textpublic void setContentSize(int size)
This method can be called to fix the space allocated for the "Contents" variable,
which contains the encoded signature. If a value > 0 is supplied then the Contents
variable will have that much space allocated for it. If a value of <= 0 is supplied
then the SignatureHandler.getEstimatedContentSize(int)
method will be called with the negative
of this value (so if you call setContentSize(-100)
, this will result in
a call of getEstimatedContentSize(100)
.
The intention of this is to allocate space in the Contents variable for external objects,
such as TimeStamps from a remote server. For instance, if you were using a
PKCS7SignatureHandler
to digitally sign and an RFC3161 TimeStamp server was
specified
, you could pass in
a value of "-1000" to this method to reserve 1000 bytes in the PKCS#7 object for the
TimeStamp token.
size
- the size of the Contents string in bytes, or <= 0 to determine automatically.public SignatureHandler getHandler()
SignatureHandlerFactory
getHandler
in interface SignatureHandlerFactory
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |