Package org.pgpainless.signature
Class SignatureUtils
- java.lang.Object
-
- org.pgpainless.signature.SignatureUtils
-
public class SignatureUtils extends java.lang.ObjectUtility 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.DatedatePlusSeconds(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.DategetKeyExpirationDate(java.util.Date keyCreationDate, org.bouncycastle.openpgp.PGPSignature signature)static java.util.DategetSignatureExpirationDate(org.bouncycastle.openpgp.PGPSignature signature)static org.bouncycastle.openpgp.PGPSignatureGeneratorgetSignatureGeneratorFor(org.bouncycastle.openpgp.PGPPublicKey signingPubKey)Return a signature generator for the provided signing key.static org.bouncycastle.openpgp.PGPSignatureGeneratorgetSignatureGeneratorFor(org.bouncycastle.openpgp.PGPSecretKey singingKey)Return a signature generator for the provided signing key.static booleanisHardRevocation(org.bouncycastle.openpgp.PGPSignature signature)Return true if the provided signature is a hard revocation.static booleanisSignatureExpired(org.bouncycastle.openpgp.PGPSignature signature)static booleanisSignatureExpired(org.bouncycastle.openpgp.PGPSignature signature, java.util.Date comparisonDate)static org.bouncycastle.openpgp.PGPSignatureListreadSignatures(java.lang.String encodedSignatures)Parse an ASCII encoded list of OpenPGP signatures into aPGPSignatureList.
-
-
-
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- dateseconds- 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 ofRevocationAttributes.Reason.KEY_COMPROMISEDorRevocationAttributes.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.IOExceptionParse an ASCII encoded list of OpenPGP signatures into aPGPSignatureList.- Parameters:
encodedSignatures- ASCII armored signature list- Returns:
- signature list
- Throws:
java.io.IOException- if the signatures cannot be read
-
-