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 theMapinstance 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:SignatureContextGet the component value.- Specified by:
getComponentValuein 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:
thisobject.
-
getTrailers
-
setTrailers
Set the pool of the HTTP trailer fields.- Parameters:
trailers- The pool of the HTTP trailer fields.- Returns:
thisobject.
-
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:
thisobject.
-
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:
thisobject.
-
getDataTypeMappings
Get theMapinstance that manages additional mappings between field names and their structured data types. The mappings managed by the instance are referenced when processing thesfflag (RFC 9421, Section 2.1.1. Strict Serialization of HTTP Structured Fields).This class implementation refers to the default mappings maintained within the
StructuredDataTypeclass when the mapping for a field name, specified as a component name with thesfflag, is not found in the additional mappings.- Returns:
- The
Mapinstance that manages additional mappings.
-
addDataTypeMapping
Add an additional mapping between a field name and its structured data type. This mapping is referenced when processing thesfflag (RFC 9421, Section 2.1.1. Strict Serialization of HTTP Structured Fields).This class implementation refers to the default mappings maintained within the
StructuredDataTypeclass when the mapping for a field name, specified as a component name with thesfflag, 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:
thisobject.
-
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:
thisobject.- 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:
thisobject.- 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:
thisobject.- 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
setTargetUrimethod.- 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
setTargetUrimethod.- 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:
thisobject.- 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
setTargetUrimethod.- 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
setTargetUrimethod.- 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
setTargetUrimethod.- 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:
thisobject.- Throws:
IllegalArgumentException- The value ofstatusdoes 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:
thisobject.- Throws:
IllegalArgumentException- The value ofstatusis 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,
nullis returned. - Throws:
SignatureException- (1) The component identifier includes thekeyparameter, 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 thesfparameter, 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,
nullis returned. - Throws:
SignatureException- If the value of the specified component is unavailable, even when the component name represents a derived component.
-