当前位置: 首页>>代码示例>>Java>>正文


Java AWSCredentialsProviderChain类代码示例

本文整理汇总了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]));
}
 
开发者ID:detectiveframework,项目名称:detective,代码行数:20,代码来源:AwsUtils.java

示例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;
}
 
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:22,代码来源:CerberusModule.java

示例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()]));
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:25,代码来源:S3DaoImpl.java

示例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;

}
 
开发者ID:kzwang,项目名称:elasticsearch-river-dynamodb,代码行数:21,代码来源:DynamoDbRiverTests.java

示例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());

}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:22,代码来源:ContextCredentialsAutoConfigurationTest.java

示例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);
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:33,代码来源:ApiImporter.java

示例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);
}
 
开发者ID:EvidentSolutions,项目名称:gradle-beanstalk-plugin,代码行数:12,代码来源:DeployTask.java

示例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());
}
 
开发者ID:apache,项目名称:samza,代码行数:15,代码来源:KinesisConfig.java

示例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());
}
 
开发者ID:scizeron,项目名称:logback-sqs,代码行数:12,代码来源:SqsAppender.java

示例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);
}
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:33,代码来源:ExtPropertiesFileConfiguration.java

示例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);
}
 
开发者ID:manheim,项目名称:aws-request-signer,代码行数:11,代码来源:V4RequestSignerTest.java

示例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);
}
 
开发者ID:j256,项目名称:simplemetrics,代码行数:11,代码来源:CloudWatchMetricsPersisterTest.java

示例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()
            );
}
 
开发者ID:awslabs,项目名称:amediamanager,代码行数:10,代码来源:ServerConfig.java

示例14: createCredentialsProvider

import com.amazonaws.auth.AWSCredentialsProviderChain; //导入依赖的package包/类
private AWSCredentialsProvider createCredentialsProvider(){
  return new AWSCredentialsProviderChain(
      new InstanceProfileCredentialsProvider(),
      new EnvironmentVariableCredentialsProvider(),
      new SystemPropertiesCredentialsProvider(),
      new AWSCredentialsConfigFileProvider()
      );
}
 
开发者ID:detectiveframework,项目名称:detective,代码行数:9,代码来源:AwsServiceImpl.java

示例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()
    );
}
 
开发者ID:trautonen,项目名称:logback-ext,代码行数:10,代码来源:AwsSupport.java


注:本文中的com.amazonaws.auth.AWSCredentialsProviderChain类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。