Interface EGIZSignatureHandler.Factory

    • 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 }"
      • getMethod

        java.lang.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
      • getMessageDigest

        java.security.MessageDigest getMessageDigest()
                                              throws java.security.NoSuchAlgorithmException
        Return the MessageDigest object to be used by this Handler
        Throws:
        java.security.NoSuchAlgorithmException
      • preSign

        void preSign​(EGIZSignatureHandler handler,
                     java.security.KeyStore keystore,
                     java.lang.String alias,
                     char[] password)
              throws java.security.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:
        java.security.GeneralSecurityException
      • doSign

        void doSign​(EGIZSignatureHandler handler,
                    java.security.MessageDigest digest)
             throws java.io.IOException,
                    java.security.GeneralSecurityException,
                    java.security.cert.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:
        java.io.IOException
        java.security.GeneralSecurityException
        java.security.cert.CertificateException
      • doVerify

        boolean doVerify​(EGIZSignatureHandler handler,
                         java.security.MessageDigest digest)
                  throws java.security.GeneralSecurityException,
                         java.io.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:
        java.security.GeneralSecurityException
        java.io.IOException