Class RemoteProxyUtils

java.lang.Object
org.apache.juneau.rest.client.classic.remote.RemoteProxyUtils

public class RemoteProxyUtils extends Object
Shared helpers for the classic REST-proxy engine.

The parse/apply logic here is ported from the next-generation engine (org.apache.juneau.rest.client.remote.RemoteClient and RrpcInterfaceMeta) so that the classic engine can honor the same @Remote/@RemoteOp members without introducing a cross-module dependency on freshly-installed common code.

See Also:
  • Method Details

    • parseConstantParts

      public static List<Map.Entry<String,String>> parseConstantParts(String[] entries, char delim)
      Parses an array of constant "name<delim>value" strings into resolved name/value entries.

      Ported from the next-generation engine's RrpcInterfaceMeta.parseConstantParts(...). Each entry is resolved through VarResolver.DEFAULT (so values such as "$S{sysprop}" expand), then split on the first occurrence of delim (':' for the "Name: value" header form, '=' for the "name=value" query/form-data form). Entries with no delimiter are skipped. Both the name and the value are trimmed.

      Parameters:
      entries - The raw annotation strings (may be empty).
      delim - The name/value delimiter character.
      Returns:
      An unmodifiable list of resolved name/value entries. Never null, but may be empty.
    • mergeConstants

      public static Map<String,String> mergeConstants(List<Map.Entry<String,String>> interfaceLevel, List<Map.Entry<String,String>> methodLevel)
      Merges interface-level and method-level constant parts into a single name-keyed map, with method-level entries overriding interface-level entries of the same name (declaration order preserved).

      Ported from the next-generation engine's RemoteInvocationHandler.applyConstants(...).

      Parameters:
      interfaceLevel - Interface-level constants (applied first; lower precedence).
      methodLevel - Method-level constants (override interface-level entries of the same name).
      Returns:
      An ordered, name-keyed map of merged constants. Never null, but may be empty.
    • combinePaths

      public static String combinePaths(String base, String method)
      Combines a base URL with a method path, avoiding double slashes.

      Ported verbatim from the next-generation engine's RemoteInvocationHandler.combinePaths(...).

      Parameters:
      base - The base URL/path.
      method - The method path.
      Returns:
      The combined path.
    • requireHttpScheme

      public static String requireHttpScheme(String url)
      Enforces the SSRF guardrail with the default (deny-private) policy: delegates to requireHttpScheme(url, false).
      Parameters:
      url - The URL to validate.
      Returns:
      The unchanged URL.
      Throws:
      IllegalArgumentException - If url is absolute and violates the policy.
    • requireHttpScheme

      public static String requireHttpScheme(String url, boolean allowPrivateUrls)
      Enforces the SSRF guardrail: when url carries a URI scheme it must be http or https with a nonempty host, and — unless allowPrivateUrls is set — must not target a loopback/private/link-local/metadata host (see RemoteUrlPolicy). Scheme-less (relative) values pass through unchanged.

      Delegates to the shared RemoteUrlPolicy.requireAllowedUrl(String, boolean) used by both the classic and next-generation engines, so the deny-list is defined exactly once.

      Parameters:
      url - The URL to validate.
      allowPrivateUrls - When true, the deny-private check is skipped (the http/https scheme requirement still applies).
      Returns:
      The unchanged URL.
      Throws:
      IllegalArgumentException - If url is absolute and violates the policy.
    • requireHttpScheme

      public static String requireHttpScheme(String url, boolean allowPrivateUrls, RemoteUrlPolicy.AllowedRanges allowedRanges)
      Same as requireHttpScheme(String, boolean), additionally honoring a client's per-client allowed address ranges.
      Parameters:
      url - The URL to validate.
      allowPrivateUrls - When true, the deny-private check is skipped.
      allowedRanges - The client's RemoteUrlPolicy.AllowedRanges, unioned with the RestClient.allowAddressRanges property.
      Returns:
      The unchanged URL.
      Throws:
      IllegalArgumentException - If url is absolute and violates the policy.
    • warnUnsupportedMember

      public static void warnUnsupportedMember(Class<?> interfaceClass, String member, String detail)
      Emits a one-time build-time warning that an @Remote/@RemoteOp member is set on the classic engine that the classic engine cannot honor.

      De-duplicated per interface-class + member name so it fires at most once for a given proxy interface.

      Parameters:
      interfaceClass - The proxy interface the member was declared on.
      member - The unsupported member name (e.g. "interceptors").
      detail - A short explanation of why the member is not honored.