List of usage examples for com.amazonaws ClientConfiguration setProxyUsername
public void setProxyUsername(String proxyUsername)
From source file:br.com.ingenieux.mojo.aws.AbstractAWSMojo.java
License:Apache License
protected ClientConfiguration getClientConfiguration() { ClientConfiguration clientConfiguration = new ClientConfiguration().withUserAgent(getUserAgent()); if (null != this.settings && null != settings.getActiveProxy()) { Proxy proxy = settings.getActiveProxy(); clientConfiguration.setProxyHost(proxy.getHost()); clientConfiguration.setProxyUsername(proxy.getUsername()); clientConfiguration.setProxyPassword(proxy.getPassword()); clientConfiguration.setProxyPort(proxy.getPort()); }//from w ww . j a va 2 s .c o m return clientConfiguration; }
From source file:com.att.aro.ui.view.menu.tools.ProxySettingDialog.java
License:Apache License
public void setClientConfiguration(ClientConfiguration config) { config.setProxyHost(getTxpHost().getText()); config.setProxyPort(Integer.parseInt(getTxpPort().getText())); config.setProxyUsername(getTxpUserName().getText()); config.setProxyPassword(Arrays.toString(getTxpPwd().getPassword())); parent.setProxySetting(config);/*from w w w . j a v a2 s . c o m*/ }
From source file:com.cloudbees.jenkins.plugins.amazonecs.ECSService.java
License:Open Source License
AmazonECSClient getAmazonECSClient() { final AmazonECSClient client; ProxyConfiguration proxy = Jenkins.getInstance().proxy; ClientConfiguration clientConfiguration = new ClientConfiguration(); if (proxy != null) { clientConfiguration.setProxyHost(proxy.name); clientConfiguration.setProxyPort(proxy.port); clientConfiguration.setProxyUsername(proxy.getUserName()); clientConfiguration.setProxyPassword(proxy.getPassword()); }/*from w w w .j a va 2s .c o m*/ AmazonWebServicesCredentials credentials = getCredentials(credentialsId); if (credentials == null) { // no credentials provided, rely on com.amazonaws.auth.DefaultAWSCredentialsProviderChain // to use IAM Role define at the EC2 instance level ... client = new AmazonECSClient(clientConfiguration); } else { 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 }); } client = new AmazonECSClient(credentials, clientConfiguration); } client.setRegion(getRegion(regionName)); LOGGER.log(Level.FINE, "Selected Region: {0}", regionName); return client; }
From source file:com.ibm.stocator.fs.cos.COSAPIClient.java
License:Apache License
@Override public void initiate(String scheme) throws IOException, ConfigurationParseException { mCachedSparkOriginated = new HashMap<String, Boolean>(); mCachedSparkJobsStatus = new HashMap<String, Boolean>(); schemaProvided = scheme;//from w w w . j a v a 2 s.co m Properties props = ConfigurationHandler.initialize(filesystemURI, conf, scheme); // Set bucket name property int cacheSize = conf.getInt(CACHE_SIZE, GUAVA_CACHE_SIZE_DEFAULT); memoryCache = MemoryCache.getInstance(cacheSize); mBucket = props.getProperty(COS_BUCKET_PROPERTY); workingDir = new Path("/user", System.getProperty("user.name")).makeQualified(filesystemURI, getWorkingDirectory()); fModeAutomaticDelete = "true".equals(props.getProperty(FMODE_AUTOMATIC_DELETE_COS_PROPERTY, "false")); mIsV2Signer = "true".equals(props.getProperty(V2_SIGNER_TYPE_COS_PROPERTY, "false")); // Define COS client String accessKey = props.getProperty(ACCESS_KEY_COS_PROPERTY); String secretKey = props.getProperty(SECRET_KEY_COS_PROPERTY); if (accessKey == null) { throw new ConfigurationParseException("Access KEY is empty. Please provide valid access key"); } if (secretKey == null) { throw new ConfigurationParseException("Secret KEY is empty. Please provide valid secret key"); } BasicAWSCredentials creds = new BasicAWSCredentials(accessKey, secretKey); ClientConfiguration clientConf = new ClientConfiguration(); int maxThreads = Utils.getInt(conf, FS_COS, FS_ALT_KEYS, MAX_THREADS, DEFAULT_MAX_THREADS); if (maxThreads < 2) { LOG.warn(MAX_THREADS + " must be at least 2: forcing to 2."); maxThreads = 2; } int totalTasks = Utils.getInt(conf, FS_COS, FS_ALT_KEYS, MAX_TOTAL_TASKS, DEFAULT_MAX_TOTAL_TASKS); long keepAliveTime = Utils.getLong(conf, FS_COS, FS_ALT_KEYS, KEEPALIVE_TIME, DEFAULT_KEEPALIVE_TIME); threadPoolExecutor = BlockingThreadPoolExecutorService.newInstance(maxThreads, maxThreads + totalTasks, keepAliveTime, TimeUnit.SECONDS, "s3a-transfer-shared"); unboundedThreadPool = new ThreadPoolExecutor(maxThreads, Integer.MAX_VALUE, keepAliveTime, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), BlockingThreadPoolExecutorService.newDaemonThreadFactory("s3a-transfer-unbounded")); boolean secureConnections = Utils.getBoolean(conf, FS_COS, FS_ALT_KEYS, SECURE_CONNECTIONS, DEFAULT_SECURE_CONNECTIONS); clientConf.setProtocol(secureConnections ? Protocol.HTTPS : Protocol.HTTP); String proxyHost = Utils.getTrimmed(conf, FS_COS, FS_ALT_KEYS, PROXY_HOST, ""); int proxyPort = Utils.getInt(conf, FS_COS, FS_ALT_KEYS, PROXY_PORT, -1); if (!proxyHost.isEmpty()) { clientConf.setProxyHost(proxyHost); if (proxyPort >= 0) { clientConf.setProxyPort(proxyPort); } else { if (secureConnections) { LOG.warn("Proxy host set without port. Using HTTPS default 443"); clientConf.setProxyPort(443); } else { LOG.warn("Proxy host set without port. Using HTTP default 80"); clientConf.setProxyPort(80); } } String proxyUsername = Utils.getTrimmed(conf, FS_COS, FS_ALT_KEYS, PROXY_USERNAME); String proxyPassword = Utils.getTrimmed(conf, FS_COS, FS_ALT_KEYS, PROXY_PASSWORD); if ((proxyUsername == null) != (proxyPassword == null)) { String msg = "Proxy error: " + PROXY_USERNAME + " or " + PROXY_PASSWORD + " set without the other."; LOG.error(msg); throw new IllegalArgumentException(msg); } clientConf.setProxyUsername(proxyUsername); clientConf.setProxyPassword(proxyPassword); clientConf.setProxyDomain(Utils.getTrimmed(conf, FS_COS, FS_ALT_KEYS, PROXY_DOMAIN)); clientConf.setProxyWorkstation(Utils.getTrimmed(conf, FS_COS, FS_ALT_KEYS, PROXY_WORKSTATION)); if (LOG.isDebugEnabled()) { LOG.debug( "Using proxy server {}:{} as user {} with password {} on " + "domain {} as workstation {}", clientConf.getProxyHost(), clientConf.getProxyPort(), String.valueOf(clientConf.getProxyUsername()), clientConf.getProxyPassword(), clientConf.getProxyDomain(), clientConf.getProxyWorkstation()); } } else if (proxyPort >= 0) { String msg = "Proxy error: " + PROXY_PORT + " set without " + PROXY_HOST; LOG.error(msg); throw new IllegalArgumentException(msg); } initConnectionSettings(conf, clientConf); if (mIsV2Signer) { clientConf.withSignerOverride("S3SignerType"); } mClient = new AmazonS3Client(creds, clientConf); final String serviceUrl = props.getProperty(ENDPOINT_URL_COS_PROPERTY); if (serviceUrl != null && !serviceUrl.equals(amazonDefaultEndpoint)) { mClient.setEndpoint(serviceUrl); } mClient.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(true).build()); // Set block size property String mBlockSizeString = props.getProperty(BLOCK_SIZE_COS_PROPERTY, "128"); mBlockSize = Long.valueOf(mBlockSizeString).longValue() * 1024 * 1024L; boolean autoCreateBucket = "true" .equalsIgnoreCase((props.getProperty(AUTO_BUCKET_CREATE_COS_PROPERTY, "false"))); partSize = Utils.getLong(conf, FS_COS, FS_ALT_KEYS, MULTIPART_SIZE, DEFAULT_MULTIPART_SIZE); multiPartThreshold = Utils.getLong(conf, FS_COS, FS_ALT_KEYS, MIN_MULTIPART_THRESHOLD, DEFAULT_MIN_MULTIPART_THRESHOLD); readAhead = Utils.getLong(conf, FS_COS, FS_ALT_KEYS, READAHEAD_RANGE, DEFAULT_READAHEAD_RANGE); LOG.debug(READAHEAD_RANGE + ":" + readAhead); inputPolicy = COSInputPolicy .getPolicy(Utils.getTrimmed(conf, FS_COS, FS_ALT_KEYS, INPUT_FADVISE, INPUT_FADV_NORMAL)); initTransferManager(); maxKeys = Utils.getInt(conf, FS_COS, FS_ALT_KEYS, MAX_PAGING_KEYS, DEFAULT_MAX_PAGING_KEYS); flatListingFlag = Utils.getBoolean(conf, FS_COS, FS_ALT_KEYS, FLAT_LISTING, DEFAULT_FLAT_LISTING); if (autoCreateBucket) { try { boolean bucketExist = mClient.doesBucketExist(mBucket); if (bucketExist) { LOG.trace("Bucket {} exists", mBucket); } else { LOG.trace("Bucket {} doesn`t exists and autocreate", mBucket); String mRegion = props.getProperty(REGION_COS_PROPERTY); if (mRegion == null) { mClient.createBucket(mBucket); } else { LOG.trace("Creating bucket {} in region {}", mBucket, mRegion); mClient.createBucket(mBucket, mRegion); } } } catch (AmazonServiceException ase) { /* * we ignore the BucketAlreadyExists exception since multiple processes or threads * might try to create the bucket in parrallel, therefore it is expected that * some will fail to create the bucket */ if (!ase.getErrorCode().equals("BucketAlreadyExists")) { LOG.error(ase.getMessage()); throw (ase); } } catch (Exception e) { LOG.error(e.getMessage()); throw (e); } } initMultipartUploads(conf); enableMultiObjectsDelete = Utils.getBoolean(conf, FS_COS, FS_ALT_KEYS, ENABLE_MULTI_DELETE, true); blockUploadEnabled = Utils.getBoolean(conf, FS_COS, FS_ALT_KEYS, FAST_UPLOAD, DEFAULT_FAST_UPLOAD); if (blockUploadEnabled) { blockOutputBuffer = Utils.getTrimmed(conf, FS_COS, FS_ALT_KEYS, FAST_UPLOAD_BUFFER, DEFAULT_FAST_UPLOAD_BUFFER); partSize = COSUtils.ensureOutputParameterInRange(MULTIPART_SIZE, partSize); blockFactory = COSDataBlocks.createFactory(this, blockOutputBuffer); blockOutputActiveBlocks = Utils.getInt(conf, FS_COS, FS_ALT_KEYS, FAST_UPLOAD_ACTIVE_BLOCKS, DEFAULT_FAST_UPLOAD_ACTIVE_BLOCKS); LOG.debug("Using COSBlockOutputStream with buffer = {}; block={};" + " queue limit={}", blockOutputBuffer, partSize, blockOutputActiveBlocks); } else { LOG.debug("Using COSOutputStream"); } }
From source file:com.liferay.portal.store.s3.S3Store.java
License:Open Source License
protected void configureProxySettings(ClientConfiguration clientConfiguration) { String proxyHost = _s3StoreConfiguration.proxyHost(); if (Validator.isNull(proxyHost)) { return;/* ww w. j a va2 s . c om*/ } clientConfiguration.setProxyHost(proxyHost); clientConfiguration.setProxyPort(_s3StoreConfiguration.proxyPort()); String proxyAuthType = _s3StoreConfiguration.proxyAuthType(); if (proxyAuthType.equals("ntlm") || proxyAuthType.equals("username-password")) { clientConfiguration.setProxyPassword(_s3StoreConfiguration.proxyPassword()); clientConfiguration.setProxyUsername(_s3StoreConfiguration.proxyUsername()); if (proxyAuthType.equals("ntlm")) { clientConfiguration.setProxyDomain(_s3StoreConfiguration.ntlmProxyDomain()); clientConfiguration.setProxyWorkstation(_s3StoreConfiguration.ntlmProxyWorkstation()); } } }
From source file:com.netflix.exhibitor.core.s3.PropertyBasedS3ClientConfig.java
License:Apache License
@Override public ClientConfiguration getAWSClientConfig() { ClientConfiguration awsClientConfig = new ClientConfiguration(); awsClientConfig.setProxyHost(proxyHost); awsClientConfig.setProxyPort(proxyPort); if (proxyUsername != null) { awsClientConfig.setProxyUsername(proxyUsername); }// w w w.j a v a2 s . c om if (proxyPassword != null) { awsClientConfig.setProxyPassword(proxyPassword); } return awsClientConfig; }
From source file:com.netflix.spinnaker.clouddriver.aws.security.AWSProxy.java
License:Apache License
public void apply(ClientConfiguration clientConfiguration) { clientConfiguration.setProxyHost(proxyHost); clientConfiguration.setProxyPort(Integer.parseInt(proxyPort)); clientConfiguration.setProxyUsername(proxyUsername); clientConfiguration.setProxyPassword(proxyPassword); Protocol awsProtocol = Protocol.HTTP; if ("HTTPS".equalsIgnoreCase(protocol)) { awsProtocol = Protocol.HTTPS;//from www .j ava2 s . com } clientConfiguration.setProtocol(awsProtocol); if (isNTLMProxy()) { clientConfiguration.setProxyDomain(proxyDomain); clientConfiguration.setProxyWorkstation(proxyWorkstation); } }
From source file:com.streamsets.pipeline.lib.aws.s3.S3Accessor.java
License:Apache License
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()); }//from ww w . ja v a2 s . c om } return clientConfig; }
From source file:com.streamsets.pipeline.stage.lib.aws.AWSUtil.java
License:Apache License
public static ClientConfiguration getClientConfiguration(ProxyConfig config) { ClientConfiguration clientConfig = new ClientConfiguration(); // 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.isEmpty()) { clientConfig.setProxyUsername(config.proxyUser); }/* w w w .j a v a 2 s.co m*/ if (config.proxyPassword != null) { clientConfig.setProxyPassword(config.proxyPassword); } } } return clientConfig; }
From source file:com.tcl.gateway.firehose.log4j.FirehoseAppender.java
License:Open Source License
/** * 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. *//*from w ww . ja v a 2 s. c om*/ 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; }