本文整理汇总了Java中org.eclipse.core.net.proxy.IProxyData.getHost方法的典型用法代码示例。如果您正苦于以下问题:Java IProxyData.getHost方法的具体用法?Java IProxyData.getHost怎么用?Java IProxyData.getHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.net.proxy.IProxyData
的用法示例。
在下文中一共展示了IProxyData.getHost方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createProxy
import org.eclipse.core.net.proxy.IProxyData; //导入方法依赖的package包/类
@VisibleForTesting
public Proxy createProxy(URI uri) {
Preconditions.checkNotNull(uri, "uri is null");
Preconditions.checkArgument(!"http".equals(uri.getScheme()), "http is not a supported schema");
IProxyService proxyServiceCopy = proxyService;
if (proxyServiceCopy == null) {
return Proxy.NO_PROXY;
}
IProxyData[] proxyDataForUri = proxyServiceCopy.select(uri);
for (final IProxyData iProxyData : proxyDataForUri) {
switch (iProxyData.getType()) {
case IProxyData.HTTPS_PROXY_TYPE:
return new Proxy(Type.HTTP, new InetSocketAddress(iProxyData.getHost(),
iProxyData.getPort()));
case IProxyData.SOCKS_PROXY_TYPE:
return new Proxy(Type.SOCKS, new InetSocketAddress(iProxyData.getHost(),
iProxyData.getPort()));
default:
logger.warning("Unsupported proxy type: " + iProxyData.getType());
break;
}
}
return Proxy.NO_PROXY;
}
示例2: prepareProxySettings
import org.eclipse.core.net.proxy.IProxyData; //导入方法依赖的package包/类
public void prepareProxySettings(String uriString) {
URI uri;
try {
uri = new URI(uriString);
IProxyService proxyService = Activator.getDefault()
.getProxyService();
IProxyData[] proxyDataForHost = proxyService.select(uri);
for (IProxyData data : proxyDataForHost) {
if (data.getHost() != null) {
System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyHost", data.getHost());
}
if (data.getHost() != null) {
System.setProperty("http.proxyPort",
String.valueOf(data.getPort()));
}
}
// Close the service and close the service tracker
proxyService = null;
} catch (URISyntaxException e) {
getLog().log(
new Status(IStatus.WARNING, PLUGIN_ID, e.getMessage(), e));
}
}
示例3: getProxyConfiguration
import org.eclipse.core.net.proxy.IProxyData; //导入方法依赖的package包/类
protected ProxyConfiguration getProxyConfiguration() {
try {
IProxyData proxyData = CloudServerUtil.getProxy(new URL(cloudServer.getUrl()));
if (proxyData != null) {
String proxyHost = proxyData.getHost();
int proxyPort = proxyData.getPort();
String user = proxyData.getUserId();
String password = proxyData.getPassword();
return ProxyConfiguration.builder().host(proxyHost)
.port(proxyPort == -1 ? Optional.empty() : Optional.of(proxyPort))
.username(Optional.ofNullable(user)).password(Optional.ofNullable(password)).build();
}
} catch (MalformedURLException e) {
CloudFoundryPlugin.logError(e);
}
return null;
}
示例4: proxySettings
import org.eclipse.core.net.proxy.IProxyData; //导入方法依赖的package包/类
/**
* This will return a list of arguments for proxy settings (if we have any, otherwise an empty list).
*
* @param env
* The environment map. Passed in so we can flag passwords to obfuscate (in other words, we may modify
* the map)
*/
private List<String> proxySettings(Map<String, String> env)
{
IProxyService service = JSCorePlugin.getDefault().getProxyService();
if (service == null || !service.isProxiesEnabled())
{
return Collections.emptyList();
}
List<String> proxyArgs = new ArrayList<String>(4);
IProxyData httpData = service.getProxyData(IProxyData.HTTP_PROXY_TYPE);
if (httpData != null && httpData.getHost() != null)
{
CollectionsUtil.addToList(proxyArgs, "--proxy", buildProxyURL(httpData, env)); //$NON-NLS-1$
}
IProxyData httpsData = service.getProxyData(IProxyData.HTTPS_PROXY_TYPE);
if (httpsData != null && httpsData.getHost() != null)
{
CollectionsUtil.addToList(proxyArgs, "--https-proxy", buildProxyURL(httpsData, env)); //$NON-NLS-1$
}
return proxyArgs;
}
示例5: getProxyHost
import org.eclipse.core.net.proxy.IProxyData; //导入方法依赖的package包/类
@Override
public String getProxyHost() {
if (!isProxiesEnabled()) {
return Constants.EMPTY_STRING;
}
IProxyData httpProxyData = getHttpProxyData();
if (httpProxyData != null && Utils.isNotEmpty(httpProxyData.getHost())) {
if (logger.isDebugEnabled()) {
logger.debug("Returning '" + httpProxyData.getHost() + "' as proxy host ");
}
return httpProxyData.getHost();
} else {
return Constants.EMPTY_STRING;
}
}
示例6: getProxy
import org.eclipse.core.net.proxy.IProxyData; //导入方法依赖的package包/类
public static HttpProxyConfiguration getProxy(URL url) {
if (url == null) {
return null;
}
// In certain cases, the activator would have stopped and the plugin may
// no longer be available. Usually onl happens on shutdown.
CloudFoundryPlugin plugin = CloudFoundryPlugin.getDefault();
if (plugin != null) {
IProxyService proxyService = plugin.getProxyService();
if (proxyService != null) {
try {
IProxyData[] selectedProxies = proxyService.select(url.toURI());
// No proxy configured or not found
if (selectedProxies == null || selectedProxies.length == 0) {
return null;
}
IProxyData data = selectedProxies[0];
int proxyPort = data.getPort();
String proxyHost = data.getHost();
String user = data.getUserId();
String password = data.getPassword();
return proxyHost != null ? new HttpProxyConfiguration(proxyHost, proxyPort,
data.isRequiresAuthentication(), user, password) : null;
}
catch (URISyntaxException e) {
// invalid url (protocol, ...) => proxy will be null
}
}
}
return null;
}
示例7: ProxyConfig
import org.eclipse.core.net.proxy.IProxyData; //导入方法依赖的package包/类
public ProxyConfig(IProxyService proxyService, URI uri){
IProxyData[] proxyDataForHost = proxyService.select(uri);
for (IProxyData data : proxyDataForHost) {
if (data.getHost() != null) {
host = data.getHost();
port = data.getPort();
userId = data.getUserId();
password = data.getPassword();
}
}
}
示例8: getProxy
import org.eclipse.core.net.proxy.IProxyData; //导入方法依赖的package包/类
public static HttpProxyConfiguration getProxy(URL url) {
// URL must be set and have a valid protocol in order to determine
// which proxy to use
if (url == null || url.getProtocol() == null) {
return null;
}
// In certain cases, the activator would have stopped and the plugin may
// no longer be available. Usually onl happens on shutdown.
DockerFoundryPlugin plugin = DockerFoundryPlugin.getDefault();
if (plugin != null) {
IProxyService proxyService = plugin.getProxyService();
// Only set proxies IF proxies are enabled (i.e a user has selected
// MANUAL provider configuration in network preferences. If it is
// direct,
// then skip proxy settings.
if (proxyService != null && proxyService.isProxiesEnabled()) {
IProxyData[] existingProxies = proxyService.getProxyData();
if (existingProxies != null) {
// Now determine the protocol to obtain the correct proxy
// type
String normalisedURLProtocol = getNormalisedProtocol(url.getProtocol());
// Resolve the correct proxy data type based on the URL
// protocol
String[] proxyDataTypes = { IProxyData.HTTP_PROXY_TYPE, IProxyData.HTTPS_PROXY_TYPE,
IProxyData.SOCKS_PROXY_TYPE };
String matchedProxyData = null;
for (String proxyDataType : proxyDataTypes) {
String normalised = getNormalisedProtocol(proxyDataType);
if (normalised.equals(normalisedURLProtocol)) {
matchedProxyData = proxyDataType;
break;
}
}
if (matchedProxyData != null) {
for (IProxyData data : existingProxies) {
if (matchedProxyData.equals(data.getType())) {
int proxyPort = data.getPort();
String proxyHost = data.getHost();
String user = data.getUserId();
String password = data.getPassword();
return proxyHost != null ? new HttpProxyConfiguration(proxyHost, proxyPort,
data.isRequiresAuthentication(), user, password) : null;
}
}
}
}
}
}
return null;
}