Class RemoteProxyUtils
The parse/apply logic here is ported from the next-generation engine
(@Remote/@RemoteOp
members without introducing a cross-module dependency on freshly-installed common code.
See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringcombinePaths(String base, String method) Combines a base URL with a method path, avoiding double slashes.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).parseConstantParts(String[] entries, char delim) Parses an array of constant"name<delim>value"strings into resolved name/value entries.static StringrequireHttpScheme(String url) Enforces the SSRF guardrail with the default (deny-private) policy: delegates torequireHttpScheme(url, false).static StringrequireHttpScheme(String url, boolean allowPrivateUrls) Enforces the SSRF guardrail: whenurlcarries a URI scheme it must behttporhttpswith a nonempty host, and — unlessallowPrivateUrlsis set — must not target a loopback/private/link-local/metadata host (seeRemoteUrlPolicy).static StringrequireHttpScheme(String url, boolean allowPrivateUrls, RemoteUrlPolicy.AllowedRanges allowedRanges) Same asrequireHttpScheme(String, boolean), additionally honoring a client's per-client allowed address ranges.static voidwarnUnsupportedMember(Class<?> interfaceClass, String member, String detail)
-
Method Details
-
parseConstantParts
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 throughVarResolver.DEFAULT(so values such as"$S{sysprop}"expand), then split on the first occurrence ofdelim(':'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
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
Enforces the SSRF guardrail with the default (deny-private) policy: delegates torequireHttpScheme(url, false).- Parameters:
url- The URL to validate.- Returns:
- The unchanged URL.
- Throws:
IllegalArgumentException- Ifurlis absolute and violates the policy.
-
requireHttpScheme
Enforces the SSRF guardrail: whenurlcarries a URI scheme it must behttporhttpswith a nonempty host, and — unlessallowPrivateUrlsis set — must not target a loopback/private/link-local/metadata host (seeRemoteUrlPolicy). 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- Whentrue , the deny-private check is skipped (the http/https scheme requirement still applies).- Returns:
- The unchanged URL.
- Throws:
IllegalArgumentException- Ifurlis absolute and violates the policy.
-
requireHttpScheme
public static String requireHttpScheme(String url, boolean allowPrivateUrls, RemoteUrlPolicy.AllowedRanges allowedRanges) Same asrequireHttpScheme(String, boolean), additionally honoring a client's per-client allowed address ranges.- Parameters:
url- The URL to validate.allowPrivateUrls- Whentrue , the deny-private check is skipped.allowedRanges- The client'sRemoteUrlPolicy.AllowedRanges, unioned with theRestClient.allowAddressRangesproperty.- Returns:
- The unchanged URL.
- Throws:
IllegalArgumentException- Ifurlis absolute and violates the policy.
-
warnUnsupportedMember
Emits a one-time build-time warning that an@Remote/@RemoteOpmember 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.
-