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


Java StaticCredentialsProvider类代码示例

本文整理汇总了Java中com.amazonaws.internal.StaticCredentialsProvider的典型用法代码示例。如果您正苦于以下问题:Java StaticCredentialsProvider类的具体用法?Java StaticCredentialsProvider怎么用?Java StaticCredentialsProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StaticCredentialsProvider类属于com.amazonaws.internal包,在下文中一共展示了StaticCredentialsProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildCredentials

import com.amazonaws.internal.StaticCredentialsProvider; //导入依赖的package包/类
public static AWSCredentialsProvider buildCredentials(Logger logger, DeprecationLogger deprecationLogger,
                                                      Settings settings, Settings repositorySettings, String clientName) {
    try (SecureString key = getConfigValue(repositorySettings, settings, clientName, S3Repository.ACCESS_KEY_SETTING,
                                           S3Repository.Repository.KEY_SETTING, S3Repository.Repositories.KEY_SETTING);
         SecureString secret = getConfigValue(repositorySettings, settings, clientName, S3Repository.SECRET_KEY_SETTING,
                                              S3Repository.Repository.SECRET_SETTING, S3Repository.Repositories.SECRET_SETTING)) {

        if (key.length() == 0 && secret.length() == 0) {
            logger.debug("Using instance profile credentials");
            return new PrivilegedInstanceProfileCredentialsProvider();
        } else {
            logger.debug("Using basic key/secret credentials");
            return new StaticCredentialsProvider(new BasicAWSCredentials(key.toString(), secret.toString()));
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:InternalAwsS3Service.java

示例2: request_credentials_takes_precendence_over_client_credentials

import com.amazonaws.internal.StaticCredentialsProvider; //导入依赖的package包/类
@Test
public void request_credentials_takes_precendence_over_client_credentials() {
    final String awsAccessKeyId = "foo";
    final String awsSecretAccessKey = "bar";
    final AWSCredentials reqCredentials = new BasicAWSCredentials(awsAccessKeyId,
                                                                  awsSecretAccessKey);
    EmptyAmazonWebServiceRequest req = new EmptyAmazonWebServiceRequest();
    req.setRequestCredentials(reqCredentials);
    AWSCredentialsProvider actual = CredentialUtils.getCredentialsProvider(req,
                                                                           null);

    Assert.assertThat(actual, Matchers.instanceOf(StaticCredentialsProvider
                                                          .class));
    assertEquals(awsAccessKeyId, actual.getCredentials().getAWSAccessKeyId());
    assertEquals(awsSecretAccessKey, actual.getCredentials().getAWSSecretKey());
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:17,代码来源:CredentialUtilsTest.java

示例3: testProvide

import com.amazonaws.internal.StaticCredentialsProvider; //导入依赖的package包/类
@Test
public void testProvide() {
    Env env = new Env().register("DYNAMODB_ENDPOINT", "fakeendpoint");
    ClientConfiguration config = new ClientConfiguration();
    config.setRetryPolicy(PredefinedRetryPolicies.NO_RETRY_POLICY);

    AWSCredentialsProvider credentialsProvider = new StaticCredentialsProvider(
            new BasicAWSCredentials("fake_access_key_id", "fake_secret_access_key"));

    AmazonDynamoDBFactory factory = new AmazonDynamoDBFactory(env, credentialsProvider, config);
    AmazonDynamoDB dynamoDB = factory.provide();

    String message = "";

    try {
        dynamoDB.listTables();  
    } catch (AmazonClientException e) {
        message = e.getMessage();
    }

    assertTrue(message.startsWith("Unable to execute HTTP request: fakeendpoint"));
    
    factory.dispose(dynamoDB);
}
 
开发者ID:coding4people,项目名称:mosquito-report-api,代码行数:25,代码来源:AmazonDynamoDBFactoryTest.java

示例4: getAWSCredentialsProvider

import com.amazonaws.internal.StaticCredentialsProvider; //导入依赖的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

示例5: getDynamoClient

import com.amazonaws.internal.StaticCredentialsProvider; //导入依赖的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

示例6: createClient

import com.amazonaws.internal.StaticCredentialsProvider; //导入依赖的package包/类
static <T extends AmazonWebServiceClient> T createClient( Class<T> clientType,
                                                          Identity identity )
{
    Regions r = Regions.US_EAST_1;
    if ( StringUtils.isNotBlank( identity.getAwsRegionName() ) )
    {
        r = Regions.fromName( identity.getAwsRegionName() );
    }
    AWSCredentialsProvider creds =
        new StaticCredentialsProvider(
                                       new BasicAWSCredentials(
                                                                identity.getAwsAccessKeyId(),
                                                                identity.getAwsSecretKey() ) );

    return Region.getRegion( r ).createClient( clientType, creds, null );
}
 
开发者ID:jiaqi,项目名称:datamung,代码行数:17,代码来源:ActivityUtils.java

示例7: getAllProfiles

import com.amazonaws.internal.StaticCredentialsProvider; //导入依赖的package包/类
@Deprecated
public Map<String, Profile> getAllProfiles() {
    Map<String, Profile> legacyProfiles = new HashMap<String, Profile>();
    for (Map.Entry<String, BasicProfile> entry : getAllBasicProfiles().entrySet()) {
        final String profileName = entry.getKey();
        legacyProfiles.put(profileName,
                           new Profile(profileName, entry.getValue().getProperties(),
                                       new StaticCredentialsProvider(
                                               getCredentials(profileName))));
    }
    return legacyProfiles;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:13,代码来源:ProfilesConfigFile.java

示例8: Profile

import com.amazonaws.internal.StaticCredentialsProvider; //导入依赖的package包/类
public Profile(String profileName, AWSCredentials awsCredentials) {
    Map<String, String> properties = new LinkedHashMap<String, String>();
    properties.put(ProfileKeyConstants.AWS_ACCESS_KEY_ID, awsCredentials.getAWSAccessKeyId());
    properties.put(ProfileKeyConstants.AWS_SECRET_ACCESS_KEY, awsCredentials.getAWSSecretKey());

    if (awsCredentials instanceof AWSSessionCredentials) {
        AWSSessionCredentials sessionCred = (AWSSessionCredentials)awsCredentials;
        properties.put(ProfileKeyConstants.AWS_SESSION_TOKEN, sessionCred.getSessionToken());
    }

    this.profileName = profileName;
    this.properties = properties;
    this.awsCredentials = new StaticCredentialsProvider(awsCredentials);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:15,代码来源:Profile.java

示例9: credentialsExplicitlySet_UsesExplicitCredentials

import com.amazonaws.internal.StaticCredentialsProvider; //导入依赖的package包/类
@Test
public void credentialsExplicitlySet_UsesExplicitCredentials() throws Exception {
    AWSCredentialsProvider provider = new StaticCredentialsProvider(
            new BasicAWSCredentials("akid", "skid"));
    AwsAsyncClientParams params = builderWithRegion().withCredentials(provider).build()
            .getAsyncParams();
    assertEquals(provider, params.getCredentialsProvider());
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:9,代码来源:AwsClientBuilderTest.java

示例10: base_credentials_returned_when_no_request_credentials_is_present

import com.amazonaws.internal.StaticCredentialsProvider; //导入依赖的package包/类
@Test
public void base_credentials_returned_when_no_request_credentials_is_present() {
    final String awsAccessKeyId = "foo";
    final String awsSecretAccessKey = "bar";
    final StaticCredentialsProvider base = new StaticCredentialsProvider
            (new BasicAWSCredentials(awsAccessKeyId, awsSecretAccessKey));

    AWSCredentialsProvider actual = CredentialUtils
            .getCredentialsProvider((AmazonWebServiceRequest) null, base);
    Assert.assertThat(actual, Matchers.instanceOf(StaticCredentialsProvider
                                                          .class));
    assertEquals(awsAccessKeyId, actual.getCredentials().getAWSAccessKeyId());
    assertEquals(awsSecretAccessKey, actual.getCredentials().getAWSSecretKey());
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:15,代码来源:CredentialUtilsTest.java

示例11: AmazonS3EncryptionClient

import com.amazonaws.internal.StaticCredentialsProvider; //导入依赖的package包/类
/**
 * @deprecated use {@link AmazonS3EncryptionClientBuilder#withEncryptionMaterials(EncryptionMaterialsProvider)} and
 *                 {@link AmazonS3EncryptionClientBuilder#withCredentials(AWSCredentialsProvider)} and
 *                 {@link AmazonS3EncryptionClientBuilder#withCryptoConfiguration(CryptoConfiguration)} and
 *                 {@link AmazonS3EncryptionClientBuilder#withClientConfiguration(ClientConfiguration)}
 */
@Deprecated
public AmazonS3EncryptionClient(AWSCredentials credentials,
        EncryptionMaterialsProvider encryptionMaterialsProvider,
        ClientConfiguration clientConfig, CryptoConfiguration cryptoConfig) {
    this(new StaticCredentialsProvider(credentials),
            encryptionMaterialsProvider, clientConfig, cryptoConfig);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:14,代码来源:AmazonS3EncryptionClient.java

示例12: createConnection

import com.amazonaws.internal.StaticCredentialsProvider; //导入依赖的package包/类
@Override
public Connection createConnection() throws JMSException {
	Builder builder = SQSConnectionFactory.builder().withAWSCredentialsProvider(new StaticCredentialsProvider(new BasicAWSCredentials(this.accessKey,this.secretKey)));
	
	if (this.regionName != null && ! this.regionName.isEmpty()) {
		builder = builder.withRegionName(regionName);
	}
	
	this.factory = builder.build();
	
	return factory.createConnection();
}
 
开发者ID:TremoloSecurity,项目名称:OpenUnison,代码行数:13,代码来源:AwsSqsConnectionFactory.java

示例13: getCredentials

import com.amazonaws.internal.StaticCredentialsProvider; //导入依赖的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

示例14: getAwsCredentialsProvider

import com.amazonaws.internal.StaticCredentialsProvider; //导入依赖的package包/类
private AWSCredentialsProvider getAwsCredentialsProvider(URI uri, Configuration conf)
{
    Optional<AWSCredentials> credentials = getAwsCredentials(uri, conf);
    if (credentials.isPresent()) {
        return new StaticCredentialsProvider(credentials.get());
    }

    if (useInstanceCredentials) {
        return new InstanceProfileCredentialsProvider();
    }

    throw new RuntimeException("S3 credentials not configured");
}
 
开发者ID:y-lan,项目名称:presto,代码行数:14,代码来源:PrestoS3FileSystem.java

示例15: testStaticCredentials

import com.amazonaws.internal.StaticCredentialsProvider; //导入依赖的package包/类
@Test
public void testStaticCredentials()
        throws Exception
{
    Configuration config = new Configuration();
    config.set(PrestoS3FileSystem.S3_ACCESS_KEY, "test_secret_access_key");
    config.set(PrestoS3FileSystem.S3_SECRET_KEY, "test_access_key_id");
    // the static credentials should be preferred

    try (PrestoS3FileSystem fs = new PrestoS3FileSystem()) {
        fs.initialize(new URI("s3n://test-bucket/"), config);
        assertInstanceOf(getAwsCredentialsProvider(fs), StaticCredentialsProvider.class);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:15,代码来源:TestPrestoS3FileSystem.java


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