Java Code Examples for com.amazonaws.auth.DefaultAWSCredentialsProviderChain#getInstance()
The following examples show how to use
com.amazonaws.auth.DefaultAWSCredentialsProviderChain#getInstance() .
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: GlueHiveMetastore.java From presto with Apache License 2.0 | 6 votes |
private static AWSCredentialsProvider getAwsCredentialsProvider(GlueHiveMetastoreConfig config) { if (config.getAwsAccessKey().isPresent() && config.getAwsSecretKey().isPresent()) { return new AWSStaticCredentialsProvider( new BasicAWSCredentials(config.getAwsAccessKey().get(), config.getAwsSecretKey().get())); } if (config.getIamRole().isPresent()) { return new STSAssumeRoleSessionCredentialsProvider .Builder(config.getIamRole().get(), "presto-session") .withExternalId(config.getExternalId().orElse(null)) .build(); } if (config.getAwsCredentialsProvider().isPresent()) { return getCustomAWSCredentialsProvider(config.getAwsCredentialsProvider().get()); } return DefaultAWSCredentialsProviderChain.getInstance(); }
Example 2
Source File: ElasticsearchClient.java From presto with Apache License 2.0 | 5 votes |
private static AWSCredentialsProvider getAwsCredentialsProvider(AwsSecurityConfig config) { if (config.getAccessKey().isPresent() && config.getSecretKey().isPresent()) { return new AWSStaticCredentialsProvider(new BasicAWSCredentials( config.getAccessKey().get(), config.getSecretKey().get())); } return DefaultAWSCredentialsProviderChain.getInstance(); }
Example 3
Source File: PrestoS3ClientFactory.java From presto with Apache License 2.0 | 5 votes |
private static AWSCredentialsProvider getAwsCredentialsProvider(Configuration conf, HiveS3Config defaults) { Optional<AWSCredentials> credentials = getAwsCredentials(conf); if (credentials.isPresent()) { return new AWSStaticCredentialsProvider(credentials.get()); } String providerClass = conf.get(S3_CREDENTIALS_PROVIDER); if (!isNullOrEmpty(providerClass)) { return getCustomAWSCredentialsProvider(conf, providerClass); } return DefaultAWSCredentialsProviderChain.getInstance(); }
Example 4
Source File: SQSFactoryImpl.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 5 votes |
@Override public AmazonSQS createSQSAsync(final SQSQueue queue) { AWSCredentialsProvider credentials = queue.hasCredentials() ? queue.lookupAwsCredentials() : DefaultAWSCredentialsProviderChain.getInstance(); AmazonSQSAsyncClientBuilder sqsAsyncBuilder = createStandardAsyncClientBuilder(queue, credentials); final QueueBufferConfig queueBufferConfig = this.getQueueBufferConfig(queue); final AmazonSQSBufferedAsyncClient sqsBufferedAsync = new AmazonSQSBufferedAsyncClient(sqsAsyncBuilder.build(), queueBufferConfig); return sqsBufferedAsync; }
Example 5
Source File: KinesisDispatcher.java From haystack-agent with Apache License 2.0 | 5 votes |
@VisibleForTesting AWSCredentialsProvider buildCredsProvider(final Map<String, String> conf) { final Object stsRoleArn = conf.remove(STS_ROLE_ARN); final Object awsAccessKey = conf.remove(AWS_ACCESS_KEY); final Object awsSecretKey = conf.remove(AWS_SECRET_KEY); if (Objects.nonNull(awsAccessKey) && Objects.nonNull(awsSecretKey) && Objects.nonNull(stsRoleArn)) { return new STSAssumeRoleSessionCredentialsProvider.Builder(stsRoleArn.toString(), "haystack-agent") .withStsClient( AWSSecurityTokenServiceClientBuilder.standard() .withCredentials( new AWSStaticCredentialsProvider(new BasicAWSCredentials(awsAccessKey.toString(), awsSecretKey.toString())) ) .withRegion(conf.get(AWS_REGION)) .build() ).build(); } else if (Objects.nonNull(awsAccessKey) && Objects.nonNull(awsSecretKey)) { LOGGER.info("Using static credential provider using aws access and secret keys"); return new AWSStaticCredentialsProvider( new BasicAWSCredentials(awsAccessKey.toString(), awsSecretKey.toString())); } else { if (Objects.nonNull(stsRoleArn)) { LOGGER.info("Using aws sts credential provider with role arn={}", stsRoleArn); return new STSProfileCredentialsServiceProvider( new RoleInfo().withRoleArn(stsRoleArn.toString()).withRoleSessionName("haystack-agent")); } else { return DefaultAWSCredentialsProviderChain.getInstance(); } } }
Example 6
Source File: SNSNotificationsConfig.java From metacat with Apache License 2.0 | 5 votes |
/** * If SNS notifications are desired and no existing client has been created elsewhere * in the application create a default client here. * * @return The configured SNS client */ //TODO: See what spring-cloud-aws would provide automatically... @Bean @ConditionalOnMissingBean(AmazonSNS.class) public AmazonSNS amazonSNS() { return new AmazonSNSClient(DefaultAWSCredentialsProviderChain.getInstance()); }
Example 7
Source File: ClientAuthenticationFactory.java From spring-cloud-vault with Apache License 2.0 | 5 votes |
private static AWSCredentialsProvider getAwsCredentialsProvider() { DefaultAWSCredentialsProviderChain backingCredentialsProvider = DefaultAWSCredentialsProviderChain .getInstance(); // Eagerly fetch credentials preventing lag during the first, actual login. AWSCredentials firstAccess = backingCredentialsProvider.getCredentials(); AtomicReference<AWSCredentials> once = new AtomicReference<>(firstAccess); return new AWSCredentialsProvider() { @Override public AWSCredentials getCredentials() { if (once.compareAndSet(firstAccess, null)) { return firstAccess; } return backingCredentialsProvider.getCredentials(); } @Override public void refresh() { backingCredentialsProvider.refresh(); } }; }
Example 8
Source File: AwsAccountValidator.java From halyard with Apache License 2.0 | 5 votes |
public static AWSCredentialsProvider getAwsCredentialsProvider( String accessKeyId, String secretKey) { if (accessKeyId != null && secretKey != null) { return new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKeyId, secretKey)); } else { return DefaultAWSCredentialsProviderChain.getInstance(); } }
Example 9
Source File: CredentialsUtil.java From pulsar with Apache License 2.0 | 5 votes |
/** * Builds an AWS credential provider based on the offload options * @return aws credential provider */ public static AWSCredentialsProvider getAWSCredentialProvider(OffloadPolicies offloadPolicies) { if (Strings.isNullOrEmpty(offloadPolicies.getS3ManagedLedgerOffloadRole())) { return DefaultAWSCredentialsProviderChain.getInstance(); } else { String roleName = offloadPolicies.getS3ManagedLedgerOffloadRole(); String roleSessionName = offloadPolicies.getS3ManagedLedgerOffloadRoleSessionName(); return new STSAssumeRoleSessionCredentialsProvider.Builder(roleName, roleSessionName).build(); } }
Example 10
Source File: AWSUtil.java From datacollector with Apache License 2.0 | 5 votes |
public static AWSCredentialsProvider getCredentialsProvider(AWSConfig config) throws StageException { AWSCredentialsProvider credentialsProvider = DefaultAWSCredentialsProviderChain.getInstance(); if (config.credentialMode == AWSCredentialMode.WITH_CREDENTIALS) { if (!StringUtils.isEmpty(config.awsAccessKeyId.get()) && !StringUtils.isEmpty(config.awsSecretAccessKey.get())) { credentialsProvider = new AWSStaticCredentialsProvider( new BasicAWSCredentials(config.awsAccessKeyId.get(), config.awsSecretAccessKey.get()) ); } } return credentialsProvider; }
Example 11
Source File: AWSUtil.java From datacollector with Apache License 2.0 | 5 votes |
public static AWSCredentialsProvider getCredentialsProvider(AWSConfig config) throws StageException { AWSCredentialsProvider credentialsProvider = DefaultAWSCredentialsProviderChain.getInstance(); if (config.credentialMode == AWSCredentialMode.WITH_CREDENTIALS) { if (!StringUtils.isEmpty(config.awsAccessKeyId.get()) && !StringUtils.isEmpty(config.awsSecretAccessKey.get())) { credentialsProvider = new AWSStaticCredentialsProvider( new BasicAWSCredentials(config.awsAccessKeyId.get(), config.awsSecretAccessKey.get()) ); } } else if (config.credentialMode == AWSCredentialMode.WITH_ANONYMOUS_CREDENTIALS) { credentialsProvider = new AWSStaticCredentialsProvider(new AnonymousAWSCredentials()); } return credentialsProvider; }
Example 12
Source File: AwsIamClientAuthenticationProvider.java From spring-cloud-config with Apache License 2.0 | 5 votes |
private static AWSCredentialsProvider getAwsCredentialsProvider() { DefaultAWSCredentialsProviderChain backingCredentialsProvider = DefaultAWSCredentialsProviderChain .getInstance(); // Eagerly fetch credentials preventing lag during the first, actual login. AWSCredentials firstAccess = backingCredentialsProvider.getCredentials(); AtomicReference<AWSCredentials> once = new AtomicReference<>(firstAccess); return new AWSCredentialsProvider() { @Override public AWSCredentials getCredentials() { if (once.compareAndSet(firstAccess, null)) { return firstAccess; } return backingCredentialsProvider.getCredentials(); } @Override public void refresh() { backingCredentialsProvider.refresh(); } }; }
Example 13
Source File: AwsOptions.java From beam with Apache License 2.0 | 4 votes |
@Override public AWSCredentialsProvider create(PipelineOptions options) { return DefaultAWSCredentialsProviderChain.getInstance(); }