org.cloudfoundry.reactor.ProxyConfiguration Java Examples

The following examples show how to use org.cloudfoundry.reactor.ProxyConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReactiveCFAccessorImpl.java    From promregator with Apache License 2.0 6 votes vote down vote up
private DefaultConnectionContext connectionContext(ProxyConfiguration proxyConfiguration) throws ConfigurationException {
	if (apiHost != null && PATTERN_HTTP_BASED_PROTOCOL_PREFIX.matcher(apiHost).find()) {
		throw new ConfigurationException("cf.api_host configuration parameter must not contain an http(s)://-like prefix; specify the hostname only instead");
	}

	Builder connctx = DefaultConnectionContext.builder()
			.apiHost(apiHost)
			.skipSslValidation(skipSSLValidation);
	
	if (proxyConfiguration != null) {
		connctx = connctx.proxyConfiguration(proxyConfiguration);
	}
	
	if (this.connectionPoolSize != null) {
		connctx = connctx.connectionPoolSize(this.connectionPoolSize);
	}
	
	if (this.threadPoolSize != null) {
		connctx = connctx.threadPoolSize(this.threadPoolSize);
	}
	
	return connctx.build();
}
 
Example #2
Source File: AbstractCfTask.java    From ya-cf-app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
protected Optional<ProxyConfiguration> tryGetProxyConfiguration(CfProperties cfAppProperties) {
    final CfProxySettingsDetail proxySettings = cfAppProperties.cfProxySettings();
    if (proxySettings == null) {
        return Optional.empty();
    }
    if (proxySettings.proxyHost() == null || proxySettings.proxyPort() == null) {
        throw new IllegalStateException("At least host and port for proxy settings must be provided");
    }
    return Optional.of(ProxyConfiguration.builder()
        .host(proxySettings.proxyHost())
        .port(proxySettings.proxyPort())
        .username(Optional.ofNullable(proxySettings.proxyUser()))
        .password(Optional.ofNullable(proxySettings.proxyPassword()))
        .build());
}
 
Example #3
Source File: CloudFoundryTargetProperties.java    From spring-cloud-app-broker with Apache License 2.0 4 votes vote down vote up
public ProxyConfiguration getProxyConfiguration() {
	return null;
}
 
Example #4
Source File: CloudFoundryProperties.java    From spring-cloud-app-broker with Apache License 2.0 4 votes vote down vote up
public ProxyConfiguration getProxyConfiguration() {
	return null;
}
 
Example #5
Source File: ReactiveCFAccessorImpl.java    From promregator with Apache License 2.0 4 votes vote down vote up
private ProxyConfiguration proxyConfiguration() throws ConfigurationException {
	
	String effectiveProxyHost;
	int effectiveProxyPort;
	
	if (this.proxyHost != null && this.proxyPort != 0) {
		// used the new way of defining proxies
		effectiveProxyHost = this.proxyHost;
		effectiveProxyPort = this.proxyPort;
	} else {
		// the old way *may* be used
		effectiveProxyHost = this.proxyHostDeprecated;
		effectiveProxyPort = this.proxyPortDeprecated;
	}
	
	if (effectiveProxyHost != null && PATTERN_HTTP_BASED_PROTOCOL_PREFIX.matcher(effectiveProxyHost).find()) {
		throw new ConfigurationException("Configuring of cf.proxyHost or cf.proxy.host configuration parameter must not contain an http(s)://-like prefix; specify the hostname only instead");
	}
	
	if (effectiveProxyHost != null && effectiveProxyPort != 0) {
		
		String proxyIP = null;
		if (!InetAddressUtils.isIPv4Address(effectiveProxyHost) && !InetAddressUtils.isIPv6Address(effectiveProxyHost)) {
			/*
			 * NB: There is currently a bug in io.netty.util.internal.SocketUtils.connect()
			 * which is called implicitly by the CF API Client library, which leads to the effect
			 * that a hostname for the proxy isn't resolved. Thus, it is only possible to pass 
			 * IP addresses as proxy names.
			 * To work around this issue, we manually perform a resolution of the hostname here
			 * and then feed that one to the CF API Client library...
			 */
			try {
				InetAddress ia = InetAddress.getByName(effectiveProxyHost);
				proxyIP = ia.getHostAddress();
			} catch (UnknownHostException e) {
				throw new ConfigurationException(String.format("The proxy host '%s' cannot be resolved to an IP address; is there a typo in your configuration?", effectiveProxyHost), e);
			}
		} else {
			// the address specified is already an IP address
			proxyIP = effectiveProxyHost;
		}
		
		return ProxyConfiguration.builder().host(proxyIP).port(effectiveProxyPort).build();
		
	} else {
		return null;
	}
}