Class SignatureBase
java.lang.Object
com.authlete.hms.SignatureBase
A class representing
signature-base
defined in RFC 9421
HTTP Message Signatures, Section 2.5. Creating the Signature Base.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSignatureBase
(List<SignatureBaseLine> baseLines, SignatureParamsLine paramsLine) A constructor with signature base lines and a signature params line. -
Method Summary
Modifier and TypeMethodDescriptionGet the signature base lines included in this signature base.Get the signature params line included in this signature base.Serialize the signature base represented by this instance, and return the resulting string.Serialize the signature base represented by this instance, and write the resulting string into the specified string builder.byte[]
sign
(HttpSigner signer) Sign this signature base (= create a signature for this signature base).toString()
Get the string representation of this instance, which is the serialized signature base returned by theserialize()
method.boolean
verify
(HttpVerifier verifier, byte[] signature) Verify the signature.
-
Constructor Details
-
SignatureBase
A constructor with signature base lines and a signature params line.- Parameters:
baseLines
- Signature base lines.paramsLine
- A signature params line. Must not be null.- Throws:
IllegalArgumentException
- The signature params line is null.
-
-
Method Details
-
toString
Get the string representation of this instance, which is the serialized signature base returned by theserialize()
method. -
serialize
Serialize the signature base represented by this instance, and return the resulting string.- Returns:
- The serialized signature base represented by this instance.
-
serializeTo
Serialize the signature base represented by this instance, and write the resulting string into the specified string builder.The ABNF for signature base from RFC 9421 HTTP Message Signatures, 2.5. Creating the Signature Base:
signature-base = *( signature-base-line LF ) signature-params-line signature-base-line = component-identifier ":" SP ( derived-component-value / *field-content ) ; no obs-fold nor obs-text component-identifier = component-name parameters component-name = sf-string derived-component-value = *( VCHAR / SP ) signature-params-line = DQUOTE "@signature-params" DQUOTE ":" SP inner-list
- Parameters:
sb
- A string builder into which the resulting string is written.- Returns:
- The same string builder that was passed as the argument.
-
getBaseLines
Get the signature base lines included in this signature base.- Returns:
- The signature base lines.
-
getParamsLine
Get the signature params line included in this signature base.- Returns:
- The signature params line.
-
sign
Sign this signature base (= create a signature for this signature base).- Parameters:
signer
- A signer that signs the signature base.- Returns:
- A newly generated signature.
- Throws:
SignatureException
- The signing operation failed.
-
verify
Verify the signature.- Parameters:
verifier
- A verifier that verifies the signature.signature
- A signature.- Returns:
- True if the signature is valid.
- Throws:
SignatureException
- Signature verification failed, or the signature is invalid.
-