Class OpenPGPSignature.OpenPGPDocumentSignature

java.lang.Object
org.bouncycastle.openpgp.api.OpenPGPSignature
org.bouncycastle.openpgp.api.OpenPGPSignature.OpenPGPDocumentSignature
Enclosing class:
OpenPGPSignature

public static class OpenPGPSignature.OpenPGPDocumentSignature extends OpenPGPSignature
An OpenPGPSignature made over a binary or textual document (e.g. a message). Also known as a Data Signature. An OpenPGPSignature.OpenPGPDocumentSignature CANNOT live on a OpenPGPCertificate.
  • Field Details

  • Constructor Details

    • OpenPGPDocumentSignature

      public OpenPGPDocumentSignature(PGPSignature signature, OpenPGPCertificate.OpenPGPComponentKey issuer)
      Create a document signature of level 0 (signature is made directly over the document).
      Parameters:
      signature - signature
      issuer - public issuer-signing-key-component (or null if not available)
    • OpenPGPDocumentSignature

      public OpenPGPDocumentSignature(PGPSignature signature, OpenPGPCertificate.OpenPGPComponentKey issuer, OpenPGPSignature.OpenPGPDocumentSignature attestedSignature)
      Create a document signature of level greater than 0 (signature is made as an attestation over other signature(s) + document). If the attested signature is itself an attestation, it will recursively contain its attested signature.
      Parameters:
      signature - attestation signature
      issuer - public issuer signing-key-component (or null if not available)
      attestedSignature - the attested signature
  • Method Details

    • getTargetDisplay

      protected String getTargetDisplay()
      Specified by:
      getTargetDisplay in class OpenPGPSignature
    • getSignatureLevel

      public int getSignatureLevel()
      Return the signature attestation level of this signature. If this signature was created directly over a document, this method returns 0. A level greater than 0 indicates that the signature is an attestation over at least one other signature.
      Returns:
      signature attestation level
    • getAttestedSignature

      public OpenPGPSignature.OpenPGPDocumentSignature getAttestedSignature()
      Return the attested signature (or null if this is not an attestation signature).
      Returns:
      attested signature or null
    • verify

      public boolean verify(PGPOnePassSignature ops) throws PGPException
      Verify the correctness of an inline signature by evaluating the corresponding PGPOnePassSignature.
      Parameters:
      ops - one-pass-signature packet
      Returns:
      true if the signature is correct, false otherwise
      Throws:
      PGPException - if the signature cannot be verified
    • verify

      public boolean verify() throws PGPException
      Verify the correctness of a prefixed-signature.
      Returns:
      true if the signature is correct, false otherwise
      Throws:
      PGPException - if the signature cannot be verified
    • isValid

      public boolean isValid() throws PGPSignatureException
      Return true, if the signature is valid at this moment. A valid signature is effective, correct and was issued by a valid signing key.
      Returns:
      true if the signature is valid now.
      Throws:
      PGPSignatureException
    • isValid

      public boolean isValid(OpenPGPPolicy policy) throws PGPSignatureException
      Return true, if the signature is valid at this moment using the given policy. A valid signature is effective, correct and was issued by a valid signing key.
      Parameters:
      policy - policy
      Returns:
      true if the signature is valid now.
      Throws:
      PGPSignatureException
    • isValidAt

      public boolean isValidAt(Date date) throws PGPSignatureException
      Return true, if th signature is valid at the given date. A valid signature is effective, correct and was issued by a valid signing key.
      Parameters:
      date - evaluation time
      Returns:
      true if the signature is valid at the given date
      Throws:
      IllegalStateException - if the signature has not yet been tested using a
      verify()
      method.
      PGPSignatureException
    • isValidAt

      public boolean isValidAt(Date date, OpenPGPPolicy policy) throws PGPSignatureException
      Return true, if th signature is valid at the given date using the given policy. A valid signature is effective, correct and was issued by a valid signing key.
      Parameters:
      date - evaluation time
      policy - policy
      Returns:
      true if the signature is valid at the given date
      Throws:
      IllegalStateException - if the signature has not yet been tested using a
      verify()
      method.
      PGPSignatureException
    • createdInBounds

      public boolean createdInBounds(Date notBefore, Date notAfter)
      Check, if the creation time of the signature is within the interval
      notBefore <= creationTime <= notAfter
      Parameters:
      notBefore - earliest accepted creation time
      notAfter - latest accepted creation time
      Returns:
      true if sig was created in bounds, false otherwise