Class ComponentValueProvider
- All Implemented Interfaces:
SignatureContext
- Since:
- 1.1
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddDataTypeMapping
(String fieldName, StructuredDataType dataType) Add an additional mapping between a field name and its structured data type.Get the authority component of the target URI of the HTTP request message.getComponentValue
(ComponentIdentifier identifier) Get the value of the component specified by the component identifier.getComponentValue
(SignatureMetadata metadata, ComponentIdentifier identifier) Get the component value.getComponentValue
(String componentName) Get the value of the component specified by the component name.Get theMap
instance that manages additional mappings between field names and their structured data types.Get the pool of the HTTP header fields.Get the pool of the HTTP header fields in the request.Get the HTTP method of a request message.getPath()
Get the target path of the HTTP request message.getQuery()
Get the query component of the HTTP request message.getQueryParam
(String name) Get the value of a query parameter in the HTTP request message.Get the full request target of the HTTP request message.Get the scheme of the target URL of the HTTP request message.Get the three-digit numeric HTTP status code of a response message.Get the target URI of a request message.Get the pool of the HTTP trailer fields.Get the pool of the HTTP trailer fields in the request.setHeaders
(Map<String, List<String>> headers) Set the pool of the HTTP header fields.setHeadersInRequest
(Map<String, List<String>> headersInRequest) Set the pool of the HTTP header fields in the request.Set the HTTP method of a request message.setRequestTarget
(String requestTarget) Set the full request target of the HTTP request message.setStatus
(int status) Set the three-digit numeric HTTP status code of a response message.Set the three-digit numeric HTTP status code of a response message.setTargetUri
(String uri) Set the target URI of a request message.setTargetUri
(URI uri) Set the target URI of a request message.setTrailers
(Map<String, List<String>> trailers) Set the pool of the HTTP trailer fields.setTrailersInRequest
(Map<String, List<String>> trailersInRequest) Set the pool of the HTTP trailer fields in the request.
-
Constructor Details
-
ComponentValueProvider
public ComponentValueProvider()The default constructor.
-
-
Method Details
-
getComponentValue
public String getComponentValue(SignatureMetadata metadata, ComponentIdentifier identifier) throws SignatureException Description copied from interface:SignatureContext
Get the component value.- Specified by:
getComponentValue
in interfaceSignatureContext
- Parameters:
metadata
- The signature metadata where the component identifier is included.identifier
- The component identifier.- Returns:
- The value of the component identified by the component identifier. null if the component value is not available.
- Throws:
SignatureException
- Something wrong happened.
-
getHeaders
-
setHeaders
Set the pool of the HTTP header fields.- Parameters:
headers
- The pool of the HTTP header fields.- Returns:
this
object.
-
getTrailers
-
setTrailers
Set the pool of the HTTP trailer fields.- Parameters:
trailers
- The pool of the HTTP trailer fields.- Returns:
this
object.
-
getHeadersInRequest
-
setHeadersInRequest
Set the pool of the HTTP header fields in the request.- Parameters:
headersInRequest
- The pool of the HTTP header fields in the request.- Returns:
this
object.
-
getTrailersInRequest
-
setTrailersInRequest
Set the pool of the HTTP trailer fields in the request.- Parameters:
trailersInRequest
- The pool of the HTTP trailer fields in the request.- Returns:
this
object.
-
getDataTypeMappings
Get theMap
instance that manages additional mappings between field names and their structured data types. The mappings managed by the instance are referenced when processing thesf
flag (RFC 9421, Section 2.1.1. Strict Serialization of HTTP Structured Fields).This class implementation refers to the default mappings maintained within the
StructuredDataType
class when the mapping for a field name, specified as a component name with thesf
flag, is not found in the additional mappings.- Returns:
- The
Map
instance that manages additional mappings.
-
addDataTypeMapping
Add an additional mapping between a field name and its structured data type. This mapping is referenced when processing thesf
flag (RFC 9421, Section 2.1.1. Strict Serialization of HTTP Structured Fields).This class implementation refers to the default mappings maintained within the
StructuredDataType
class when the mapping for a field name, specified as a component name with thesf
flag, is not found in the additional mappings.- Parameters:
fieldName
- A field name. The given value is converted to lowercase before being added.dataType
- A data type.- Returns:
this
object.
-
getMethod
Get the HTTP method of a request message. This is used as the value of the"@method"
derived component.- Returns:
- The HTTP method of a request message.
- See Also:
-
setMethod
Set the HTTP method of a request message. This is used as the value of the"@method"
derived component.- Parameters:
method
- The HTTP method of a request message.- Returns:
this
object.- See Also:
-
getTargetUri
Get the target URI of a request message. This is used as the value of the"@target-uri"
derived component.- Returns:
- The target URI of a request message.
- See Also:
-
setTargetUri
Set the target URI of a request message. This is used as the value of the"@target-uri"
derived component.- Parameters:
uri
- The target URI of a request message.- Returns:
this
object.- Throws:
IllegalArgumentException
- The given string violates RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax.- See Also:
-
setTargetUri
Set the target URI of a request message. This is used as the value of the"@target-uri"
derived component.- Parameters:
uri
- The target URI of a request message.- Returns:
this
object.- See Also:
-
getAuthority
Get the authority component of the target URI of the HTTP request message. This is used as the value of the"@authority"
derived component.The value of this derived component is computed based on the target URI set by the
setTargetUri
method.- Returns:
- The authority component of the target URI of the HTTP request message.
- See Also:
-
getScheme
Get the scheme of the target URL of the HTTP request message. This is used as the value of the"@scheme"
derived component.The value of this derived component is computed based on the target URI set by the
setTargetUri
method.- Returns:
- The scheme of the target URL of the HTTP request message.
- See Also:
-
getRequestTarget
Get the full request target of the HTTP request message. This is used as the value of the"@request-target"
derived component.- Returns:
- The full request target of the HTTP request message.
- See Also:
-
setRequestTarget
Set the full request target of the HTTP request message. This is used as the value of the"@request-target"
derived component.- Parameters:
requestTarget
- The full request target of the HTTP request message.- Returns:
this
object.- See Also:
-
getPath
Get the target path of the HTTP request message. This is used as the value of the"@path"
derived component.The value of this derived component is computed based on the target URI set by the
setTargetUri
method.- Returns:
- The target path of the HTTP request message.
- See Also:
-
getQuery
Get the query component of the HTTP request message. This is used as the value of the"@query"
derived component.The value of this derived component is computed based on the target URI set by the
setTargetUri
method.- Returns:
- The query component of the HTTP request message.
- See Also:
-
getQueryParam
Get the value of a query parameter in the HTTP request message. This is used as the value of the"@query-param";name="name"
derived component.The value of this derived component is computed based on the target URI set by the
setTargetUri
method.- Parameters:
name
- The name of a query parameter.- Returns:
- The value of a query parameter in the HTTP request message.
- See Also:
-
getStatus
Get the three-digit numeric HTTP status code of a response message. This is used as the"@status"
derived component.- Returns:
- The three-digit numeric HTTP status code of a response message.
- See Also:
-
setStatus
Set the three-digit numeric HTTP status code of a response message. This is used as the"@status"
derived component.- Parameters:
status
- The three-digit numeric HTTP status code of a response message.- Returns:
this
object.- Throws:
IllegalArgumentException
- The value ofstatus
does not represent a three-digit positive integer.- See Also:
-
setStatus
Set the three-digit numeric HTTP status code of a response message. This is used as the"@status"
derived component.- Parameters:
status
- The three-digit numeric HTTP status code of a response message.- Returns:
this
object.- Throws:
IllegalArgumentException
- The value ofstatus
is not a three-digit positive integer.- See Also:
-
getComponentValue
Get the value of the component specified by the component identifier.- Parameters:
identifier
- A component identifier.- Returns:
- The value of the specified component. If the value is
unavailable,
null
is returned. - Throws:
SignatureException
- (1) The component identifier includes thekey
parameter, but the HTTP field value is either missing, cannot be parsed as a dictionary, or contains no entry with the specified key. (2) The component identifier includes thesf
parameter, but the data type of the HTTP field is either unknown or its value cannot be parsed as the expected data type.
-
getComponentValue
Get the value of the component specified by the component name.- Parameters:
componentName
- A component name.- Returns:
- The value of the specified component. If the value is
unavailable,
null
is returned. - Throws:
SignatureException
- If the value of the specified component is unavailable, even when the component name represents a derived component.
-