Package org.faceless.pdf2
Interface EGIZSignatureHandler.Factory
-
- All Superinterfaces:
SignatureHandlerFactory
- Enclosing class:
- EGIZSignatureHandler
public static interface EGIZSignatureHandler.Factory extends SignatureHandlerFactory
An implementation of this Factory is required to create and control the EGIZSignatureHandler
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
doSign(EGIZSignatureHandler handler, MessageDigest digest)
Do the actual signing.boolean
doVerify(EGIZSignatureHandler handler, MessageDigest digest)
Do the actual verification.int[]
getCertificateSizes()
Get the value passed in tosetCertificateSizes(int[])
int
getCertificationType(EGIZSignatureHandler handler)
Set the return value from theSignatureHandler.getCertificationType()
method on the supplied handlerMessageDigest
getMessageDigest()
Return theMessageDigest
object to be used by this HandlerString
getMethod()
Get the "method" field of the signature, eg "urn:pdfsigfilter:bka.gv.at:binaer:v1.1.0";PDFPage
getPage()
Return the PDFPage set set bysetPage(org.faceless.pdf2.PDFPage, int, int, int, int)
Rectangle
getRectangle()
Return the Rectangle, as set set bysetPage(org.faceless.pdf2.PDFPage, int, int, int, int)
void
populateCanvas(PDFCanvas canvas, int width, int height, EGIZSignatureHandler handler)
Populate the supplied canvas with the signature appearance.void
preSign(EGIZSignatureHandler handler, KeyStore keystore, String alias, char[] password)
Set any fields in the Signature that need to be set prior to the start of the signing process.void
preVerify(EGIZSignatureHandler handler)
Called right at the start of the verification process before the digest is created and thedoVerify(org.faceless.pdf2.EGIZSignatureHandler, java.security.MessageDigest)
method is calledvoid
setCertificateSizes(int[] sizes)
Set the size in bytes of each X.509 certificate that will be stored.void
setLogo(PDFImage logo)
Set the logo to be displayed on the stampvoid
setPage(PDFPage page, int x1, int y1, int x2, int y2)
Set the page and size of the stamp that will be added by the signature-
Methods inherited from interface org.faceless.pdf2.SignatureHandlerFactory
getHandler
-
-
-
-
Method Detail
-
setLogo
void setLogo(PDFImage logo)
Set the logo to be displayed on the stamp
-
setCertificateSizes
void setCertificateSizes(int[] sizes)
Set the size in bytes of each X.509 certificate that will be stored. For example, to store 1 x 1500byte cert, pass in "new int[] { 1500 }"
-
getCertificateSizes
int[] getCertificateSizes()
Get the value passed in tosetCertificateSizes(int[])
-
getMethod
String getMethod()
Get the "method" field of the signature, eg "urn:pdfsigfilter:bka.gv.at:binaer:v1.1.0";
-
populateCanvas
void populateCanvas(PDFCanvas canvas, int width, int height, EGIZSignatureHandler handler)
Populate the supplied canvas with the signature appearance. This method should return a newPDFCanvas
of the specified size, containing text or images representing the signature. Tokens must be inserted into the canvas to indicate the location of the signature date, value, issuer, method and so on. These tokens can be created using thecreateToken()
method of thehandler
property.- Parameters:
canvas
- the Canvaswidth
- the width of the canvas in pointsheight
- the height of the canvas in pointshandler
- the SignatureHandler this canvas is being created for
-
setPage
void setPage(PDFPage page, int x1, int y1, int x2, int y2)
Set the page and size of the stamp that will be added by the signature- Parameters:
page
- the PDFPage to stampx1
- the first X coordinatey1
- the first Y coordinatex2
- the second X coordinatey2
- the second Y coordinate
-
getPage
PDFPage getPage()
Return the PDFPage set set bysetPage(org.faceless.pdf2.PDFPage, int, int, int, int)
-
getRectangle
Rectangle getRectangle()
Return the Rectangle, as set set bysetPage(org.faceless.pdf2.PDFPage, int, int, int, int)
-
getMessageDigest
MessageDigest getMessageDigest() throws NoSuchAlgorithmException
Return theMessageDigest
object to be used by this Handler- Throws:
NoSuchAlgorithmException
-
preSign
void preSign(EGIZSignatureHandler handler, KeyStore keystore, String alias, char[] password) throws GeneralSecurityException
Set any fields in the Signature that need to be set prior to the start of the signing process. This is called beforepopulateCanvas()
- Parameters:
handler
- the EGIZSignatureHandlerkeystore
- the KeyStorealias
- the aliaspassword
- the password- Throws:
GeneralSecurityException
-
preVerify
void preVerify(EGIZSignatureHandler handler) throws GeneralSecurityException
Called right at the start of the verification process before the digest is created and thedoVerify(org.faceless.pdf2.EGIZSignatureHandler, java.security.MessageDigest)
method is called- Throws:
GeneralSecurityException
- Since:
- 2.11.19
-
doSign
void doSign(EGIZSignatureHandler handler, MessageDigest digest) throws IOException, GeneralSecurityException, CertificateException
Do the actual signing. When this method is called, the "digest" has been updated with the bytes from the PDF. This method should do the following:1. Create the signature somehow, then 2. Call "handler.setSignatureValue(data)" where "data" is a byte array containing the "Signaturwert" fields. This value will be base64 encoded by the handler. 3. Call "handler.setSignerInfo(info)" where info is a String containing the value of the "Unterzeichner" field. The value may contain a "\n" to control where the line is split. 4. Call "handler.setIssuerInfo(info)" where info is a String containing the value of the "Aussteller-Zertifikat" field. The value may contain a "\n" to control where the line is split. 5. Call "handler.setCertificates(certs)" where "certs" is an array of javax.security.certs.X509Certificate. 6. Call "handler.setSignDate(date)" where "date" is a java.util.Calendar 7. Call "handler.setSerialNumber(num)" where "num" is a java.math.BigInteger 8. Call "handler.setParameter(val)" where "val" is a String.
ThesetNNN
method calls can be made in any order.
-
doVerify
boolean doVerify(EGIZSignatureHandler handler, MessageDigest digest) throws GeneralSecurityException, IOException
Do the actual verification. This method will be called with the MessageDigest returned fromSignatureHandler.getMessageDigest()
, which has been udpated with the digestable parts of the PDF. It should return true if the signature is consided valid by this handler.- Throws:
GeneralSecurityException
IOException
-
getCertificationType
int getCertificationType(EGIZSignatureHandler handler)
Set the return value from theSignatureHandler.getCertificationType()
method on the supplied handler- Since:
- 2.13
-
-