@NotNull private MantisConnectPortType createSoap() throws Exception { if (isUseProxy()) { for (KeyValue<String, String> pair : HttpConfigurable.getJvmPropertiesList(false, null)) { String key = pair.getKey(), value = pair.getValue(); // Axis uses another names for username and password properties // see http://axis.apache.org/axis/java/client-side-axis.html for complete list if (key.equals(JavaProxyProperty.HTTP_USERNAME)) { AxisProperties.setProperty("http.proxyUser", value); } else if (key.equals(JavaProxyProperty.HTTP_PASSWORD)) { AxisProperties.setProperty("http.proxyPassword", value); } else { AxisProperties.setProperty(key, value); } } } return new MantisConnectLocator().getMantisConnectPort(new URL(getUrl() + SOAP_API_LOCATION)); }
public static List<KeyValue<String, String>> getJvmPropertiesList(final boolean withAutodetection, @Nullable final URI uri) { final HttpConfigurable me = getInstance(); if (! me.USE_HTTP_PROXY && ! me.USE_PROXY_PAC) { return Collections.emptyList(); } final List<KeyValue<String, String>> result = new ArrayList<KeyValue<String, String>>(); if (me.USE_HTTP_PROXY) { final boolean putCredentials = me.KEEP_PROXY_PASSWORD && StringUtil.isNotEmpty(me.PROXY_LOGIN); if (me.PROXY_TYPE_IS_SOCKS) { result.add(KeyValue.create(JavaProxyProperty.SOCKS_HOST, me.PROXY_HOST)); result.add(KeyValue.create(JavaProxyProperty.SOCKS_PORT, String.valueOf(me.PROXY_PORT))); if (putCredentials) { result.add(KeyValue.create(JavaProxyProperty.SOCKS_USERNAME, me.PROXY_LOGIN)); result.add(KeyValue.create(JavaProxyProperty.SOCKS_PASSWORD, me.getPlainProxyPassword())); } } else { result.add(KeyValue.create(JavaProxyProperty.HTTP_HOST, me.PROXY_HOST)); result.add(KeyValue.create(JavaProxyProperty.HTTP_PORT, String.valueOf(me.PROXY_PORT))); result.add(KeyValue.create(JavaProxyProperty.HTTPS_HOST, me.PROXY_HOST)); result.add(KeyValue.create(JavaProxyProperty.HTTPS_PORT, String.valueOf(me.PROXY_PORT))); if (putCredentials) { result.add(KeyValue.create(JavaProxyProperty.HTTP_USERNAME, me.PROXY_LOGIN)); result.add(KeyValue.create(JavaProxyProperty.HTTP_PASSWORD, me.getPlainProxyPassword())); } } } else if (me.USE_PROXY_PAC && withAutodetection && uri != null) { final List<Proxy> proxies = CommonProxy.getInstance().select(uri); // we will just take the first returned proxy, but we have an option to test connection through each of them, // for instance, by calling prepareUrl() if (proxies != null && ! proxies.isEmpty()) { for (Proxy proxy : proxies) { if (isRealProxy(proxy)) { final SocketAddress address = proxy.address(); if (address instanceof InetSocketAddress) { final InetSocketAddress inetSocketAddress = (InetSocketAddress)address; if (Proxy.Type.SOCKS.equals(proxy.type())) { result.add(KeyValue.create(JavaProxyProperty.SOCKS_HOST, inetSocketAddress.getHostName())); result.add(KeyValue.create(JavaProxyProperty.SOCKS_PORT, String.valueOf(inetSocketAddress.getPort()))); } else { result.add(KeyValue.create(JavaProxyProperty.HTTP_HOST, inetSocketAddress.getHostName())); result.add(KeyValue.create(JavaProxyProperty.HTTP_PORT, String.valueOf(inetSocketAddress.getPort()))); result.add(KeyValue.create(JavaProxyProperty.HTTPS_HOST, inetSocketAddress.getHostName())); result.add(KeyValue.create(JavaProxyProperty.HTTPS_PORT, String.valueOf(inetSocketAddress.getPort()))); } } } } } } return result; }
@Nonnull public List<Pair<String, String>> getJvmProperties(boolean withAutodetection, @Nullable URI uri) { if (!USE_HTTP_PROXY && !USE_PROXY_PAC) { return Collections.emptyList(); } List<Pair<String, String>> result = new ArrayList<>(); if (USE_HTTP_PROXY) { boolean putCredentials = KEEP_PROXY_PASSWORD && StringUtil.isNotEmpty(getProxyLogin()); if (PROXY_TYPE_IS_SOCKS) { result.add(Pair.pair(JavaProxyProperty.SOCKS_HOST, PROXY_HOST)); result.add(Pair.pair(JavaProxyProperty.SOCKS_PORT, String.valueOf(PROXY_PORT))); if (putCredentials) { result.add(Pair.pair(JavaProxyProperty.SOCKS_USERNAME, getProxyLogin())); result.add(Pair.pair(JavaProxyProperty.SOCKS_PASSWORD, getPlainProxyPassword())); } } else { result.add(Pair.pair(JavaProxyProperty.HTTP_HOST, PROXY_HOST)); result.add(Pair.pair(JavaProxyProperty.HTTP_PORT, String.valueOf(PROXY_PORT))); result.add(Pair.pair(JavaProxyProperty.HTTPS_HOST, PROXY_HOST)); result.add(Pair.pair(JavaProxyProperty.HTTPS_PORT, String.valueOf(PROXY_PORT))); if (putCredentials) { result.add(Pair.pair(JavaProxyProperty.HTTP_USERNAME, getProxyLogin())); result.add(Pair.pair(JavaProxyProperty.HTTP_PASSWORD, getPlainProxyPassword())); } } } else if (USE_PROXY_PAC && withAutodetection && uri != null) { List<Proxy> proxies = CommonProxy.getInstance().select(uri); // we will just take the first returned proxy, but we have an option to test connection through each of them, // for instance, by calling prepareUrl() if (proxies != null && !proxies.isEmpty()) { for (Proxy proxy : proxies) { if (isRealProxy(proxy)) { SocketAddress address = proxy.address(); if (address instanceof InetSocketAddress) { InetSocketAddress inetSocketAddress = (InetSocketAddress)address; if (Proxy.Type.SOCKS.equals(proxy.type())) { result.add(Pair.pair(JavaProxyProperty.SOCKS_HOST, inetSocketAddress.getHostName())); result.add(Pair.pair(JavaProxyProperty.SOCKS_PORT, String.valueOf(inetSocketAddress.getPort()))); } else { result.add(Pair.pair(JavaProxyProperty.HTTP_HOST, inetSocketAddress.getHostName())); result.add(Pair.pair(JavaProxyProperty.HTTP_PORT, String.valueOf(inetSocketAddress.getPort()))); result.add(Pair.pair(JavaProxyProperty.HTTPS_HOST, inetSocketAddress.getHostName())); result.add(Pair.pair(JavaProxyProperty.HTTPS_PORT, String.valueOf(inetSocketAddress.getPort()))); } } } } } } return result; }