Class TrustedProxies

java.lang.Object
org.alfresco.module.aosmodule.util.TrustedProxies

public final class TrustedProxies extends Object
An allowlist of trusted reverse proxies, parsed from a comma-separated list of IP addresses and/or CIDR ranges (IPv4 and IPv6). Used to decide whether the forwarded headers of an incoming request may be trusted.

An empty allowlist means "no restriction configured"; callers treat that as the historical, backward-compatible behavior of trusting the fronting proxy. Malformed entries are ignored so a single bad token cannot disable the whole allowlist.

Addresses are parsed with Guava's InetAddresses.forString(String) (see parseLiteral(String)), which accepts only IP literals and never performs name resolution: non-literal values (host names) are rejected rather than resolved, so neither configuration parsing nor per-request matching ever triggers a DNS lookup. This both avoids allowing host names where only IP/CIDR are expected and removes a potential latency/DoS vector on the unauthenticated request path.

  • Method Details

    • parse

      public static TrustedProxies parse(String config)
      Parses a comma-separated list of IP addresses and CIDR ranges. Returns an empty (never null) allowlist when config is null or blank.
    • isEmpty

      public boolean isEmpty()
    • isTrusted

      public boolean isTrusted(String remoteAddr)
      Returns whether the given remote address matches any configured exact address or CIDR range. Returns false for a null, blank or non-IP-literal address (host names are never resolved, avoiding DNS).