List of usage examples for com.amazonaws ClientConfiguration withProxyPort
public ClientConfiguration withProxyPort(int proxyPort)
From source file:com.ge.predix.solsvc.blobstore.bootstrap.BlobstoreClientImpl.java
License:Apache License
/** * -/* w w w .jav a2s .c o m*/ */ @PostConstruct public void init() { ClientConfiguration config = new ClientConfiguration(); config.setProtocol(Protocol.HTTPS); if (this.blobstoreConfig.getProxyHost() != null && !"".equals(this.blobstoreConfig.getProxyHost())) { //$NON-NLS-1$ this.log.info("Connnecting with proxy"); //$NON-NLS-1$ if (this.blobstoreConfig.getProxyHost() != null) { config.withProxyHost(this.blobstoreConfig.getProxyHost()); } if (this.blobstoreConfig.getProxyPort() != null) { config.withProxyPort(Integer.parseInt(this.blobstoreConfig.getProxyPort())); } } BasicAWSCredentials creds = new BasicAWSCredentials(this.blobstoreConfig.getAccessKey(), this.blobstoreConfig.getAccessKey()); this.s3Client = new AmazonS3Client(creds, config); this.s3Client.setEndpoint(this.blobstoreConfig.getUrl()); }
From source file:org.apache.nifi.processors.aws.credentials.provider.factory.strategies.AssumeRoleCredentialsStrategy.java
License:Apache License
@Override public AWSCredentialsProvider getDerivedCredentialsProvider(Map<PropertyDescriptor, String> properties, AWSCredentialsProvider primaryCredentialsProvider) { final String assumeRoleArn = properties.get(ASSUME_ROLE_ARN); final String assumeRoleName = properties.get(ASSUME_ROLE_NAME); String rawMaxSessionTime = properties.get(MAX_SESSION_TIME); rawMaxSessionTime = (rawMaxSessionTime != null) ? rawMaxSessionTime : MAX_SESSION_TIME.getDefaultValue(); final Integer maxSessionTime = Integer.parseInt(rawMaxSessionTime.trim()); final String assumeRoleExternalId = properties.get(ASSUME_ROLE_EXTERNAL_ID); STSAssumeRoleSessionCredentialsProvider.Builder builder; ClientConfiguration config = new ClientConfiguration(); // If proxy variables are set, then create Client Configuration with those values if (proxyVariablesValidForAssumeRole(properties)) { final String assumeRoleProxyHost = properties.get(ASSUME_ROLE_PROXY_HOST); final Integer assumeRoleProxyPort = Integer.parseInt(properties.get(ASSUME_ROLE_PROXY_PORT)); config.withProxyHost(assumeRoleProxyHost); config.withProxyPort(assumeRoleProxyPort); }/* ww w.j a va 2 s . com*/ AWSSecurityTokenService securityTokenService = new AWSSecurityTokenServiceClient(primaryCredentialsProvider, config); builder = new STSAssumeRoleSessionCredentialsProvider.Builder(assumeRoleArn, assumeRoleName) .withStsClient(securityTokenService).withRoleSessionDurationSeconds(maxSessionTime); if (assumeRoleExternalId != null && !assumeRoleExternalId.isEmpty()) { builder = builder.withExternalId(assumeRoleExternalId); } final AWSCredentialsProvider credsProvider = builder.build(); return credsProvider; }
From source file:org.apache.storm.s3.output.UploaderFactory.java
License:Apache License
public static Uploader buildUploader(Map conf) { Protocol protocol = Protocol.HTTPS;//from w ww.j a v a2s. c om String proxy = null; int proxyPort = 0; if (conf.containsKey(S3_PROTOCOL)) { protocol = Protocol.valueOf((String) conf.get(S3_PROTOCOL)); } if (conf.containsKey(S3_PROXY)) { proxy = (String) conf.get(S3_PROXY); } if (conf.containsKey(S3_PROXY_PORT)) { proxyPort = ((Long) conf.get(S3_PROXY_PORT)).intValue(); } AWSCredentialsProvider provider = new DefaultAWSCredentialsProviderChain(); AWSCredentials credentials = provider.getCredentials(); ClientConfiguration config = new ClientConfiguration().withProtocol(protocol); if (proxy != null) { config.withProxyHost(proxy); } if (proxyPort != 0) { config.withProxyPort(proxyPort); } AmazonS3 client = new AmazonS3Client(credentials, config); if (conf.containsKey(S3_ENDPOINT)) { client.setEndpoint((String) conf.get(S3_ENDPOINT)); } return getUploader(conf, client); }