| 124 | } |
| 125 | |
| 126 | public Map<String, Object> toJson() { |
| 127 | Map<String, Object> m = new HashMap<>(); |
| 128 | |
| 129 | if (proxyType != ProxyType.UNSPECIFIED) { |
| 130 | m.put(PROXY_TYPE, proxyType.toString()); |
| 131 | } |
| 132 | if (httpProxy != null) { |
| 133 | m.put(HTTP_PROXY, httpProxy); |
| 134 | } |
| 135 | if (noProxy != null) { |
| 136 | m.put(NO_PROXY, List.of(noProxy.split(",\\s*"))); |
| 137 | } |
| 138 | if (sslProxy != null) { |
| 139 | m.put(SSL_PROXY, sslProxy); |
| 140 | } |
| 141 | if (socksProxy != null) { |
| 142 | m.put(SOCKS_PROXY, socksProxy); |
| 143 | } |
| 144 | if (socksVersion != null) { |
| 145 | m.put(SOCKS_VERSION, socksVersion); |
| 146 | } |
| 147 | if (socksUsername != null) { |
| 148 | m.put(SOCKS_USERNAME, socksUsername); |
| 149 | } |
| 150 | if (socksPassword != null) { |
| 151 | m.put(SOCKS_PASSWORD, socksPassword); |
| 152 | } |
| 153 | if (proxyAutoconfigUrl != null) { |
| 154 | m.put(PROXY_AUTOCONFIG_URL, proxyAutoconfigUrl); |
| 155 | } |
| 156 | if (autodetect) { |
| 157 | m.put(AUTODETECT, true); |
| 158 | } |
| 159 | return m; |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * Gets the {@link ProxyType}. This can signal if set to use a direct connection (without proxy), |