Class AbstractHttpWebServiceMessageSender
- All Implemented Interfaces:
WebServiceMessageSender
- Direct Known Subclasses:
AbstractHttpComponents5MessageSender, ClientHttpRequestMessageSender, HttpComponentsMessageSender, HttpUrlConnectionMessageSender, JdkHttpClientMessageSender
WebServiceMessageSender implementations that
use HTTP.
For WebServiceMessageSender.UriSource.APPLICATION, default checks accept any http: or
https: URI. For WebServiceMessageSender.UriSource.REMOTE, default checks require a host; reject
localhost and *.localhost; and when the host is an IP literal, reject
loopback, link-local, any-local addresses without DNS lookups, and RFC 1918-style
private IPv4 literals. Non-literal host names are not resolved in the defaults, so
private network access through DNS is not rejected unless you add a
WebServiceMessageSender.DestinationPolicy, for example, using
HttpDestinationDescriptor.hostAddress(boolean) with DNS for stricter checks or
host allowlists. Private IPv4 literals can be enabled by setting
allowSiteLocalIpv4 to true.
- Since:
- 1.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface WebServiceMessageSender
WebServiceMessageSender.DestinationDescriptor, WebServiceMessageSender.DestinationPolicy<D>, WebServiceMessageSender.UriSource -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.commons.logging.LogLogger available to subclasses. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreate an instance that acceptshttp:andhttps:URIs.protectedAbstractHttpWebServiceMessageSender(Predicate<URI> supportedUriFilter) Create an instance with the URI filter to apply to accept a given URI. -
Method Summary
Modifier and TypeMethodDescriptionprotected HttpDestinationDescriptorcreateDescriptor(URI uri, WebServiceMessageSender.UriSource uriSource) protected Predicate<HttpDestinationDescriptor> defaultChecks(WebServiceMessageSender.UriSource uriSource) Return the default checks to apply for the givenWebServiceMessageSender.UriSource.booleanReturn whether to accept GZIP encoding, that is, whether to send the HTTPAccept-Encodingheader withgzipas value.protected booleanremoteDefaultChecks(HttpDestinationDescriptor descriptor) Apply default checks forWebServiceMessageSender.UriSource.REMOTEURIs.voidsetAcceptGzipEncoding(boolean acceptGzipEncoding) Set whether to accept GZIP encoding, that is, whether to send the HTTPAccept-Encodingheader withgzipas value.voidsetAllowDnsResolution(boolean allowDnsResolution) Set whether to allow DNS resolution for remote destinations.voidsetAllowSiteLocalIpv4(boolean allowSiteLocalIpv4) Set whether to allow site-local IPv4 addresses for remote destinations.Methods inherited from class AbstractWebServiceMessageSender
getDestinationPolicy, setDestinationPolicy, supportsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface WebServiceMessageSender
createConnection, supports
-
Field Details
-
logger
protected final org.apache.commons.logging.Log loggerLogger available to subclasses.
-
-
Constructor Details
-
AbstractHttpWebServiceMessageSender
-
AbstractHttpWebServiceMessageSender
protected AbstractHttpWebServiceMessageSender()Create an instance that acceptshttp:andhttps:URIs.
-
-
Method Details
-
isAcceptGzipEncoding
public boolean isAcceptGzipEncoding()Return whether to accept GZIP encoding, that is, whether to send the HTTPAccept-Encodingheader withgzipas value. -
setAcceptGzipEncoding
public void setAcceptGzipEncoding(boolean acceptGzipEncoding) Set whether to accept GZIP encoding, that is, whether to send the HTTPAccept-Encodingheader withgzipas value.Default is
true. Turn this flag off if you do not want GZIP response compression even if enabled on the HTTP server. -
setAllowSiteLocalIpv4
public void setAllowSiteLocalIpv4(boolean allowSiteLocalIpv4) Set whether to allow site-local IPv4 addresses for remote destinations.Default is
false. Whenfalse, remote default checks reject private (RFC 1918) IPv4 literals like10.0.0.1. Set totrueto allow out-of-band replies to internal network destinations unless blocked by another policy.- Since:
- 3.1.9
-
setAllowDnsResolution
public void setAllowDnsResolution(boolean allowDnsResolution) Set whether to allow DNS resolution for remote destinations.Default is
falseto avoid the performance penalty of resolving every remote destination. However, this means that malicious hostnames resolving to internal IPs (DNS rebinding or simply internal DNS records) are not blocked by the default IP-level checks. To secure out-of-band replies without the DNS resolution penalty, it is strongly recommended to configure a strict allowlist of known hosts using aWebServiceMessageSender.DestinationPolicy.Set to
trueto resolve host names and apply default checks to the resolved IPs, mitigating SSRF attacks using DNS at the cost of additional latency.- Since:
- 3.1.9
-
createDescriptor
protected HttpDestinationDescriptor createDescriptor(URI uri, WebServiceMessageSender.UriSource uriSource) Description copied from class:AbstractWebServiceMessageSender- Specified by:
createDescriptorin classAbstractWebServiceMessageSender<HttpDestinationDescriptor>- Parameters:
uri- the URI to checkuriSource- the source of the URI- Returns:
- a suitable descriptor
-
defaultChecks
protected Predicate<HttpDestinationDescriptor> defaultChecks(WebServiceMessageSender.UriSource uriSource) Description copied from class:AbstractWebServiceMessageSenderReturn the default checks to apply for the givenWebServiceMessageSender.UriSource.- Specified by:
defaultChecksin classAbstractWebServiceMessageSender<HttpDestinationDescriptor>- Returns:
- the default checks to apply
-
remoteDefaultChecks
Apply default checks forWebServiceMessageSender.UriSource.REMOTEURIs.- Parameters:
descriptor- the descriptor- Returns:
- whether the default checks accept the URI of the given descriptor
-