lv.pasts.eme.edoc

## Interface EDOCPreparedSignature

- All Superinterfaces:
    EDOCSignature

      public interface EDOCPreparedSignature
      extends EDOCSignature

  An `EDOCPreparedSignature` allows to create signature outside the `EDOC` document, e.g. in a different process on the same machine or on a client machine in a client-server environment.

  Use the `getDocumentDigest()` method to obtain the digest value for signature calculation.

  Use the `setSignatureValue(byte[])` method to provide the calculated signature value.

  Use the `setTimeStamp(TimeStamp)` method to set a time stamp.

  In order to add another signature or save the `EDOC` document, the current `EDOCPreparedSignature` must be completed using the `complete()` method.

  Since:
    2.1.0
  See Also:
    `EDOC.prepareSignature(SignatureType, java.security.cert.X509Certificate)`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `complete()` Completes the current signature.
    `byte[]` | `getDocumentDigest()` Returns the `EDOC` document digest value for signature calculation.
    `boolean` | `isCompleted()` Returns true if this `EDOCPreparedSignature` instance is completed.
    `void` | `setSignatureValue(byte[] signatureValue)` Sets the signature value bytes.
    `void` | `setTimeStamp(TimeStamp timeStamp)` Sets the time stamp for the current signature.

    - ### Methods inherited from interface lv.pasts.eme.edoc.EDOCSignature

      `getCertificate, getID, getSignatureTimeStamp, getSignatureType, getSignatureValue, getSignatureValueImprintDigest, getSignedDigest, getSigningTime, isDigitalSeal, validate`

- - ### Method Detail

    - #### getDocumentDigest

          byte[] getDocumentDigest()
                            throws EDOCException

      Returns the `EDOC` document digest value for signature calculation.

      NOTE: The digest value is calculated using the 'SHA1' digesting algorithm. Resulting digest value is prepended with a 'SHA1' algorithm identifier to form a `DigestInfo` object, as defined by PKCS#7 Digest-encryption process (RFC 2315). The returned value is DER encoded `DigestInfo` value to be signed with the corresponding private key. Therefore, the signature must be calculated using a raw RSA (`NONEwithRSA`) signature algorithm.

      Returns:
        the document digest value to be signed.
      Throws:
        `EDOCException` - if document digest value cannot be calculated.
      See Also:
        `setSignatureValue(byte[])`

    - #### setSignatureValue

          void setSignatureValue(byte[] signatureValue)
                          throws EDOCException

      Sets the signature value bytes.

      The signature value must be calculated for the `EDOC` document digest value using the raw RSA (`NONEwithRSA`) signature algorithm.

      Parameters:
        `signatureValue` - the signature value bytes.
      Throws:
        `EDOCException` - if signature value cannot be set.
      See Also:
        `getDocumentDigest()`

    - #### setTimeStamp

          void setTimeStamp(TimeStamp timeStamp)
                     throws EDOCException

      Sets the time stamp for the current signature.

      The input for the time stamp hash computation is the `ds:SignatureValue` XML element, as defined in ETSI TS 101 903 v1.3.2. The signature value message imprint value can be obtained using the `EDOCSignature.getSignatureValueImprintDigest()` method.

      Parameters:
        `timeStamp` - the time stamp.
      Throws:
        `EDOCException` - if time stamp cannot be set.
      See Also:
        `TimeStampGenerator.requestTimeStamp(byte[], java.security.KeyStore.Builder, String, String)`

    - #### complete

          void complete()
                 throws EDOCException

      Completes the current signature.

      If required by the current signature level, the revocation data is also added during the completion process.

      Throws:
        `EDOCException` - if signature cannot be completed.

    - #### isCompleted

          boolean isCompleted()

      Returns true if this `EDOCPreparedSignature` instance is completed.
      Returns:
        true if this instance is completed.

Copyright VAS Latvijas Valsts radio un televizijas centrs / Developed by SIA EUSO