Class VerificationSpec.Builder
- Enclosing class:
- VerificationSpec
VerificationSpec
objects.
Signature Context must be provided, and it should contain Signature-Input and Signature headers. Public ket getter key must be provided. Signature label must be provided.
-
Method Summary
Modifier and TypeMethodDescriptionapplicationTag
(String tag) Sets application-specific tag of signature to verifybuild()
ConstructsVerificationSpec
object from this buildercontext
(SignatureContext signatureContext) Sets Signature ContextforbiddenParameters
(Collection<SignatureParameterType> parameters) Sets Signature Parameters which must not be present in verified signature, e.g.forbiddenParameters
(SignatureParameterType... parameters) Sets Signature Parameters which must not be present in verified signature, e.g.maximumAge
(int maximumAgeSeconds) Sets maximum age of verified signature in secondsmaximumSkew
(int maximumSkewSeconds) Set s maximum "skew" for created Signature Property (in seconds) - for detecting signatures from the "future".publicKeyGetter
(CheckedFunction<String, PublicKeyInfo> publicKeyGetter) Sets public key supplier functionrequiredComponents
(SignatureComponents components) Sets definitions of required Signature ComponentsrequiredIfPresentComponents
(SignatureComponents components) Sets definitions of Signature Components which are required in the signature only if their values are defined in Signature Context.requiredParameters
(Collection<SignatureParameterType> parameters) Sets Signature Parameters which must be present in verified signature.requiredParameters
(SignatureParameterType... parameters) Sets Signature Parameters which must be present in verified signature.signatureLabel
(String signatureLabel) Sets label of signature to verify
-
Method Details
-
requiredParameters
Sets Signature Parameters which must be present in verified signature.If any of them is not present, in Signature-Input, then verified signature is rejected.
- Parameters:
parameters
- Required Signature Parameter types, provided as vararg- Returns:
- This builder
-
requiredParameters
Sets Signature Parameters which must be present in verified signature.If any of them is not present, in Signature-Input, then verified signature is rejected.
- Parameters:
parameters
- Required Signature Parameter types, provided as collection- Returns:
- This builder
-
forbiddenParameters
Sets Signature Parameters which must not be present in verified signature, e.g. algIf any of them is present, in Signature-Input, then verified signature is rejected.
- Parameters:
parameters
- Forbidden Signature Parameter types, provided as varargs- Returns:
- This builder
-
forbiddenParameters
Sets Signature Parameters which must not be present in verified signature, e.g. algIf any of them is present, in Signature-Input, then verified signature is rejected.
- Parameters:
parameters
- Forbidden Signature Parameter types, provided as collection- Returns:
- This builder
-
requiredComponents
Sets definitions of required Signature ComponentsIf related values are not present in verified Signature-Input, the signature is rejected.
- Parameters:
components
- Required Signature Components- Returns:
- This builder
-
requiredIfPresentComponents
Sets definitions of Signature Components which are required in the signature only if their values are defined in Signature Context.They can be optional HTTP headers which must be included in the signature if they are present. If such headers are present in the Signature Context but are missing in Signature-Input, the signature is rejected.
- Parameters:
components
- Signature Components required if present in the Signature Context- Returns:
- This builder
-
context
Sets Signature Context- Parameters:
signatureContext
- Signature Context with values obtained from verified request or response- Returns:
- This builder
-
maximumAge
Sets maximum age of verified signature in secondsAge is based on created Signature Parameter. Signature is rejected if
created < now() - maximumAgeSeconds
. Such verification is performed only if created Signature Parameter is present.- Parameters:
maximumAgeSeconds
- Maximum age of verified signature in seconds- Returns:
- This builder
-
maximumSkew
Set s maximum "skew" for created Signature Property (in seconds) - for detecting signatures from the "future".A signature will be rejected if it's from the "future" -
created > now() + maximumSkewSeconds
- Parameters:
maximumSkewSeconds
- Maximum "future" skew of verified signature n seconds- Returns:
- This builder
-
publicKeyGetter
public VerificationSpec.Builder publicKeyGetter(CheckedFunction<String, PublicKeyInfo> publicKeyGetter) Sets public key supplier functionThe supplier should return
PublicKeyInfo
object for given key ID, or throw an exception in case of problems, e.g. unknown key ID. Key ID is extracted from Signature-Input header.- Parameters:
publicKeyGetter
- Function which for given keyid returns related public key- Returns:
- This builder
- See Also:
-
signatureLabel
Sets label of signature to verifySignature and Signature-Input headers will be searched for provided label. If they don't contain the label, signature verification will be rejected.
If application-specific {
applicationTag(String)
} is also provided then found signature must contain both the label and the tag. If signatureLabel is not provided then onlyapplicationTag(String)
is used to find matching signature. Either signatureLabel or applicationTag must be provided in verification specs.- Parameters:
signatureLabel
- Label of signature to verify- Returns:
- This builder
-
applicationTag
Sets application-specific tag of signature to verifySignature-Input header will be searched for provided tag. If it doesn't contain the tag, signature verification will be rejected. If multiple signatures contain the tag, signature verification will be rejected.
If {
signatureLabel(String)
is also provided then found signature must contain both the label and the tag. (In this case multiple signatures having the tag won't lead to rejection.) If tag is not provided then onlysignatureLabel(String)
is used to find matching signature. Either signatureLabel or applicationTag must be provided in verification specs.- Parameters:
tag
- Application-specific tag of signature to verify- Returns:
- This builder
-
build
ConstructsVerificationSpec
object from this builderAll required data mentioned in
VerificationSpec.Builder
must be provided (signature context, public key getter, signature label).- Returns:
- VerificationSpec object
-