public abstract class AbstractSignature extends java.lang.Object implements Signature
Signature implementation| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
algorithm |
private java.security.Signature |
signatureInstance |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractSignature(java.lang.String algorithm) |
| Modifier and Type | Method and Description |
|---|---|
protected java.security.Signature |
doInitSignature(java.lang.String algo,
boolean forSigning)
Initializes the internal signature instance
|
protected boolean |
doVerify(byte[] data) |
protected java.util.AbstractMap.SimpleImmutableEntry<java.lang.String,byte[]> |
extractEncodedSignature(byte[] sig)
Makes an attempt to detect if the signature is encoded or pure data
|
java.lang.String |
getAlgorithm() |
protected java.security.Signature |
getSignature() |
void |
initSigner(java.security.PrivateKey key) |
void |
initVerifier(java.security.PublicKey key) |
byte[] |
sign()
Compute the signature
|
java.lang.String |
toString() |
void |
update(byte[] hash,
int off,
int len)
Update the computed signature with the given data
|
private java.security.Signature signatureInstance
private final java.lang.String algorithm
public final java.lang.String getAlgorithm()
getAlgorithm in interface AlgorithmNameProviderprotected java.security.Signature doInitSignature(java.lang.String algo,
boolean forSigning)
throws java.security.GeneralSecurityException
algo - The signature's algorithmforSigning - If true then it is being initialized for signing,
otherwise for verifying a signatureSignature instancejava.security.GeneralSecurityException - if failed to initializeprotected java.security.Signature getSignature()
Signature instance
- null if not initializeddoInitSignature(String, boolean)public byte[] sign()
throws java.lang.Exception
Signaturepublic void initVerifier(java.security.PublicKey key)
throws java.lang.Exception
initVerifier in interface Signaturekey - The PublicKey to be used for verifying signaturesjava.lang.Exception - If failed to initializepublic void initSigner(java.security.PrivateKey key)
throws java.lang.Exception
initSigner in interface Signaturekey - The PrivateKey to be used for signingjava.lang.Exception - If failed to initializepublic void update(byte[] hash,
int off,
int len)
throws java.lang.Exception
Signatureprotected java.util.AbstractMap.SimpleImmutableEntry<java.lang.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 java.security.SignatureException
java.security.SignatureExceptionpublic java.lang.String toString()
toString in class java.lang.Object