Package org.pgpainless.signature.builder
Class AbstractSignatureBuilder<B extends AbstractSignatureBuilder<B>>
- java.lang.Object
-
- org.pgpainless.signature.builder.AbstractSignatureBuilder<B>
-
- Direct Known Subclasses:
DirectKeySignatureBuilder
,PrimaryKeyBindingSignatureBuilder
,RevocationSignatureBuilder
,SelfSignatureBuilder
,SubkeyBindingSignatureBuilder
,ThirdPartyCertificationSignatureBuilder
,UniversalSignatureBuilder
public abstract class AbstractSignatureBuilder<B extends AbstractSignatureBuilder<B>> extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected HashAlgorithm
hashAlgorithm
protected SignatureSubpackets
hashedSubpackets
protected org.bouncycastle.openpgp.PGPPrivateKey
privateSigningKey
protected org.bouncycastle.openpgp.PGPPublicKey
publicSigningKey
protected SignatureType
signatureType
protected SignatureSubpackets
unhashedSubpackets
-
Constructor Summary
Constructors Modifier Constructor Description AbstractSignatureBuilder(org.bouncycastle.openpgp.PGPSecretKey certificationKey, SecretKeyRingProtector protector, org.bouncycastle.openpgp.PGPSignature archetypeSignature)
AbstractSignatureBuilder(SignatureType signatureType, org.bouncycastle.openpgp.PGPSecretKey signingKey, SecretKeyRingProtector protector)
protected
AbstractSignatureBuilder(SignatureType signatureType, org.bouncycastle.openpgp.PGPSecretKey signingKey, SecretKeyRingProtector protector, HashAlgorithm hashAlgorithm, SignatureSubpackets hashedSubpackets, SignatureSubpackets unhashedSubpackets)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected org.bouncycastle.openpgp.PGPSignatureGenerator
buildAndInitSignatureGenerator()
Build an instance ofPGPSignatureGenerator
initialized with the signing key and with hashed and unhashed subpackets.protected abstract boolean
isValidSignatureType(SignatureType type)
Return true if the givenSignatureType
is a valid choice for the concrete implementation ofAbstractSignatureBuilder
.protected static HashAlgorithm
negotiateHashAlgorithm(org.bouncycastle.openpgp.PGPPublicKey publicKey)
Negotiate aHashAlgorithm
to be used when creating the signature.B
overrideHashAlgorithm(HashAlgorithm hashAlgorithm)
B
setSignatureType(SignatureType type)
Set the buildersSignatureType
.
-
-
-
Field Detail
-
privateSigningKey
protected final org.bouncycastle.openpgp.PGPPrivateKey privateSigningKey
-
publicSigningKey
protected final org.bouncycastle.openpgp.PGPPublicKey publicSigningKey
-
hashAlgorithm
protected HashAlgorithm hashAlgorithm
-
signatureType
protected SignatureType signatureType
-
unhashedSubpackets
protected SignatureSubpackets unhashedSubpackets
-
hashedSubpackets
protected SignatureSubpackets hashedSubpackets
-
-
Constructor Detail
-
AbstractSignatureBuilder
protected AbstractSignatureBuilder(SignatureType signatureType, org.bouncycastle.openpgp.PGPSecretKey signingKey, SecretKeyRingProtector protector, HashAlgorithm hashAlgorithm, SignatureSubpackets hashedSubpackets, SignatureSubpackets unhashedSubpackets) throws org.bouncycastle.openpgp.PGPException
- Throws:
org.bouncycastle.openpgp.PGPException
-
AbstractSignatureBuilder
public AbstractSignatureBuilder(SignatureType signatureType, org.bouncycastle.openpgp.PGPSecretKey signingKey, SecretKeyRingProtector protector) throws org.bouncycastle.openpgp.PGPException
- Throws:
org.bouncycastle.openpgp.PGPException
-
AbstractSignatureBuilder
public AbstractSignatureBuilder(org.bouncycastle.openpgp.PGPSecretKey certificationKey, SecretKeyRingProtector protector, org.bouncycastle.openpgp.PGPSignature archetypeSignature) throws org.bouncycastle.openpgp.PGPException
- Throws:
org.bouncycastle.openpgp.PGPException
-
-
Method Detail
-
negotiateHashAlgorithm
protected static HashAlgorithm negotiateHashAlgorithm(org.bouncycastle.openpgp.PGPPublicKey publicKey)
Negotiate aHashAlgorithm
to be used when creating the signature.- Parameters:
publicKey
- signing public key- Returns:
- hash algorithm
-
overrideHashAlgorithm
public B overrideHashAlgorithm(@Nonnull HashAlgorithm hashAlgorithm)
-
setSignatureType
public B setSignatureType(SignatureType type)
Set the buildersSignatureType
. Note that only those types who are valid for the concrete subclass of thisAbstractSignatureBuilder
are allowed. Invalid choices result in anIllegalArgumentException
to be thrown.- Parameters:
type
- signature type- Returns:
- builder
-
buildAndInitSignatureGenerator
protected org.bouncycastle.openpgp.PGPSignatureGenerator buildAndInitSignatureGenerator() throws org.bouncycastle.openpgp.PGPException
Build an instance ofPGPSignatureGenerator
initialized with the signing key and with hashed and unhashed subpackets.- Returns:
- pgp signature generator
- Throws:
org.bouncycastle.openpgp.PGPException
-
isValidSignatureType
protected abstract boolean isValidSignatureType(SignatureType type)
Return true if the givenSignatureType
is a valid choice for the concrete implementation ofAbstractSignatureBuilder
.- Parameters:
type
- type- Returns:
- return true if valid, false otherwise
-
-