Class SignatureSubpacketGeneratorUtil
- java.lang.Object
-
- org.pgpainless.signature.subpackets.SignatureSubpacketGeneratorUtil
-
public class SignatureSubpacketGeneratorUtil extends java.lang.ObjectUtility class that helps dealing with BCs SignatureSubpacketGenerator class.
-
-
Constructor Summary
Constructors Constructor Description SignatureSubpacketGeneratorUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <P extends org.bouncycastle.bcpg.SignatureSubpacket>
java.util.List<P>getSubpacketsOfType(SignatureSubpacket type, org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator generator)Return a list ofSignatureSubpacketsfrom the subpacket generator, which correspond to the givenSignatureSubpackettype.static booleanhasKeyFlag(KeyFlag keyFlag, org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator generator)Return true, if the subpacket generator has aKeyFlagssubpacket which carries the given key flag.static voidremoveAllPacketsOfType(int type, org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator subpacketGenerator)Remove all packets of the given type from thePGPSignatureSubpacketGeneratorsinternal set.static voidremoveAllPacketsOfType(SignatureSubpacket subpacketType, org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator subpacketGenerator)Remove all packets of the given type from thePGPSignatureSubpacketGeneratorsinternal set.static voidsetExpirationDateInSubpacketGenerator(java.util.Date expirationDate, java.util.Date creationDate, org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator subpacketGenerator)Replace all occurrences of key expiration time subpackets in the subpacket generator with a single instance representing the new expiration time.static voidsetSignatureCreationTimeInSubpacketGenerator(java.util.Date date, org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator subpacketGenerator)Replace all occurrences of a signature creation time subpackets in the subpacket generator with a single new instance representing the provided date.
-
-
-
Method Detail
-
getSubpacketsOfType
public static <P extends org.bouncycastle.bcpg.SignatureSubpacket> java.util.List<P> getSubpacketsOfType(SignatureSubpacket type, org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator generator)
Return a list ofSignatureSubpacketsfrom the subpacket generator, which correspond to the givenSignatureSubpackettype.- Type Parameters:
P- generic subpacket type- Parameters:
type- subpacket typegenerator- subpacket generator- Returns:
- possibly empty list of subpackets
-
removeAllPacketsOfType
public static void removeAllPacketsOfType(SignatureSubpacket subpacketType, org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator subpacketGenerator)
Remove all packets of the given type from thePGPSignatureSubpacketGeneratorsinternal set.- Parameters:
subpacketType- type of subpacket to removesubpacketGenerator- subpacket generator
-
removeAllPacketsOfType
public static void removeAllPacketsOfType(int type, org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator subpacketGenerator)Remove all packets of the given type from thePGPSignatureSubpacketGeneratorsinternal set.- Parameters:
type- type of subpacket to removesubpacketGenerator- subpacket generator
-
setSignatureCreationTimeInSubpacketGenerator
public static void setSignatureCreationTimeInSubpacketGenerator(java.util.Date date, org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator subpacketGenerator)Replace all occurrences of a signature creation time subpackets in the subpacket generator with a single new instance representing the provided date.- Parameters:
date- signature creation timesubpacketGenerator- subpacket generator
-
setExpirationDateInSubpacketGenerator
public static void setExpirationDateInSubpacketGenerator(java.util.Date expirationDate, @Nonnull java.util.Date creationDate, org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator subpacketGenerator)Replace all occurrences of key expiration time subpackets in the subpacket generator with a single instance representing the new expiration time.- Parameters:
expirationDate- expiration time as date or null for no expirationcreationDate- date on which the key was createdsubpacketGenerator- subpacket generator
-
hasKeyFlag
public static boolean hasKeyFlag(KeyFlag keyFlag, org.bouncycastle.openpgp.PGPSignatureSubpacketGenerator generator)
Return true, if the subpacket generator has aKeyFlagssubpacket which carries the given key flag. Returns false, if noKeyFlagssubpacket is present. If there are more than one instance of aKeyFlagspacket present, only the last occurrence will be tested.- Parameters:
keyFlag- flag to test forgenerator- subpackets generator- Returns:
- true if the generator has the given key flag set
-
-