use of software.amazon.awssdk.crt.http.HttpProxyOptions in project aws-sdk-java-v2 by aws.
the class AwsCrtAsyncHttpClient method buildProxyOptions.
private HttpProxyOptions buildProxyOptions(ProxyConfiguration proxyConfiguration) {
if (proxyConfiguration == null) {
return null;
}
HttpProxyOptions clientProxyOptions = new HttpProxyOptions();
clientProxyOptions.setHost(proxyConfiguration.host());
clientProxyOptions.setPort(proxyConfiguration.port());
if ("https".equalsIgnoreCase(proxyConfiguration.scheme())) {
clientProxyOptions.setTlsContext(tlsContext);
}
if (proxyConfiguration.username() != null && proxyConfiguration.password() != null) {
clientProxyOptions.setAuthorizationUsername(proxyConfiguration.username());
clientProxyOptions.setAuthorizationPassword(proxyConfiguration.password());
clientProxyOptions.setAuthorizationType(HttpProxyOptions.HttpProxyAuthorizationType.Basic);
} else {
clientProxyOptions.setAuthorizationType(HttpProxyOptions.HttpProxyAuthorizationType.None);
}
return clientProxyOptions;
}
use of software.amazon.awssdk.crt.http.HttpProxyOptions in project aws-crt-java by awslabs.
the class ProxyTest method buildProxiedConnectionManager.
private HttpClientConnectionManager buildProxiedConnectionManager(ProxyTestType testType, ProxyAuthType authType) {
try (EventLoopGroup eventLoopGroup = new EventLoopGroup(1);
HostResolver resolver = new HostResolver(eventLoopGroup);
ClientBootstrap bootstrap = new ClientBootstrap(eventLoopGroup, resolver);
SocketOptions sockOpts = new SocketOptions();
TlsContext tlsContext = createHttpClientTlsContext();
TlsContext proxyTlsContext = createProxyTlsContext(testType)) {
HttpProxyOptions proxyOptions = buildProxyOptions(testType, authType, proxyTlsContext);
HttpClientConnectionManagerOptions options = new HttpClientConnectionManagerOptions();
options.withClientBootstrap(bootstrap).withSocketOptions(sockOpts).withTlsContext(tlsContext).withUri(getUriForTest(testType)).withMaxConnections(1).withProxyOptions(proxyOptions);
return HttpClientConnectionManager.create(options);
}
}
use of software.amazon.awssdk.crt.http.HttpProxyOptions in project aws-crt-java by awslabs.
the class ProxyTest method buildProxyOptions.
private HttpProxyOptions buildProxyOptions(ProxyTestType testType, ProxyAuthType authType, TlsContext proxyTlsContext) {
HttpProxyOptions proxyOptions = new HttpProxyOptions();
proxyOptions.setHost(getProxyHostForTest(testType, authType));
proxyOptions.setPort(getProxyPortForTest(testType, authType));
proxyOptions.setConnectionType(getProxyConnectionTypeForTest(testType));
proxyOptions.setTlsContext(proxyTlsContext);
if (authType == ProxyAuthType.Basic) {
proxyOptions.setAuthorizationType(HttpProxyOptions.HttpProxyAuthorizationType.Basic);
proxyOptions.setAuthorizationUsername(HTTP_PROXY_BASIC_AUTH_USERNAME);
proxyOptions.setAuthorizationPassword(HTTP_PROXY_BASIC_AUTH_PASSWORD);
}
return proxyOptions;
}
use of software.amazon.awssdk.crt.http.HttpProxyOptions in project aws-iot-device-sdk-java-v2 by aws.
the class CommandLineOption method buildWebsocketX509MQTTConnection.
public MqttClientConnection buildWebsocketX509MQTTConnection(MqttClientConnectionEvents callbacks) {
try {
AwsIotMqttConnectionBuilder builder = AwsIotMqttConnectionBuilder.newMtlsBuilderFromPath(null, null);
buildConnectionSetupCAFileDefaults(builder);
buildConnectionSetupConnectionDefaults(builder, callbacks);
HttpProxyOptions proxyOptions = null;
int proxyPort = Integer.parseInt(getCommandOrDefault(m_cmd_proxy_port, "0"));
if (hasCommand(m_cmd_proxy_host) && proxyPort > 0) {
proxyOptions = new HttpProxyOptions();
proxyOptions.setHost(getCommand(m_cmd_proxy_host));
proxyOptions.setPort(proxyPort);
builder.withHttpProxyOptions(proxyOptions);
}
builder.withWebsockets(true);
builder.withWebsocketSigningRegion(getCommandRequired(m_cmd_signing_region, ""));
TlsContextOptions x509TlsOptions = TlsContextOptions.createWithMtlsFromPath(getCommandRequired(m_cmd_x509_cert_file, ""), getCommandRequired(m_cmd_x509_key_file, ""));
if (hasCommand(m_cmd_x509_ca_file)) {
x509TlsOptions.withCertificateAuthorityFromPath(null, getCommand(m_cmd_x509_ca_file));
}
ClientTlsContext x509TlsContext = new ClientTlsContext(x509TlsOptions);
X509CredentialsProvider.X509CredentialsProviderBuilder x509builder = new X509CredentialsProvider.X509CredentialsProviderBuilder().withTlsContext(x509TlsContext).withEndpoint(getCommandRequired(m_cmd_x509_endpoint, "")).withRoleAlias(getCommandRequired(m_cmd_x509_role, "")).withThingName(getCommandRequired(m_cmd_x509_thing_name, "")).withProxyOptions(proxyOptions);
X509CredentialsProvider provider = x509builder.build();
builder.withWebsocketCredentialsProvider(provider);
return builder.build();
} catch (CrtRuntimeException ex) {
return null;
}
}
use of software.amazon.awssdk.crt.http.HttpProxyOptions in project aws-iot-device-sdk-java-v2 by aws.
the class CommandLineOption method buildConnectionSetupProxyDefaults.
private void buildConnectionSetupProxyDefaults(AwsIotMqttConnectionBuilder builder) {
int proxyPort = Integer.parseInt(getCommandOrDefault(m_cmd_proxy_port, "0"));
if (hasCommand(m_cmd_proxy_host) && proxyPort > 0) {
HttpProxyOptions proxyOptions = new HttpProxyOptions();
proxyOptions.setHost(getCommand(m_cmd_proxy_host));
proxyOptions.setPort(proxyPort);
builder.withHttpProxyOptions(proxyOptions);
}
}
Aggregations