Java Code Examples for com.amazonaws.ClientConfiguration#setProxyPassword()
The following examples show how to use
com.amazonaws.ClientConfiguration#setProxyPassword() .
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: ProxyConfiguration.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
private static void useJenkinsProxy(ClientConfiguration config) { if (Jenkins.getInstance() != null) { hudson.ProxyConfiguration proxyConfiguration = Jenkins.getInstance().proxy; if (proxyConfiguration != null) { config.setProxyHost(proxyConfiguration.name); config.setProxyPort(proxyConfiguration.port); config.setProxyUsername(proxyConfiguration.getUserName()); config.setProxyPassword(proxyConfiguration.getPassword()); if (proxyConfiguration.noProxyHost != null) { String[] noProxyParts = proxyConfiguration.noProxyHost.split("[ \t\n,|]+"); config.setNonProxyHosts(Joiner.on('|').join(noProxyParts)); } } } }
Example 2
Source File: AmazonWebServiceClientUtil.java From cs-actions with Apache License 2.0 | 6 votes |
public static ClientConfiguration getClientConfiguration(String proxyHost, String proxyPort, String proxyUsername, String proxyPassword, String connectTimeoutMs, String executionTimeoutMs) { ClientConfiguration clientConf = new ClientConfiguration() .withConnectionTimeout(Integer.parseInt(connectTimeoutMs)) .withClientExecutionTimeout(Integer.parseInt(executionTimeoutMs)); if (!StringUtils.isEmpty(proxyHost)) { clientConf.setProxyHost(proxyHost); } if (!StringUtils.isEmpty(proxyPort)) { clientConf.setProxyPort(Integer.parseInt(proxyPort)); } if (!StringUtils.isEmpty(proxyUsername)) { clientConf.setProxyUsername(proxyUsername); } if (!StringUtils.isEmpty(proxyPassword)) { clientConf.setProxyPassword(proxyPassword); } return clientConf; }
Example 3
Source File: AmazonAwsClientFactory.java From primecloud-controller with GNU General Public License v2.0 | 6 votes |
protected ClientConfiguration createConfiguration() { ClientConfiguration configuration = new ClientConfiguration(); // Proxy設定 if (proxyHost != null && proxyPort != null) { configuration.setProxyHost(proxyHost); configuration.setProxyPort(proxyPort); if (proxyUser != null && proxyPassword != null) { configuration.setProxyUsername(proxyUser); configuration.setProxyPassword(proxyPassword); } } // リトライしない configuration.setMaxErrorRetry(0); return configuration; }
Example 4
Source File: AWSClientFactory.java From awseb-deployment-plugin with Apache License 2.0 | 6 votes |
private static AWSClientFactory getClientFactory(AWSCredentialsProvider provider, String awsRegion) { ClientConfiguration clientConfig = new ClientConfiguration(); Jenkins jenkins = Jenkins.get(); if (jenkins.proxy != null) { ProxyConfiguration proxyConfig = jenkins.proxy; clientConfig.setProxyHost(proxyConfig.name); clientConfig.setProxyPort(proxyConfig.port); if (proxyConfig.getUserName() != null) { clientConfig.setProxyUsername(proxyConfig.getUserName()); clientConfig.setProxyPassword(proxyConfig.getPassword()); } } clientConfig.setUserAgentPrefix("ingenieux CloudButler/" + Utils.getVersion()); return new AWSClientFactory(provider, clientConfig, awsRegion); }
Example 5
Source File: S3Accessor.java From datacollector with Apache License 2.0 | 6 votes |
ClientConfiguration createClientConfiguration() throws StageException { ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setConnectionTimeout(connectionConfigs.getConnectionTimeoutMillis()); clientConfig.setSocketTimeout(connectionConfigs.getSocketTimeoutMillis()); clientConfig.withMaxErrorRetry(connectionConfigs.getMaxErrorRetry()); if (connectionConfigs.isProxyEnabled()) { clientConfig.setProxyHost(connectionConfigs.getProxyHost()); clientConfig.setProxyPort(connectionConfigs.getProxyPort()); if (connectionConfigs.isProxyAuthenticationEnabled()) { clientConfig.setProxyUsername(connectionConfigs.getProxyUser().get()); clientConfig.setProxyPassword(connectionConfigs.getProxyPassword().get()); } } return clientConfig; }
Example 6
Source File: AWSUtil.java From datacollector with Apache License 2.0 | 6 votes |
public static ClientConfiguration getClientConfiguration(ProxyConfig config) throws StageException { ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setConnectionTimeout(config.connectionTimeout * MILLIS); clientConfig.setSocketTimeout(config.socketTimeout * MILLIS); clientConfig.withMaxErrorRetry(config.retryCount); // Optional proxy settings if (config.useProxy) { if (config.proxyHost != null && !config.proxyHost.isEmpty()) { clientConfig.setProxyHost(config.proxyHost); clientConfig.setProxyPort(config.proxyPort); if (config.proxyUser != null && !config.proxyUser.get().isEmpty()) { clientConfig.setProxyUsername(config.proxyUser.get()); } if (config.proxyPassword != null) { clientConfig.setProxyPassword(config.proxyPassword.get()); } } } return clientConfig; }
Example 7
Source File: LambdaClientConfig.java From aws-lambda-jenkins-plugin with MIT License | 6 votes |
private ClientConfiguration getClientConfiguration() { /* Jenkins instance = Jenkins.getInstance(); if (instance != null) { ProxyConfiguration proxy = instance.proxy; */ ClientConfiguration config = new ClientConfiguration(); if (proxyConfiguration != null) { config.setProxyHost(proxyConfiguration.name); config.setProxyPort(proxyConfiguration.port); if (proxyConfiguration.getUserName() != null) { config.setProxyUsername(proxyConfiguration.getUserName()); config.setProxyPassword(proxyConfiguration.getPassword()); } if (proxyConfiguration.noProxyHost != null) { config.setNonProxyHosts(proxyConfiguration.noProxyHost); } } return config; }
Example 8
Source File: PropertyBasedS3ClientConfig.java From exhibitor with Apache License 2.0 | 6 votes |
@Override public ClientConfiguration getAWSClientConfig() { ClientConfiguration awsClientConfig = new ClientConfiguration(); awsClientConfig.setProxyHost(proxyHost); awsClientConfig.setProxyPort(proxyPort); if ( proxyUsername != null ) { awsClientConfig.setProxyUsername(proxyUsername); } if ( proxyPassword != null ) { awsClientConfig.setProxyPassword(proxyPassword); } return awsClientConfig; }
Example 9
Source File: AwsModuleTest.java From beam with Apache License 2.0 | 6 votes |
@Test public void testClientConfigurationSerializationDeserialization() throws Exception { ClientConfiguration clientConfiguration = new ClientConfiguration(); clientConfiguration.setProxyHost("localhost"); clientConfiguration.setProxyPort(1234); clientConfiguration.setProxyUsername("username"); clientConfiguration.setProxyPassword("password"); final String valueAsJson = objectMapper.writeValueAsString(clientConfiguration); final ClientConfiguration valueDes = objectMapper.readValue(valueAsJson, ClientConfiguration.class); assertEquals("localhost", valueDes.getProxyHost()); assertEquals(1234, valueDes.getProxyPort()); assertEquals("username", valueDes.getProxyUsername()); assertEquals("password", valueDes.getProxyPassword()); }
Example 10
Source File: ProxyConfiguration.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
private static void configureProxy(ClientConfiguration config, String env, int defaultPort) { Pattern pattern = Pattern.compile(PROXY_PATTERN); Matcher matcher = pattern.matcher(env); if (matcher.matches()) { if (matcher.group(3) != null) { config.setProxyUsername(matcher.group(3)); } if (matcher.group(5) != null) { config.setProxyPassword(matcher.group(5)); } config.setProxyHost(matcher.group(6)); if (matcher.group(8) != null) { config.setProxyPort(Integer.parseInt(matcher.group(8))); } else { config.setProxyPort(defaultPort); } } }
Example 11
Source File: EC2Communication.java From development with Apache License 2.0 | 5 votes |
/** * Return amazon interface * * @return AmazonEC2 client ec2 */ AmazonEC2 getEC2() { if (ec2 == null) { String endpoint = ENDPOINT_PREFIX + ph.getRegion() + ENDPOINT_SUFFIX; String proxyHost = System.getProperty(HTTPS_PROXY_HOST); String proxyPort = System.getProperty(HTTPS_PROXY_PORT); String proxyUser = System.getProperty(HTTPS_PROXY_USER); String proxyPassword = System.getProperty(HTTPS_PROXY_PASSWORD); int proxyPortInt = 0; try { proxyPortInt = Integer.parseInt(proxyPort); } catch (NumberFormatException e) { // ignore } ClientConfiguration clientConfiguration = new ClientConfiguration(); if (!isNonProxySet(endpoint)) { if (proxyHost != null) { clientConfiguration.setProxyHost(proxyHost); } if (proxyPortInt > 0) { clientConfiguration.setProxyPort(proxyPortInt); } if (proxyUser != null && proxyUser.length() > 0) { clientConfiguration.setProxyUsername(proxyUser); } if (proxyPassword != null && proxyPassword.length() > 0) { clientConfiguration.setProxyPassword(proxyPassword); } } ec2 = getEC2(credentialsProvider, clientConfiguration); ec2.setEndpoint(endpoint); } return ec2; }
Example 12
Source File: Aws.java From digdag with Apache License 2.0 | 5 votes |
static void configureProxy(ClientConfiguration configuration, ProxyConfig proxyConfig) { configuration.setProxyHost(proxyConfig.getHost()); configuration.setProxyPort(proxyConfig.getPort()); Optional<String> user = proxyConfig.getUser(); if (user.isPresent()) { configuration.setProxyUsername(user.get()); } Optional<String> password = proxyConfig.getPassword(); if (password.isPresent()) { configuration.setProxyPassword(password.get()); } }
Example 13
Source File: ECSService.java From amazon-ecs-plugin with MIT License | 5 votes |
public ECSService(String credentialsId, String regionName) { this.clientSupplier = () -> { ProxyConfiguration proxy = Jenkins.get().proxy; ClientConfiguration clientConfiguration = new ClientConfiguration(); if (proxy != null) { clientConfiguration.setProxyHost(proxy.name); clientConfiguration.setProxyPort(proxy.port); clientConfiguration.setProxyUsername(proxy.getUserName()); clientConfiguration.setProxyPassword(proxy.getPassword()); } // Default is 3. 10 helps us actually utilize the SDK's backoff strategy // The strategy will wait up to 20 seconds per request (after multiple failures) clientConfiguration.setMaxErrorRetry(10); AmazonECSClientBuilder builder = AmazonECSClientBuilder .standard() .withClientConfiguration(clientConfiguration) .withRegion(regionName); AmazonWebServicesCredentials credentials = getCredentials(credentialsId); if (credentials != null) { if (LOGGER.isLoggable(Level.FINE)) { String awsAccessKeyId = credentials.getCredentials().getAWSAccessKeyId(); String obfuscatedAccessKeyId = StringUtils.left(awsAccessKeyId, 4) + StringUtils.repeat("*", awsAccessKeyId.length() - (2 * 4)) + StringUtils.right(awsAccessKeyId, 4); LOGGER.log(Level.FINE, "Connect to Amazon ECS with IAM Access Key {1}", new Object[]{obfuscatedAccessKeyId}); } builder .withCredentials(credentials); } LOGGER.log(Level.FINE, "Selected Region: {0}", regionName); return builder.build(); }; }
Example 14
Source File: DynamoDBClient.java From emr-dynamodb-connector with Apache License 2.0 | 5 votes |
@VisibleForTesting void applyProxyConfiguration(ClientConfiguration clientConfig, Configuration conf) { final String proxyHost = conf.get(DynamoDBConstants.PROXY_HOST); final int proxyPort = conf.getInt(DynamoDBConstants.PROXY_PORT, 0); final String proxyUsername = conf.get(DynamoDBConstants.PROXY_USERNAME); final String proxyPassword = conf.get(DynamoDBConstants.PROXY_PASSWORD); boolean proxyHostAndPortPresent = false; if (!Strings.isNullOrEmpty(proxyHost) && proxyPort > 0) { clientConfig.setProxyHost(proxyHost); clientConfig.setProxyPort(proxyPort); proxyHostAndPortPresent = true; } else if (Strings.isNullOrEmpty(proxyHost) ^ proxyPort <= 0) { throw new RuntimeException("Only one of proxy host and port are set, when both are required"); } if (!Strings.isNullOrEmpty(proxyUsername) && !Strings.isNullOrEmpty(proxyPassword)) { if (!proxyHostAndPortPresent) { throw new RuntimeException("Proxy host and port must be supplied if proxy username and " + "password are present"); } else { clientConfig.setProxyUsername(proxyUsername); clientConfig.setProxyPassword(proxyPassword); } } else if (Strings.isNullOrEmpty(proxyUsername) ^ Strings.isNullOrEmpty(proxyPassword)) { throw new RuntimeException("Only one of proxy username and password are set, when both are " + "required"); } }
Example 15
Source File: HttpUtil.java From snowflake-jdbc with Apache License 2.0 | 5 votes |
public static void setProxyForS3(ClientConfiguration clientConfig) { if (useProxy) { clientConfig.setProxyHost(proxyHost); clientConfig.setProxyPort(proxyPort); clientConfig.setNonProxyHosts(nonProxyHosts); if (!Strings.isNullOrEmpty(proxyUser) && !Strings.isNullOrEmpty(proxyPassword)) { clientConfig.setProxyUsername(proxyUser); clientConfig.setProxyPassword(proxyPassword); } } }
Example 16
Source File: KinesisAppender.java From kinesis-log4j-appender with Apache License 2.0 | 5 votes |
/** * Set proxy configuration based on system properties. Some of the properties are standard * properties documented by Oracle (http.proxyHost, http.proxyPort, http.auth.ntlm.domain), * and others are from common convention (http.proxyUser, http.proxyPassword). * * Finally, for NTLM authentication the workstation name is taken from the environment as * COMPUTERNAME. We set this on the client configuration only if the NTLM domain was specified. */ private ClientConfiguration setProxySettingsFromSystemProperties(ClientConfiguration clientConfiguration) { final String proxyHost = System.getProperty("http.proxyHost"); if(proxyHost != null) { clientConfiguration.setProxyHost(proxyHost); } final String proxyPort = System.getProperty("http.proxyPort"); if(proxyPort != null) { clientConfiguration.setProxyPort(Integer.parseInt(proxyPort)); } final String proxyUser = System.getProperty("http.proxyUser"); if(proxyUser != null) { clientConfiguration.setProxyUsername(proxyUser); } final String proxyPassword = System.getProperty("http.proxyPassword"); if(proxyPassword != null) { clientConfiguration.setProxyPassword(proxyPassword); } final String proxyDomain = System.getProperty("http.auth.ntlm.domain"); if(proxyDomain != null) { clientConfiguration.setProxyDomain(proxyDomain); } final String workstation = System.getenv("COMPUTERNAME"); if(proxyDomain != null && workstation != null) { clientConfiguration.setProxyWorkstation(workstation); } return clientConfiguration; }
Example 17
Source File: ClientHelper.java From jobcacher-plugin with MIT License | 5 votes |
public static ClientConfiguration getClientConfiguration(ProxyConfiguration proxy) { final ClientConfiguration clientConfiguration = new ClientConfiguration(); if (shouldUseProxy(proxy, "s3.amazonaws.com")) { clientConfiguration.setProxyHost(proxy.name); clientConfiguration.setProxyPort(proxy.port); if (proxy.getUserName() != null) { clientConfiguration.setProxyUsername(proxy.getUserName()); clientConfiguration.setProxyPassword(proxy.getPassword()); } } return clientConfiguration; }
Example 18
Source File: AwsEc2ServiceImpl.java From crate with Apache License 2.0 | 5 votes |
static ClientConfiguration buildConfiguration(Logger logger, Ec2ClientSettings clientSettings) { final ClientConfiguration clientConfiguration = new ClientConfiguration(); // the response metadata cache is only there for diagnostics purposes, // but can force objects from every response to the old generation. clientConfiguration.setResponseMetadataCacheSize(0); clientConfiguration.setProtocol(clientSettings.protocol); if (Strings.hasText(clientSettings.proxyHost)) { // TODO: remove this leniency, these settings should exist together and be validated clientConfiguration.setProxyHost(clientSettings.proxyHost); clientConfiguration.setProxyPort(clientSettings.proxyPort); clientConfiguration.setProxyUsername(clientSettings.proxyUsername); clientConfiguration.setProxyPassword(clientSettings.proxyPassword); } // Increase the number of retries in case of 5xx API responses final Random rand = Randomness.get(); final RetryPolicy retryPolicy = new RetryPolicy( RetryPolicy.RetryCondition.NO_RETRY_CONDITION, (originalRequest, exception, retriesAttempted) -> { // with 10 retries the max delay time is 320s/320000ms (10 * 2^5 * 1 * 1000) logger.warn("EC2 API request failed, retry again. Reason was:", exception); return 1000L * (long) (10d * Math.pow(2, retriesAttempted / 2.0d) * (1.0d + rand.nextDouble())); }, 10, false); clientConfiguration.setRetryPolicy(retryPolicy); clientConfiguration.setSocketTimeout(clientSettings.readTimeoutMillis); return clientConfiguration; }
Example 19
Source File: AwsClientConfiguration.java From s3-cf-service-broker with Apache License 2.0 | 5 votes |
public ClientConfiguration toClientConfiguration(){ ClientConfiguration clientConfiguration = new ClientConfiguration(); clientConfiguration.setProxyHost(proxyHost); if(proxyPort != null) { clientConfiguration.setProxyPort(Integer.parseInt(proxyPort)); } clientConfiguration.setProxyUsername(proxyUsername); clientConfiguration.setProxyPassword(proxyPassword); if(preemptiveBasicProxyAuth != null) { clientConfiguration.setPreemptiveBasicProxyAuth(preemptiveBasicProxyAuth); } return clientConfiguration; }
Example 20
Source File: AbstractAWSProcessor.java From nifi with Apache License 2.0 | 4 votes |
protected ClientConfiguration createConfiguration(final ProcessContext context) { final ClientConfiguration config = new ClientConfiguration(); config.setMaxConnections(context.getMaxConcurrentTasks()); config.setMaxErrorRetry(0); config.setUserAgent(DEFAULT_USER_AGENT); // If this is changed to be a property, ensure other uses are also changed config.setProtocol(DEFAULT_PROTOCOL); final int commsTimeout = context.getProperty(TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue(); config.setConnectionTimeout(commsTimeout); config.setSocketTimeout(commsTimeout); if(this.getSupportedPropertyDescriptors().contains(SSL_CONTEXT_SERVICE)) { final SSLContextService sslContextService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class); if (sslContextService != null) { final SSLContext sslContext = sslContextService.createSSLContext(SslContextFactory.ClientAuth.NONE); // NIFI-3788: Changed hostnameVerifier from null to DHV (BrowserCompatibleHostnameVerifier is deprecated) SdkTLSSocketFactory sdkTLSSocketFactory = new SdkTLSSocketFactory(sslContext, new DefaultHostnameVerifier()); config.getApacheHttpClientConfig().setSslSocketFactory(sdkTLSSocketFactory); } } final ProxyConfiguration proxyConfig = ProxyConfiguration.getConfiguration(context, () -> { if (context.getProperty(PROXY_HOST).isSet()) { final ProxyConfiguration componentProxyConfig = new ProxyConfiguration(); String proxyHost = context.getProperty(PROXY_HOST).evaluateAttributeExpressions().getValue(); Integer proxyPort = context.getProperty(PROXY_HOST_PORT).evaluateAttributeExpressions().asInteger(); String proxyUsername = context.getProperty(PROXY_USERNAME).evaluateAttributeExpressions().getValue(); String proxyPassword = context.getProperty(PROXY_PASSWORD).evaluateAttributeExpressions().getValue(); componentProxyConfig.setProxyType(Proxy.Type.HTTP); componentProxyConfig.setProxyServerHost(proxyHost); componentProxyConfig.setProxyServerPort(proxyPort); componentProxyConfig.setProxyUserName(proxyUsername); componentProxyConfig.setProxyUserPassword(proxyPassword); return componentProxyConfig; } return ProxyConfiguration.DIRECT_CONFIGURATION; }); if (Proxy.Type.HTTP.equals(proxyConfig.getProxyType())) { config.setProxyHost(proxyConfig.getProxyServerHost()); config.setProxyPort(proxyConfig.getProxyServerPort()); if (proxyConfig.hasCredential()) { config.setProxyUsername(proxyConfig.getProxyUserName()); config.setProxyPassword(proxyConfig.getProxyUserPassword()); } } return config; }