-
public interface HostValidator
A type that validates hosts to be connected.
-
-
Field Summary
Fields Modifier and Type Field Description static HostValidator
ALLOW_ALL
AHostValidator
that allows all hosts.static HostValidator
DENY_COMMON_INFRASTRUCTURE_TARGETS
AHostValidator
that prevents access to common infrastructure targets.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static HostValidator
fromAllowedHostDomain(java.lang.String domainName)
Return aHostValidator
that will assure a given domain is within the allowed domain.static HostValidator
fromAllowedHostPattern(java.util.regex.Pattern allowPattern)
Return aHostValidator
that will validate the host name against the "allowPattern".boolean
isAllowed(java.lang.String host)
Decide whether a host is allowed to be reached
-
-
-
Field Detail
-
ALLOW_ALL
static final HostValidator ALLOW_ALL
AHostValidator
that allows all hosts.
-
DENY_COMMON_INFRASTRUCTURE_TARGETS
static final HostValidator DENY_COMMON_INFRASTRUCTURE_TARGETS
AHostValidator
that prevents access to common infrastructure targets. Right now this only includes likely gateway IP address and AWS Metadata services host, but hopefully over time we can identify more. Note that changes to this set should also include the "integer" version of the IP address, which can be generated with utilities on the web.
-
-
Method Detail
-
isAllowed
boolean isAllowed(java.lang.String host)
Decide whether a host is allowed to be reached- Parameters:
host
- the host of aURL
- Returns:
- true, if the application can connect to the host, false otherwise
-
fromAllowedHostPattern
static HostValidator fromAllowedHostPattern(java.util.regex.Pattern allowPattern)
Return aHostValidator
that will validate the host name against the "allowPattern".- Parameters:
allowPattern
- the pattern that describes allowed hosts- Returns:
- a validator based on the given host pattern
-
fromAllowedHostDomain
static HostValidator fromAllowedHostDomain(java.lang.String domainName)
Return aHostValidator
that will assure a given domain is within the allowed domain. For example, given a domain of "good.com", this validator will allow "good.com", "www.good.com", "internal.good.com", etc.- Parameters:
domainName
- the domain to allow, e.g., "good.com", or "internal-host"- Returns:
- a validator that will only allow hosts within the given domain space
-
-