public final class WindowsProxyResolver extends Object
No PowerShell required. Works on hardened systems where PowerShell Constrained Language Mode (CLM) blocks .NET method calls.
AutoConfigURLDefaultConnectionSettings binary blob for an embedded PAC URLhttp://wpad/wpad.dat) if the flag is setProxyOverride bypass list
// Full auto-detection:
ProxyResult result = WindowsProxyResolver.resolve("https://example.com");
// Choose PAC URL source explicitly:
ProxyResult r1 = WindowsProxyResolver.resolve(target, PacUrlSource.DIRECT,
"http://wpad.corp.local/wpad.dat");
ProxyResult r2 = WindowsProxyResolver.resolve(target, PacUrlSource.REGISTRY, null);
ProxyResult r3 = WindowsProxyResolver.resolve(target, PacUrlSource.POWERSHELL, null);
if (result.isDirect()) {
connection = url.openConnection();
} else {
connection = url.openConnection(result.toJavaProxy());
}
ProxyResult,
PacUrlSource| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_PAC_DISCOVERY_SCRIPT
Default PowerShell command to discover the PAC URL from the Windows Registry.
|
static String |
INTERNET_SETTINGS_KEY
The Windows Registry key containing user-level Internet/proxy settings.
|
| Modifier and Type | Method and Description |
|---|---|
static ProxyResult |
evaluatePac(String pacUrl,
String targetUrl)
Evaluates a PAC auto-configuration script from the given URL via GraalJS.
|
static ProxyResult |
evaluatePacScript(String pacScript,
String targetUrl)
Evaluates a PAC script string (not a URL) against the given target URL.
|
static boolean |
isBypassed(String host,
String proxyOverride)
Checks if a host matches the Windows proxy bypass pattern list.
|
static boolean |
isWpadAutoDetectEnabled()
Returns
true if WPAD auto-detect is enabled in connection settings. |
static int |
readConnectionFlags()
Reads the raw connection flags byte.
|
static String |
readRegistryValue(String key,
String valueName)
Reads a single value from the Windows Registry via
reg.exe. |
static String |
readRegistryValueFromAllHives(String valueName)
Searches all four registry hives for the given value name (GPO first).
|
static ProxyResult |
resolve(String url)
Resolves the proxy using the full Windows auto-detection chain (registry-based).
|
static ProxyResult |
resolve(String targetUrl,
PacUrlSource source,
String pacUrlOrScript)
Resolves the proxy using the specified
PacUrlSource strategy. |
static ProxyResult |
resolveStatic(String url)
Resolves using only static registry settings (ProxyEnable + ProxyServer).
|
public static final String INTERNET_SETTINGS_KEY
public static final String DEFAULT_PAC_DISCOVERY_SCRIPT
public static ProxyResult resolve(String url)
resolve(url, PacUrlSource.REGISTRY, null).public static ProxyResult resolve(String targetUrl, PacUrlSource source, String pacUrlOrScript)
PacUrlSource strategy.
This is the primary facade method.targetUrl - the URL to resolve the proxy forsource - how to obtain the PAC URLpacUrlOrScript - PAC URL, PowerShell command, or null (depending on source)ProxyResult — never nullpublic static ProxyResult resolveStatic(String url)
public static ProxyResult evaluatePac(String pacUrl, String targetUrl)
public static ProxyResult evaluatePacScript(String pacScript, String targetUrl)
public static String readRegistryValue(String key, String valueName)
reg.exe.public static String readRegistryValueFromAllHives(String valueName)
public static boolean isBypassed(String host, String proxyOverride)
public static boolean isWpadAutoDetectEnabled()
true if WPAD auto-detect is enabled in connection settings.public static int readConnectionFlags()
Copyright © 2026. All rights reserved.