List of usage examples for com.amazonaws.auth SystemPropertiesCredentialsProvider SystemPropertiesCredentialsProvider
SystemPropertiesCredentialsProvider
From source file:com.tsatsatzu.subwar.game.logic.dynamo.DynamoIODriver.java
License:Apache License
/** * Instantiates a new dynamo io driver.//ww w . ja v a2s . c o m */ public DynamoIODriver() { String accessKey = CredentialsLogic.getProperty("accessKey"); String secretKey = CredentialsLogic.getProperty("secretKey"); System.setProperty("aws.accessKeyId", accessKey); System.setProperty("aws.secretKey", secretKey); mClient = new AmazonDynamoDBClient(new SystemPropertiesCredentialsProvider()); mSingleThreaded = true; }
From source file:fi.yle.tools.aws.maven.AuthenticationInfoAWSCredentialsProviderChain.java
License:Apache License
AuthenticationInfoAWSCredentialsProviderChain(AuthenticationInfo authenticationInfo) { super(new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new InstanceProfileCredentialsProvider(), new ProfileCredentialsProvider(), new AuthenticationInfoAWSCredentialsProvider(authenticationInfo)); }
From source file:io.druid.common.aws.AWSCredentialsUtils.java
License:Apache License
public static AWSCredentialsProviderChain defaultAWSCredentialsProviderChain( final AWSCredentialsConfig config) { return new AWSCredentialsProviderChain(new ConfigDrivenAwsCredentialsConfigProvider(config), new LazyFileSessionCredentialsProvider(config), new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new ProfileCredentialsProvider(), new InstanceProfileCredentialsProvider()); }
From source file:jp.classmethod.aws.gradle.AwsPluginExtension.java
License:Apache License
public AWSCredentialsProvider newCredentialsProvider(String profileName) { if (credentialsProvider != null) { return credentialsProvider; }/*from w w w . j ava 2s . c om*/ String profileNameToUse = profileName != null ? profileName : this.profileName; if (Strings.isNullOrEmpty(profileNameToUse) == false) { List<AWSCredentialsProvider> providers = new ArrayList<AWSCredentialsProvider>(); providers.add(new EnvironmentVariableCredentialsProvider()); providers.add(new SystemPropertiesCredentialsProvider()); providers.add(new ProfileCredentialsProvider(profileNameToUse)); providers.add(new EC2ContainerCredentialsProviderWrapper()); return new AWSCredentialsProviderChain(providers); } return DefaultAWSCredentialsProviderChain.getInstance(); }
From source file:org.adroitlogic.build.aws.maven.AuthenticationInfoAWSCredentialsProviderChain.java
License:Apache License
AuthenticationInfoAWSCredentialsProviderChain(AuthenticationInfo authenticationInfo) { super(new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new InstanceProfileCredentialsProvider(), new AuthenticationInfoAWSCredentialsProvider(authenticationInfo)); }
From source file:org.apache.flink.streaming.connectors.kinesis.util.AWSUtil.java
License:Apache License
/** * Return a {@link AWSCredentialsProvider} instance corresponding to the configuration properties. * * @param configProps the configuration properties * @return The corresponding AWS Credentials Provider instance */// w w w. j av a 2 s . co m public static AWSCredentialsProvider getCredentialsProvider(final Properties configProps) { CredentialProvider credentialProviderType; if (!configProps.containsKey(AWSConfigConstants.AWS_CREDENTIALS_PROVIDER)) { if (configProps.containsKey(AWSConfigConstants.AWS_ACCESS_KEY_ID) && configProps.containsKey(AWSConfigConstants.AWS_SECRET_ACCESS_KEY)) { // if the credential provider type is not specified, but the Access Key ID and Secret Key are given, it will default to BASIC credentialProviderType = CredentialProvider.BASIC; } else { // if the credential provider type is not specified, it will default to AUTO credentialProviderType = CredentialProvider.AUTO; } } else { credentialProviderType = CredentialProvider .valueOf(configProps.getProperty(AWSConfigConstants.AWS_CREDENTIALS_PROVIDER)); } AWSCredentialsProvider credentialsProvider; switch (credentialProviderType) { case ENV_VAR: credentialsProvider = new EnvironmentVariableCredentialsProvider(); break; case SYS_PROP: credentialsProvider = new SystemPropertiesCredentialsProvider(); break; case PROFILE: String profileName = configProps.getProperty(AWSConfigConstants.AWS_PROFILE_NAME, null); String profileConfigPath = configProps.getProperty(AWSConfigConstants.AWS_PROFILE_PATH, null); credentialsProvider = (profileConfigPath == null) ? new ProfileCredentialsProvider(profileName) : new ProfileCredentialsProvider(profileConfigPath, profileName); break; case BASIC: credentialsProvider = new AWSCredentialsProvider() { @Override public AWSCredentials getCredentials() { return new BasicAWSCredentials(configProps.getProperty(AWSConfigConstants.AWS_ACCESS_KEY_ID), configProps.getProperty(AWSConfigConstants.AWS_SECRET_ACCESS_KEY)); } @Override public void refresh() { // do nothing } }; break; default: case AUTO: credentialsProvider = new DefaultAWSCredentialsProviderChain(); } return credentialsProvider; }
From source file:org.apache.storm.kinesis.spout.CredentialsProviderChain.java
License:Apache License
public CredentialsProviderChain() { super(new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new ClasspathPropertiesFileCredentialsProvider(), new InstanceProfileCredentialsProvider(), new ProfileCredentialsProvider()); }
From source file:org.elasticsearch.cloud.aws.AwsEc2Service.java
License:Apache License
public synchronized AmazonEC2 client() { if (client != null) { return client; }/*from w w w . j ava 2 s . co m*/ ClientConfiguration clientConfiguration = new ClientConfiguration(); String protocol = componentSettings.get("protocol", "http").toLowerCase(); if ("http".equals(protocol)) { clientConfiguration.setProtocol(Protocol.HTTP); } else if ("https".equals(protocol)) { clientConfiguration.setProtocol(Protocol.HTTPS); } else { throw new ElasticsearchIllegalArgumentException( "No protocol supported [" + protocol + "], can either be [http] or [https]"); } String account = componentSettings.get("access_key", settings.get("cloud.account")); String key = componentSettings.get("secret_key", settings.get("cloud.key")); String proxyHost = componentSettings.get("proxy_host"); if (proxyHost != null) { String portString = componentSettings.get("proxy_port", "80"); Integer proxyPort; try { proxyPort = Integer.parseInt(portString, 10); } catch (NumberFormatException ex) { throw new ElasticsearchIllegalArgumentException( "The configured proxy port value [" + portString + "] is invalid", ex); } clientConfiguration.withProxyHost(proxyHost).setProxyPort(proxyPort); } AWSCredentialsProvider credentials; if (account == null && key == null) { credentials = new AWSCredentialsProviderChain(new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new InstanceProfileCredentialsProvider()); } else { credentials = new AWSCredentialsProviderChain( new StaticCredentialsProvider(new BasicAWSCredentials(account, key))); } this.client = new AmazonEC2Client(credentials, clientConfiguration); if (componentSettings.get("ec2.endpoint") != null) { String endpoint = componentSettings.get("ec2.endpoint"); logger.debug("using explicit ec2 endpoint [{}]", endpoint); client.setEndpoint(endpoint); } else if (componentSettings.get("region") != null) { String region = componentSettings.get("region").toLowerCase(); String endpoint; if (region.equals("us-east-1") || region.equals("us-east")) { endpoint = "ec2.us-east-1.amazonaws.com"; } else if (region.equals("us-west") || region.equals("us-west-1")) { endpoint = "ec2.us-west-1.amazonaws.com"; } else if (region.equals("us-west-2")) { endpoint = "ec2.us-west-2.amazonaws.com"; } else if (region.equals("ap-southeast") || region.equals("ap-southeast-1")) { endpoint = "ec2.ap-southeast-1.amazonaws.com"; } else if (region.equals("ap-southeast-2")) { endpoint = "ec2.ap-southeast-2.amazonaws.com"; } else if (region.equals("ap-northeast") || region.equals("ap-northeast-1")) { endpoint = "ec2.ap-northeast-1.amazonaws.com"; } else if (region.equals("eu-west") || region.equals("eu-west-1")) { endpoint = "ec2.eu-west-1.amazonaws.com"; } else if (region.equals("sa-east") || region.equals("sa-east-1")) { endpoint = "ec2.sa-east-1.amazonaws.com"; } else { throw new ElasticsearchIllegalArgumentException( "No automatic endpoint could be derived from region [" + region + "]"); } if (endpoint != null) { logger.debug("using ec2 region [{}], with endpoint [{}]", region, endpoint); client.setEndpoint(endpoint); } } return this.client; }
From source file:org.elasticsearch.cloud.aws.AwsS3Service.java
License:Apache License
private synchronized AmazonS3 getClient(String endpoint, String account, String key) { Tuple<String, String> clientDescriptor = new Tuple<String, String>(endpoint, account); AmazonS3Client client = clients.get(clientDescriptor); if (client != null) { return client; }//ww w. jav a 2 s .c om ClientConfiguration clientConfiguration = new ClientConfiguration(); String protocol = componentSettings.get("protocol", "http").toLowerCase(); if ("http".equals(protocol)) { clientConfiguration.setProtocol(Protocol.HTTP); } else if ("https".equals(protocol)) { clientConfiguration.setProtocol(Protocol.HTTPS); } else { throw new ElasticsearchIllegalArgumentException( "No protocol supported [" + protocol + "], can either be [http] or [https]"); } String proxyHost = componentSettings.get("proxy_host"); if (proxyHost != null) { String portString = componentSettings.get("proxy_port", "80"); Integer proxyPort; try { proxyPort = Integer.parseInt(portString, 10); } catch (NumberFormatException ex) { throw new ElasticsearchIllegalArgumentException( "The configured proxy port value [" + portString + "] is invalid", ex); } clientConfiguration.withProxyHost(proxyHost).setProxyPort(proxyPort); } AWSCredentialsProvider credentials; if (account == null && key == null) { credentials = new AWSCredentialsProviderChain(new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new InstanceProfileCredentialsProvider()); } else { credentials = new AWSCredentialsProviderChain( new StaticCredentialsProvider(new BasicAWSCredentials(account, key))); } client = new AmazonS3Client(credentials, clientConfiguration); if (endpoint != null) { client.setEndpoint(endpoint); } clients.put(clientDescriptor, client); return client; }
From source file:org.elasticsearch.cloud.aws.InternalAwsS3Service.java
License:Apache License
private synchronized AmazonS3 getClient(String endpoint, String protocol, String account, String key, Integer maxRetries) {//from w ww . j av a 2s . c o m Tuple<String, String> clientDescriptor = new Tuple<String, String>(endpoint, account); AmazonS3Client client = clients.get(clientDescriptor); if (client != null) { return client; } 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); if (protocol == null) { protocol = settings.get("cloud.aws.protocol", "https").toLowerCase(); protocol = settings.get("cloud.aws.s3.protocol", protocol).toLowerCase(); } if ("http".equals(protocol)) { clientConfiguration.setProtocol(Protocol.HTTP); } else if ("https".equals(protocol)) { clientConfiguration.setProtocol(Protocol.HTTPS); } else { throw new IllegalArgumentException( "No protocol supported [" + protocol + "], can either be [http] or [https]"); } String proxyHost = settings.get("cloud.aws.proxy_host"); proxyHost = settings.get("cloud.aws.s3.proxy_host", proxyHost); if (proxyHost != null) { String portString = settings.get("cloud.aws.proxy_port", "80"); portString = settings.get("cloud.aws.s3.proxy_port", portString); Integer proxyPort; try { proxyPort = Integer.parseInt(portString, 10); } catch (NumberFormatException ex) { throw new IllegalArgumentException( "The configured proxy port value [" + portString + "] is invalid", ex); } clientConfiguration.withProxyHost(proxyHost).setProxyPort(proxyPort); } if (maxRetries != null) { // If not explicitly set, default to 3 with exponential backoff policy clientConfiguration.setMaxErrorRetry(maxRetries); } // #155: we might have 3rd party users using older S3 API version String awsSigner = settings.get("cloud.aws.s3.signer", settings.get("cloud.aws.signer")); if (awsSigner != null) { logger.debug("using AWS API signer [{}]", awsSigner); try { AwsSigner.configureSigner(awsSigner, clientConfiguration); } catch (IllegalArgumentException e) { logger.warn("wrong signer set for [cloud.aws.s3.signer] or [cloud.aws.signer]: [{}]", awsSigner); } } AWSCredentialsProvider credentials; if (account == null && key == null) { credentials = new AWSCredentialsProviderChain(new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new InstanceProfileCredentialsProvider()); } else { credentials = new AWSCredentialsProviderChain( new StaticCredentialsProvider(new BasicAWSCredentials(account, key))); } client = new AmazonS3Client(credentials, clientConfiguration); if (endpoint != null) { client.setEndpoint(endpoint); } clients.put(clientDescriptor, client); return client; }