public abstract class AbstractSignature extends Object implements Signature
Signature
implementationModifier | Constructor and Description |
---|---|
protected |
AbstractSignature(String algorithm) |
Modifier and Type | Method and Description |
---|---|
protected Signature |
doInitSignature(String algo,
boolean forSigning)
Initializes the internal signature instance
|
protected boolean |
doVerify(byte[] data) |
protected AbstractMap.SimpleImmutableEntry<String,byte[]> |
extractEncodedSignature(byte[] sig)
Makes an attempt to detect if the signature is encoded or pure data
|
String |
getAlgorithm() |
protected Signature |
getSignature() |
void |
initSigner(PrivateKey key) |
void |
initVerifier(PublicKey key) |
byte[] |
sign()
Compute the signature
|
String |
toString() |
void |
update(byte[] hash,
int off,
int len)
Update the computed signature with the given data
|
protected AbstractSignature(String algorithm)
public final String getAlgorithm()
getAlgorithm
in interface AlgorithmNameProvider
protected Signature doInitSignature(String algo, boolean forSigning) throws GeneralSecurityException
algo
- The signature's algorithmforSigning
- If true
then it is being initialized for signing,
otherwise for verifying a signatureSignature
instanceGeneralSecurityException
- if failed to initializeprotected Signature getSignature()
Signature
instance
- null
if not initializeddoInitSignature(String, boolean)
public byte[] sign() throws Exception
Signature
public void initVerifier(PublicKey key) throws Exception
initVerifier
in interface Signature
key
- The PublicKey
to be used for verifying signaturesException
- If failed to initializepublic void initSigner(PrivateKey key) throws Exception
initSigner
in interface Signature
key
- The PrivateKey
to be used for signingException
- If failed to initializepublic void update(byte[] hash, int off, int len) throws Exception
Signature
protected AbstractMap.SimpleImmutableEntry<String,byte[]> extractEncodedSignature(byte[] sig)
sig
- The original signatureAbstractMap.SimpleImmutableEntry
where first value is the key type and second
value is the data - null
if not encodedprotected boolean doVerify(byte[] data) throws SignatureException
SignatureException
Copyright © 2008–2022 The Apache Software Foundation. All rights reserved.