Interface JWSAlgorithm
- All Superinterfaces:
de.christofreichardt.diagnosis.Traceable
- All Known Implementing Classes:
HmacSHA256,SHA256withECDSA,SHA256withRSA
public interface JWSAlgorithm
extends de.christofreichardt.diagnosis.Traceable
All algorithm classes used for signing or validating must implement this interface. The methods below are acting as adapters
between the instances responsible for signing (or rather validating) and the cryptographic algorithms provided by the
Java platform.
- Author:
- Christof Reichardt
-
Method Summary
Modifier and TypeMethodDescriptionReturns the name of the underlying algorithm object.voidInitialises the underlying algorithm provided by the Java platform with the given key.byte[]Requests a signature from the underlying algorithm for the delivered bytes.voidupdate(byte[] data) Hands over the given bytes to the underlying algorithm provided by the Java platform.booleanverify(byte[] signature) Requests the validation of the delivered data agianst the given signature.Methods inherited from interface de.christofreichardt.diagnosis.Traceable
getCurrentTracer
-
Method Details
-
init
Initialises the underlying algorithm provided by the Java platform with the given key.- Parameters:
key- the cryptographic key used for signing or validating.- Throws:
GeneralSecurityException- if something goes wrong during the initialization.
-
update
Hands over the given bytes to the underlying algorithm provided by the Java platform.- Parameters:
data- the data to be signed or to be validated.- Throws:
GeneralSecurityException- if something goes wrong during the update, e.g. the underlying algorithm hasn't been properly initialized.
-
signature
Requests a signature from the underlying algorithm for the delivered bytes.- Returns:
- the signature bytes
- Throws:
GeneralSecurityException- if the underlying algorithm couldn't process the delivered data for various reasons.
-
verify
Requests the validation of the delivered data agianst the given signature.- Parameters:
signature- the signature bytes.- Returns:
- indicates if the signature has been valid.
- Throws:
GeneralSecurityException- if the underlying algorithm couldn't process the delivered data for various reasons.
-
algorithm
String algorithm()Returns the name of the underlying algorithm object.- Returns:
- the name of the underlying algorithm object.
-