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