Class UriUtils

java.lang.Object
org.apache.juneau.commons.utils.UriUtils

public class UriUtils extends Object
Various URI-related utility methods.
Since:
10.0.0
  • Constructor Details

    • UriUtils

      protected UriUtils()
      Constructor.
  • Method Details

    • isSecureOrLoopback

      public static boolean isSecureOrLoopback(URI uri)
      Returns true 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 returns false, as does a null 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 be null (returns false).
      Returns:
      true if the URI is "https" or targets a loopback host.
    • assertSecureOrLoopback

      public static URI assertSecureOrLoopback(URI uri)
      Throwing variant of isSecureOrLoopback(URI).
      Parameters:
      uri - The URI to validate. Can be null (rejected).
      Returns:
      The validated URI (for fluent use).
      Throws:
      IllegalArgumentException - If the URI is not "https" and does not target a loopback host.