Package org.apache.juneau.commons.utils
Class UriUtils
java.lang.Object
org.apache.juneau.commons.utils.UriUtils
Various
URI-related utility methods.- Since:
- 10.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic URIThrowing variant ofisSecureOrLoopback(URI).static booleanisSecureOrLoopback(URI uri) Returnstrue if the specified URI either uses the"https" scheme or targets a loopback host.
-
Constructor Details
-
UriUtils
protected UriUtils()Constructor.
-
-
Method Details
-
isSecureOrLoopback
Returnstrue if the specified URI either uses the"https" scheme or targets a loopback host.A loopback host is one of
"localhost" (case-insensitive),"127.0.0.1" ,"::1" , or"[::1]" . A plaintext ("http" ) URI aimed at any other host returnsfalse , as does anull or scheme-less (malformed) URI. This is the check to make before transmitting anything sensitive to a caller-configured endpoint so that a plaintext transport is only tolerated for local development.- Parameters:
uri- The URI to check. Can benull (returnsfalse ).- Returns:
true if the URI is"https" or targets a loopback host.
-
assertSecureOrLoopback
Throwing variant ofisSecureOrLoopback(URI).- Parameters:
uri- The URI to validate. Can benull (rejected).- Returns:
- The validated URI (for fluent use).
- Throws:
IllegalArgumentException- If the URI is not"https" and does not target a loopback host.
-