Class SignatureUtils


  • public class SignatureUtils
    extends java.lang.Object
    Utility methods related to signatures.
    • Constructor Summary

      Constructors 
      Constructor Description
      SignatureUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Date datePlusSeconds​(java.util.Date date, long seconds)
      Return a new date which represents the given date plus the given amount of seconds added.
      static java.util.Date getKeyExpirationDate​(java.util.Date keyCreationDate, org.bouncycastle.openpgp.PGPSignature signature)  
      static java.lang.String getSignatureDigestPrefix​(org.bouncycastle.openpgp.PGPSignature signature)  
      static java.util.Date getSignatureExpirationDate​(org.bouncycastle.openpgp.PGPSignature signature)  
      static org.bouncycastle.openpgp.PGPSignatureGenerator getSignatureGeneratorFor​(org.bouncycastle.openpgp.PGPPublicKey signingPubKey)
      Return a signature generator for the provided signing key.
      static org.bouncycastle.openpgp.PGPSignatureGenerator getSignatureGeneratorFor​(org.bouncycastle.openpgp.PGPSecretKey singingKey)
      Return a signature generator for the provided signing key.
      static boolean isHardRevocation​(org.bouncycastle.openpgp.PGPSignature signature)
      Return true if the provided signature is a hard revocation.
      static boolean isSignatureExpired​(org.bouncycastle.openpgp.PGPSignature signature)  
      static boolean isSignatureExpired​(org.bouncycastle.openpgp.PGPSignature signature, java.util.Date comparisonDate)  
      static org.bouncycastle.openpgp.PGPSignatureList readSignatures​(java.lang.String encodedSignatures)
      Parse an ASCII encoded list of OpenPGP signatures into a PGPSignatureList.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SignatureUtils

        public SignatureUtils()
    • Method Detail

      • getSignatureGeneratorFor

        public static org.bouncycastle.openpgp.PGPSignatureGenerator getSignatureGeneratorFor​(org.bouncycastle.openpgp.PGPSecretKey singingKey)
        Return a signature generator for the provided signing key. The signature generator will follow the hash algorithm preferences of the signing key and pick the best algorithm.
        Parameters:
        singingKey - signing key
        Returns:
        signature generator
      • getSignatureGeneratorFor

        public static org.bouncycastle.openpgp.PGPSignatureGenerator getSignatureGeneratorFor​(org.bouncycastle.openpgp.PGPPublicKey signingPubKey)
        Return a signature generator for the provided signing key. The signature generator will follow the hash algorithm preferences of the signing key and pick the best algorithm.
        Parameters:
        signingPubKey - signing key
        Returns:
        signature generator
      • getKeyExpirationDate

        public static java.util.Date getKeyExpirationDate​(java.util.Date keyCreationDate,
                                                          org.bouncycastle.openpgp.PGPSignature signature)
      • getSignatureExpirationDate

        public static java.util.Date getSignatureExpirationDate​(org.bouncycastle.openpgp.PGPSignature signature)
      • datePlusSeconds

        public static java.util.Date datePlusSeconds​(java.util.Date date,
                                                     long seconds)
        Return a new date which represents the given date plus the given amount of seconds added. Since '0' is a special value in the OpenPGP specification when it comes to dates (e.g. '0' means no expiration for expiration dates), this method will return 'null' if seconds is 0.
        Parameters:
        date - date
        seconds - number of seconds to be added
        Returns:
        date plus seconds or null if seconds is '0'
      • isSignatureExpired

        public static boolean isSignatureExpired​(org.bouncycastle.openpgp.PGPSignature signature)
      • isSignatureExpired

        public static boolean isSignatureExpired​(org.bouncycastle.openpgp.PGPSignature signature,
                                                 java.util.Date comparisonDate)
      • isHardRevocation

        public static boolean isHardRevocation​(org.bouncycastle.openpgp.PGPSignature signature)
        Return true if the provided signature is a hard revocation. Hard revocations are revocation signatures which either carry a revocation reason of RevocationAttributes.Reason.KEY_COMPROMISED or RevocationAttributes.Reason.NO_REASON, or no reason at all.
        Parameters:
        signature - signature
        Returns:
        true if signature is a hard revocation
      • readSignatures

        public static org.bouncycastle.openpgp.PGPSignatureList readSignatures​(java.lang.String encodedSignatures)
                                                                        throws java.io.IOException
        Parse an ASCII encoded list of OpenPGP signatures into a PGPSignatureList.
        Parameters:
        encodedSignatures - ASCII armored signature list
        Returns:
        signature list
        Throws:
        java.io.IOException - if the signatures cannot be read
      • getSignatureDigestPrefix

        public static java.lang.String getSignatureDigestPrefix​(org.bouncycastle.openpgp.PGPSignature signature)