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(SessionContext session,
String algo,
Key key,
boolean forSigning)
Initializes the internal signature instance
|
protected boolean |
doVerify(byte[] data) |
protected Map.Entry<String,byte[]> |
extractEncodedSignature(byte[] sig,
Collection<String> expectedTypes)
Makes an attempt to detect if the signature is encoded or pure data
|
protected Map.Entry<String,byte[]> |
extractEncodedSignature(byte[] sig,
Predicate<? super String> typeSelector) |
String |
getAlgorithm() |
protected Signature |
getSignature() |
void |
initSigner(SessionContext session,
PrivateKey key) |
void |
initVerifier(SessionContext session,
PublicKey key) |
byte[] |
sign(SessionContext session)
Compute the signature
|
String |
toString() |
void |
update(SessionContext session,
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 AlgorithmNameProviderprotected Signature doInitSignature(SessionContext session, String algo, Key key, boolean forSigning) throws GeneralSecurityException
session - The SessionContext for calling this method - may be null if not
called within a session contextalgo - The signature's algorithm namekey - the Key that is provided for initialization - a PrivateKey for
signing and a PublicKey for verificationforSigning - 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(SessionContext, String, Key, boolean)public byte[] sign(SessionContext session) throws Exception
Signaturesign in interface Signaturesession - The SessionContext for calling this method - may be null if not called within a
session contextException - If failed to calculate the signaturepublic void initVerifier(SessionContext session, PublicKey key) throws Exception
initVerifier in interface Signaturesession - The SessionContext for calling this method - may be null if not called within a
session contextkey - The PublicKey to be used for verifying signaturesException - If failed to initializepublic void initSigner(SessionContext session, PrivateKey key) throws Exception
initSigner in interface Signaturesession - The SessionContext for calling this method - may be null if not called within a
session contextkey - The PrivateKey to be used for signingException - If failed to initializepublic void update(SessionContext session, byte[] hash, int off, int len) throws Exception
Signatureupdate in interface Signaturesession - The SessionContext for calling this method - may be null if not called within a
session contexthash - The hash data bufferoff - Offset of hash data in bufferlen - Length of hash dataException - If failed to updateprotected Map.Entry<String,byte[]> extractEncodedSignature(byte[] sig, Collection<String> expectedTypes)
sig - The original signatureexpectedTypes - The expected encoded key typesAbstractMap.SimpleImmutableEntry where first value is the key type and second value is the
data - null if not encodedprotected Map.Entry<String,byte[]> extractEncodedSignature(byte[] sig, Predicate<? super String> typeSelector)
protected boolean doVerify(byte[] data)
throws SignatureException
SignatureExceptionCopyright © 2018–2020 The Apache Software Foundation. All rights reserved.