本文整理汇总了Java中com.amazonaws.auth.AWSCredentialsProviderChain类的典型用法代码示例。如果您正苦于以下问题:Java AWSCredentialsProviderChain类的具体用法?Java AWSCredentialsProviderChain怎么用?Java AWSCredentialsProviderChain使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AWSCredentialsProviderChain类属于com.amazonaws.auth包,在下文中一共展示了AWSCredentialsProviderChain类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCredentialProviderC
import com.amazonaws.auth.AWSCredentialsProviderChain; //导入依赖的package包/类
public static AWSCredentialsProvider getCredentialProviderC(Parameters config){
List<AWSCredentialsProvider> providers = new ArrayList<AWSCredentialsProvider>();
if ("YES".equals(config.get("aws.credentials.instaneProfile")))
providers.add(new InstanceProfileCredentialsProvider());
if ("YES".equals(config.get("aws.credentials.environmentVariable")))
providers.add(new EnvironmentVariableCredentialsProvider());
if ("YES".equals(config.get("aws.credentials.systemProperties")))
providers.add(new SystemPropertiesCredentialsProvider());
String accessKey = config.get("aws.credentials.accessKey").toString();
String secretKey = config.get("aws.credentials.secretKey").toString();
if (accessKey != null && accessKey.length() > 0){
providers.add(new AWSCredentialsConfigFileProvider(accessKey, secretKey));
}
return new AWSCredentialsProviderChain(providers.toArray(new AWSCredentialsProvider[0]));
}
示例2: getAWSCredentialsProviderChain
import com.amazonaws.auth.AWSCredentialsProviderChain; //导入依赖的package包/类
public static AWSCredentialsProviderChain getAWSCredentialsProviderChain() {
String cerberusRoleToAssume = System.getenv(CERBERUS_ASSUME_ROLE_ARN) != null ?
System.getenv(CERBERUS_ASSUME_ROLE_ARN) : "";
String cerberusRoleToAssumeExternalId = System.getenv(CERBERUS_ASSUME_ROLE_EXTERNAL_ID) != null ?
System.getenv(CERBERUS_ASSUME_ROLE_EXTERNAL_ID) : "";
STSAssumeRoleSessionCredentialsProvider sTSAssumeRoleSessionCredentialsProvider =
new STSAssumeRoleSessionCredentialsProvider
.Builder(cerberusRoleToAssume, UUID.randomUUID().toString())
.withExternalId(cerberusRoleToAssumeExternalId)
.build();
AWSCredentialsProviderChain chain = new AWSCredentialsProviderChain(
new EnvironmentVariableCredentialsProvider(),
new SystemPropertiesCredentialsProvider(),
new ProfileCredentialsProvider(),
sTSAssumeRoleSessionCredentialsProvider,
new InstanceProfileCredentialsProvider());
return chain;
}
示例3: getAWSCredentialsProvider
import com.amazonaws.auth.AWSCredentialsProviderChain; //导入依赖的package包/类
/**
* <p> Gets the {@link AWSCredentialsProvider} based on the credentials in the given parameters. </p> <p> Returns {@link DefaultAWSCredentialsProviderChain}
* if either access or secret key is {@code null}. Otherwise returns a {@link StaticCredentialsProvider} with the credentials. </p>
*
* @param params - Access parameters
*
* @return AWS credentials provider implementation
*/
private AWSCredentialsProvider getAWSCredentialsProvider(S3FileTransferRequestParamsDto params)
{
List<AWSCredentialsProvider> providers = new ArrayList<>();
String accessKey = params.getAwsAccessKeyId();
String secretKey = params.getAwsSecretKey();
if (accessKey != null && secretKey != null)
{
providers.add(new StaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey)));
}
for (HerdAWSCredentialsProvider herdAWSCredentialsProvider : params.getAdditionalAwsCredentialsProviders())
{
providers.add(new HerdAwsCredentialsProviderWrapper(herdAWSCredentialsProvider));
}
providers.add(new DefaultAWSCredentialsProviderChain());
return new AWSCredentialsProviderChain(providers.toArray(new AWSCredentialsProvider[providers.size()]));
}
示例4: getDynamoClient
import com.amazonaws.auth.AWSCredentialsProviderChain; //导入依赖的package包/类
private AmazonDynamoDBClient getDynamoClient(String tableName) {
AWSCredentialsProvider credentials = new AWSCredentialsProviderChain(new StaticCredentialsProvider(new BasicAWSCredentials("test", "test")));
AmazonDynamoDBClient amazonDynamoDBClient = new AmazonDynamoDBClient(credentials);
amazonDynamoDBClient.setEndpoint("http://localhost:8000");
ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput()
.withReadCapacityUnits(5L)
.withWriteCapacityUnits(10L);
CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(tableName).withProvisionedThroughput(provisionedThroughput);
ArrayList<AttributeDefinition> attributeDefinitions= new ArrayList<AttributeDefinition>();
attributeDefinitions.add(new AttributeDefinition().withAttributeName("id").withAttributeType("S"));
createTableRequest.setAttributeDefinitions(attributeDefinitions);
ArrayList<KeySchemaElement> tableKeySchema = new ArrayList<KeySchemaElement>();
tableKeySchema.add(new KeySchemaElement().withAttributeName("id").withKeyType(KeyType.HASH));
createTableRequest.setKeySchema(tableKeySchema);
amazonDynamoDBClient.createTable(createTableRequest);
return amazonDynamoDBClient;
}
示例5: AnnotationConfigApplicationContext
import com.amazonaws.auth.AWSCredentialsProviderChain; //导入依赖的package包/类
@Test
public void credentialsProvider_accessKeyAndSecretKeyConfigured_configuresStaticCredentialsProviderWithAccessAndSecretKey() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(ContextCredentialsAutoConfiguration.class);
TestPropertyValues.of(
"cloud.aws.credentials.accessKey:foo",
"cloud.aws.credentials.secretKey:bar").applyTo(this.context);
this.context.refresh();
AWSCredentialsProvider awsCredentialsProvider = this.context.getBean(AmazonWebserviceClientConfigurationUtils.CREDENTIALS_PROVIDER_BEAN_NAME, AWSCredentialsProviderChain.class);
assertNotNull(awsCredentialsProvider);
@SuppressWarnings("unchecked") List<CredentialsProvider> credentialsProviders =
(List<CredentialsProvider>) ReflectionTestUtils.getField(awsCredentialsProvider, "credentialsProviders");
assertEquals(2, credentialsProviders.size());
assertTrue(AWSStaticCredentialsProvider.class.isInstance(credentialsProviders.get(0)));
assertTrue(ProfileCredentialsProvider.class.isInstance(credentialsProviders.get(1)));
assertEquals("foo", awsCredentialsProvider.getCredentials().getAWSAccessKeyId());
assertEquals("bar", awsCredentialsProvider.getCredentials().getAWSSecretKey());
}
示例6: ApiImporter
import com.amazonaws.auth.AWSCredentialsProviderChain; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public ApiImporter(String profile, String accessKey, String secret) {
if (accessKey != null && secret != null) {
credentialsProvider=new AWSCredentialsProvider() {
@Override
public void refresh() {
}
@Override
public AWSCredentials getCredentials() {
return new AWSCredentials() {
@Override
public String getAWSSecretKey() {
return secret;
}
@Override
public String getAWSAccessKeyId() {
return accessKey;
}
};
}
};
} else {
credentialsProvider = new AWSCredentialsProviderChain(new EnvironmentVariableCredentialsProvider(),
new SystemPropertiesCredentialsProvider(), new ProfileCredentialsProvider(profile),
new InstanceProfileCredentialsProvider());
}
amazonApiGatewayClient = new AmazonApiGatewayClient(credentialsProvider);
}
示例7: deploy
import com.amazonaws.auth.AWSCredentialsProviderChain; //导入依赖的package包/类
@TaskAction
protected void deploy() {
String versionLabel = getVersionLabel();
AWSCredentialsProviderChain credentialsProvider = new AWSCredentialsProviderChain(new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new ProfileCredentialsProvider(beanstalk.getProfile()));
BeanstalkDeployer deployer = new BeanstalkDeployer(beanstalk.getS3Endpoint(), beanstalk.getBeanstalkEndpoint(), credentialsProvider);
File warFile = getProject().files(war).getSingleFile();
deployer.deploy(warFile, deployment.getApplication(), deployment.getEnvironment(), deployment.getTemplate(), versionLabel);
}
示例8: credentialsProviderForStream
import com.amazonaws.auth.AWSCredentialsProviderChain; //导入依赖的package包/类
/**
* Get the appropriate CredentialProvider for a given system stream.
* @param system name of the system
* @param stream name of the stream
* @return AWSCredentialsProvider
*/
AWSCredentialsProvider credentialsProviderForStream(String system, String stream) {
// Try to load credentials in the following order:
// 1. Access key from the config and passed in secretKey
// 2. From the default credential provider chain (environment variables, system properties, AWS profile file, etc)
return new AWSCredentialsProviderChain(
new KinesisAWSCredentialsProvider(getStreamAccessKey(system, stream), getStreamSecretKey(system, stream)),
new DefaultAWSCredentialsProviderChain());
}
示例9: getCredentials
import com.amazonaws.auth.AWSCredentialsProviderChain; //导入依赖的package包/类
/**
*
* @return
*/
private AWSCredentialsProvider getCredentials() {
return new AWSCredentialsProviderChain(new StaticCredentialsProvider(
new AppenderCredentials()), new SystemPropertiesCredentialsProvider(),
new EnvironmentVariableCredentialsProvider(),
new ProfileCredentialsProvider(),
new InstanceProfileCredentialsProvider());
}
示例10: ExtPropertiesFileConfiguration
import com.amazonaws.auth.AWSCredentialsProviderChain; //导入依赖的package包/类
/**
* Creates a {@link PropertiesFileConfiguration} from values provided in a classpath properties file.
*
* @param prop the classpath properties file to load.
* @param credentialProvider credential provider.
*/
public ExtPropertiesFileConfiguration(final Properties prop, final AWSCredentialsProviderChain credentialProvider) {
this.sqsUrl = prop.getProperty(SQS_URL);
LibraryUtils.checkArgumentNotNull(this.sqsUrl, "Cannot find SQS URL in properties file.");
final String accessKey = prop.getProperty(ACCESS_KEY);
final String secretKey = prop.getProperty(SECRET_KEY);
if (accessKey != null && secretKey != null) {
this.awsCredentialsProvider = new SimplePropertiesCredentials(prop);
}
else {
this.awsCredentialsProvider = credentialProvider;
}
this.s3Region = prop.getProperty(S3_REGION);
this.visibilityTimeout = this.getIntProperty(prop, VISIBILITY_TIMEOUT);
this.sqsRegion = prop.getProperty(SQS_REGION);
this.threadCount = this.getIntProperty(prop, THREAD_COUNT);
this.threadTerminationDelaySeconds = this.getIntProperty(prop, THREAD_TERMINATION_DELAY_SECONDS);
this.maxEventsPerEmit = this.getIntProperty(prop, MAX_EVENTS_PER_EMIT);
this.enableRawEventInfo = this.getBooleanProperty(prop, ENABLE_RAW_EVENT_INFO);
}
示例11: before
import com.amazonaws.auth.AWSCredentialsProviderChain; //导入依赖的package包/类
@Before
public final void before() throws URISyntaxException {
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
calendar.set(2011, 8, 9, 23, 36, 00);
currentDate = calendar.getTime();
uri = new URI(TEST_ENDPOINT);
AWSCredentialsProviderChain awsCredentialsProvider = new AWSCredentialsProviderChain(
new StaticCredentialsProvider(new BasicAWSCredentials(AWS_ACCESS_KEY_ID, AWS_SECRET_KEY)));
testObject = new V4RequestSigner(awsCredentialsProvider, REGION_NAME, SERVICE_NAME, currentDate);
}
示例12: testCoverage
import com.amazonaws.auth.AWSCredentialsProviderChain; //导入依赖的package包/类
@Test
public void testCoverage() {
AWSCredentials creds = new BasicAWSCredentials("key", "secret");
CloudWatchMetricsPersister persister = new CloudWatchMetricsPersister(creds, "app", true);
StaticCredentialsProvider credProv = new StaticCredentialsProvider(creds);
persister = new CloudWatchMetricsPersister(new AWSCredentialsProviderChain(credProv), "app", true);
persister = new CloudWatchMetricsPersister();
persister.setAwsCredentials(creds);
persister.setAwsCredentialsProvider(credProv);
}
示例13: credentials
import com.amazonaws.auth.AWSCredentialsProviderChain; //导入依赖的package包/类
@Bean
@Scope(WebApplicationContext.SCOPE_APPLICATION)
public AWSCredentialsProvider credentials() {
return new AWSCredentialsProviderChain(
new InstanceProfileCredentialsProvider(),
new EnvironmentVariableCredentialsProvider(),
new SystemPropertiesCredentialsProvider()
);
}
示例14: createCredentialsProvider
import com.amazonaws.auth.AWSCredentialsProviderChain; //导入依赖的package包/类
private AWSCredentialsProvider createCredentialsProvider(){
return new AWSCredentialsProviderChain(
new InstanceProfileCredentialsProvider(),
new EnvironmentVariableCredentialsProvider(),
new SystemPropertiesCredentialsProvider(),
new AWSCredentialsConfigFileProvider()
);
}
示例15: getCredentials
import com.amazonaws.auth.AWSCredentialsProviderChain; //导入依赖的package包/类
public AWSCredentialsProvider getCredentials(AWSCredentials credentials) {
return new AWSCredentialsProviderChain(
new EnvironmentVariableCredentialsProvider(),
new SystemPropertiesCredentialsProvider(),
new StaticCredentialsProvider(credentials == null ? new NullCredentials() : credentials),
new ProfileCredentialsProvider(),
new InstanceProfileCredentialsProvider()
);
}