public abstract class AbstractSignature extends Object implements Signature
Signature implementation| Modifier | 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 Pair<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 Signatureprotected 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
Signaturepublic void initVerifier(PublicKey key) throws Exception
initVerifier in interface Signaturekey - The PublicKey to be used for verifying signaturesException - If failed to initializepublic void initSigner(PrivateKey key) throws Exception
initSigner in interface Signaturekey - The PrivateKey to be used for signingException - If failed to initializepublic void update(byte[] hash,
int off,
int len)
throws Exception
Signatureprotected Pair<String,byte[]> extractEncodedSignature(byte[] sig)
sig - The original signaturePair where first value is the key type and second
value is the data - null if not encodedprotected boolean doVerify(byte[] data)
throws SignatureException
SignatureExceptionCopyright © 2008–2017 The Apache Software Foundation. All rights reserved.