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 and 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 to `setCertificateSizes(int[])`
    `int` | `getCertificationType(EGIZSignatureHandler handler)` Set the return value from the `SignatureHandler.getCertificationType()` method on the supplied handler
    `MessageDigest` | `getMessageDigest()` Return the `MessageDigest` object to be used by this Handler
    `String` | `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 by `setPage(org.faceless.pdf2.PDFPage, int, int, int, int)`
    `Rectangle` | `getRectangle()` Return the Rectangle, as set set by `setPage(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 the `doVerify(org.faceless.pdf2.EGIZSignatureHandler, java.security.MessageDigest)` method is called
    `void` | `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 stamp
    `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

    - ### 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 to `setCertificateSizes(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 new `PDFCanvas` 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 the `createToken()` method of the `handler` property.
      Parameters:
        `canvas` - the Canvas
        `width` - the width of the canvas in points
        `height` - the height of the canvas in points
        `handler` - 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 stamp
        `x1` - the first X coordinate
        `y1` - the first Y coordinate
        `x2` - the second X coordinate
        `y2` - the second Y coordinate

    - #### getPage

          PDFPage getPage()

      Return the PDFPage set set by `setPage(org.faceless.pdf2.PDFPage, int, int, int, int)`

    - #### getRectangle

          Rectangle getRectangle()

      Return the Rectangle, as set set by `setPage(org.faceless.pdf2.PDFPage, int, int, int, int)`

    - #### getMessageDigest

          MessageDigest getMessageDigest()
                                  throws NoSuchAlgorithmException

      Return the `MessageDigest` 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 before `populateCanvas()`
      Parameters:
        `handler` - the EGIZSignatureHandler
        `keystore` - the KeyStore
        `alias` - the alias
        `password` - 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 the `doVerify(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.

      The `setNNN` method calls can be made in any order.
      Throws:
        `IOException`
        `GeneralSecurityException`
        `CertificateException`

    - #### doVerify

          boolean doVerify(EGIZSignatureHandler handler,
                           MessageDigest digest)
                    throws GeneralSecurityException,
                           IOException

      Do the actual verification. This method will be called with the MessageDigest returned from `SignatureHandler.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 the `SignatureHandler.getCertificationType()` method on the supplied handler
      Since:
        2.13

Copyright © 2001-2015 Big Faceless Organization