當前位置: 首頁>>代碼示例>>Java>>正文


Java AWSCredentialsProvider類代碼示例

本文整理匯總了Java中com.amazonaws.auth.AWSCredentialsProvider的典型用法代碼示例。如果您正苦於以下問題:Java AWSCredentialsProvider類的具體用法?Java AWSCredentialsProvider怎麽用?Java AWSCredentialsProvider使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AWSCredentialsProvider類屬於com.amazonaws.auth包,在下文中一共展示了AWSCredentialsProvider類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildCredentials

import com.amazonaws.auth.AWSCredentialsProvider; //導入依賴的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: AmazonS3EncryptionClient

import com.amazonaws.auth.AWSCredentialsProvider; //導入依賴的package包/類
/**
 * @deprecated use {@link AmazonS3EncryptionClientBuilder#withEncryptionMaterials(EncryptionMaterialsProvider)} and
 *                 {@link AmazonS3EncryptionClientBuilder#withCredentials(AWSCredentialsProvider)} and
 *                 {@link AmazonS3EncryptionClientBuilder#withCryptoConfiguration(CryptoConfiguration)} and
 *                 {@link AmazonS3EncryptionClientBuilder#withClientConfiguration(ClientConfiguration)} and
 *                 {@link AmazonS3EncryptionClientBuilder#withMetricsCollector(RequestMetricCollector)} and
 *                 {@link AmazonS3EncryptionClientBuilder#withKmsClient(AWSKMS)}
 */
@Deprecated
public AmazonS3EncryptionClient(AWSKMSClient kms,
        AWSCredentialsProvider credentialsProvider,
        EncryptionMaterialsProvider kekMaterialsProvider,
        ClientConfiguration clientConfig,
        CryptoConfiguration cryptoConfig,
        RequestMetricCollector requestMetricCollector) {
    super(credentialsProvider, clientConfig, requestMetricCollector);
    assertParameterNotNull(kekMaterialsProvider,
            "EncryptionMaterialsProvider parameter must not be null.");
    assertParameterNotNull(cryptoConfig,
            "CryptoConfiguration parameter must not be null.");
    this.isKMSClientInternal = kms == null;
    this.kms = isKMSClientInternal 
        ? newAWSKMSClient(credentialsProvider, clientConfig, cryptoConfig, 
                requestMetricCollector)
        : kms;
    this.crypto = new CryptoModuleDispatcher(this.kms, new S3DirectImpl(),
            credentialsProvider, kekMaterialsProvider, cryptoConfig);
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:29,代碼來源:AmazonS3EncryptionClient.java

示例3: amazonCloudWatchClient

import com.amazonaws.auth.AWSCredentialsProvider; //導入依賴的package包/類
@Bean
public AmazonCloudWatch amazonCloudWatchClient(final AWSCredentialsProvider awsCredentialsProvider, 
    final ClientConfiguration awsClientConfig, final Region awsRegion) {
    return AmazonCloudWatchClientBuilder.standard()
        .withCredentials(awsCredentialsProvider)
        .withClientConfiguration(awsClientConfig)
        .withRegion(awsRegion.getName())
        .build();
}
 
開發者ID:shinesolutions,項目名稱:aem-orchestrator,代碼行數:10,代碼來源:AwsConfig.java

示例4: configure

import com.amazonaws.auth.AWSCredentialsProvider; //導入依賴的package包/類
@Override
public Credentials configure(final Host host) {
    final Credentials credentials = host.getCredentials();
    // Only for AWS
    if(host.getHostname().endsWith(PreferencesFactory.get().getProperty("s3.hostname.default"))) {
        if(!credentials.validate(host.getProtocol(), new LoginOptions(host.getProtocol()).password(false))) {
            // Lookup from default profile if no access key is set in bookmark
            for(AWSCredentialsProvider provider : providers) {
                try {
                    final AWSCredentials c = provider.getCredentials();
                    credentials.setUsername(c.getAWSAccessKeyId());
                    credentials.setPassword(c.getAWSSecretKey());
                    break;
                }
                catch(SdkClientException e) {
                    log.debug(String.format("Ignore failure loading credentials from provider %s", provider));
                    // Continue searching with next provider
                }
            }
        }
    }
    return credentials;
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:24,代碼來源:AWSCredentialsConfigurator.java

示例5: GenericDynamoDB

import com.amazonaws.auth.AWSCredentialsProvider; //導入依賴的package包/類
public GenericDynamoDB(AmazonDynamoDB client, AWSCredentialsProvider awsCredentials,
                       ClientConfiguration clientConfiguration,
                       SecretsGroupIdentifier groupIdentifier, Class<Entry> clazz, Converters converters,
                       ReadWriteLock readWriteLock) {
    this.clazz = clazz;
    buildMappings();
    this.converters = converters;
    this.awsCredentials = awsCredentials;
    this.clientConfiguration = clientConfiguration;
    this.client = client;
    this.region = RegionUtils.getRegion(groupIdentifier.region.getName());
    this.readWriteLock = readWriteLock;

    RegionLocalResourceName resourceName = new RegionLocalResourceName(groupIdentifier);
    this.tableName = resourceName.toString();
}
 
開發者ID:schibsted,項目名稱:strongbox,代碼行數:17,代碼來源:GenericDynamoDB.java

示例6: cleanUpKMSKeys

import com.amazonaws.auth.AWSCredentialsProvider; //導入依賴的package包/類
private static void cleanUpKMSKeys(Regions testRegion, String testResourcePrefix, Date createdBeforeThreshold,
                                   AWSCredentialsProvider awsCredentials) {
    LOG.info("Cleaning KMS...");

    AWSKMS kmsClient = AWSKMSClientBuilder.standard()
            .withCredentials(awsCredentials)
            .withRegion(testRegion)
            .build();

    List<AliasListEntry> keys = kmsClient.listAliases().getAliases();
    for (AliasListEntry entry: keys) {
        if (!entry.getAliasName().startsWith("alias/" + testResourcePrefix)) {
            continue;
        }

        DescribeKeyRequest request = new DescribeKeyRequest().withKeyId(entry.getTargetKeyId());
        KeyMetadata metadata = kmsClient.describeKey(request).getKeyMetadata();

        if (KMSKeyState.fromString(metadata.getKeyState()) != KMSKeyState.PENDING_DELETION &&
                metadata.getCreationDate().before(createdBeforeThreshold)) {
            LOG.info("Scheduling KMS key for deletion:" + entry.getAliasName());
            scheduleKeyDeletion(kmsClient, entry);
        }
    }
}
 
開發者ID:schibsted,項目名稱:strongbox,代碼行數:26,代碼來源:IntegrationTestHelper.java

示例7: setUp

import com.amazonaws.auth.AWSCredentialsProvider; //導入依賴的package包/類
@BeforeMethod
public void setUp() throws Exception {
    AWSCredentialsProvider mockCredentials = mock(AWSCredentialsProvider.class);
    ClientConfiguration mockConfig = mock(ClientConfiguration.class);
    SecretsGroupIdentifier group = new SecretsGroupIdentifier(Region.US_WEST_1, "test.group");

    this.mockAwsCrypto = mock(AwsCrypto.class);
    this.mockKmsManager = mock(KMSManager.class);
    KMSEncryptor encryptor = new KMSEncryptor(mockKmsManager, mockCredentials, mockConfig, group, mockAwsCrypto, EncryptionStrength.AES_256);

    this.kmsEncryptor = spy(encryptor);
    this.mockProvider = mock(KmsMasterKeyProvider.class);
    doReturn(mockProvider).when(kmsEncryptor).getProvider();

    // Verify the expected encryption algorithm was set.
    verify(mockAwsCrypto, times(1)).setEncryptionAlgorithm(
            CryptoAlgorithm.ALG_AES_256_GCM_IV12_TAG16_HKDF_SHA384_ECDSA_P384);
}
 
開發者ID:schibsted,項目名稱:strongbox,代碼行數:19,代碼來源:KMSEncryptorTest.java

示例8: Profile

import com.amazonaws.auth.AWSCredentialsProvider; //導入依賴的package包/類
public Profile(String profileName, String sourceProfile, AWSCredentialsProvider awsCredentials, RoleInfo roleInfo) {
    Map<String, String> properties = new LinkedHashMap<String, String>();
    properties.put(ProfileKeyConstants.SOURCE_PROFILE, sourceProfile);
    properties.put(ProfileKeyConstants.ROLE_ARN, roleInfo.getRoleArn());

    if (roleInfo.getRoleSessionName() != null) {
        properties.put(ProfileKeyConstants.ROLE_SESSION_NAME, roleInfo.getRoleSessionName());
    }

    if (roleInfo.getExternalId() != null) {
        properties.put(ProfileKeyConstants.EXTERNAL_ID, roleInfo.getExternalId());
    }

    this.profileName = profileName;
    this.properties = properties;
    this.awsCredentials = awsCredentials;
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:18,代碼來源:Profile.java

示例9: LinkGeneratorLambdaHandler

import com.amazonaws.auth.AWSCredentialsProvider; //導入依賴的package包/類
LinkGeneratorLambdaHandler(String region, String jwtEncryptKeyArn, String pageStorageBucket, String authVerifyEndpointURL,
                           AWSCredentialsProvider awsCredential, String introPageTemplateName) throws IOException, TemplateException {
    AWSKMS kmsClient = AWSKMSClientBuilder.standard()
            .withCredentials(awsCredential)
            .withRegion(region)
            .build();
    AmazonS3 s3client = AmazonS3ClientBuilder
            .standard()
            .withCredentials(awsCredential)
            .withRegion(region)
            .build();
    kmsEncrypt = new KMSEncrypt(kmsClient, jwtEncryptKeyArn);
    this.pageStorageBucket = pageStorageBucket;
    this.authVerifyEndpointURL = authVerifyEndpointURL;
    this.pageUploader = new PageUploader(s3client, pageStorageBucket);


    this.introPageTemplate = new IntroPageTemplate(introPageTemplateName);
}
 
開發者ID:julianghionoiu,項目名稱:tdl-auth,代碼行數:20,代碼來源:LinkGeneratorLambdaHandler.java

示例10: GetMediaWorker

import com.amazonaws.auth.AWSCredentialsProvider; //導入依賴的package包/類
private GetMediaWorker(Regions region,
        AWSCredentialsProvider credentialsProvider,
        String streamName,
        StartSelector startSelector,
        String endPoint,
        MkvElementVisitor elementVisitor) {
    super(region, credentialsProvider, streamName);

    AmazonKinesisVideoMediaClientBuilder builder = AmazonKinesisVideoMediaClientBuilder.standard()
            .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endPoint, region.getName()))
            .withCredentials(getCredentialsProvider());

    this.videoMedia = builder.build();
    this.elementVisitor = elementVisitor;
    this.startSelector = startSelector;
}
 
開發者ID:aws,項目名稱:amazon-kinesis-video-streams-parser-library,代碼行數:17,代碼來源:GetMediaWorker.java

示例11: AWSRequestSigningApacheInterceptor

import com.amazonaws.auth.AWSCredentialsProvider; //導入依賴的package包/類
/**
 *
 * @param service service that we're connecting to
 * @param signer particular signer implementation
 * @param awsCredentialsProvider source of AWS credentials for signing
 */
public AWSRequestSigningApacheInterceptor(final String service,
                            final Signer signer,
                            final AWSCredentialsProvider awsCredentialsProvider) {
    this.service = service;
    this.signer = signer;
    this.awsCredentialsProvider = awsCredentialsProvider;
}
 
開發者ID:awslabs,項目名稱:aws-request-signing-apache-interceptor,代碼行數:14,代碼來源:AWSRequestSigningApacheInterceptor.java

示例12: testCredentialsSetInRequestContext

import com.amazonaws.auth.AWSCredentialsProvider; //導入依賴的package包/類
@Test
public void testCredentialsSetInRequestContext() throws Exception {
    EasyMock.reset(httpClient);
    EasyMock
            .expect(httpClient.execute(EasyMock.<HttpRequestBase>anyObject(), EasyMock.<HttpContext>anyObject()))
            .andReturn(createBasicHttpResponse())
            .once();
    EasyMock.replay(httpClient);

    AmazonHttpClient client = new AmazonHttpClient(new ClientConfiguration(), httpClient, null);

    final BasicAWSCredentials credentials = new BasicAWSCredentials("foo", "bar");

    AWSCredentialsProvider credentialsProvider = EasyMock.createMock(AWSCredentialsProvider.class);
    EasyMock.expect(credentialsProvider.getCredentials())
            .andReturn(credentials)
            .anyTimes();
    EasyMock.replay(credentialsProvider);

    ExecutionContext executionContext = new ExecutionContext();
    executionContext.setCredentialsProvider(credentialsProvider);

    Request<?> request = mockRequest(SERVER_NAME, HttpMethodName.PUT, URI_NAME, true);

    HttpResponseHandler<AmazonWebServiceResponse<Object>> handler = createStubResponseHandler();
    EasyMock.replay(handler);

    client.execute(request, handler, null, executionContext);

    assertEquals(credentials, request.getHandlerContext(HandlerContextKey.AWS_CREDENTIALS));
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:32,代碼來源:AmazonHttpClientTest.java

示例13: sqsConnection

import com.amazonaws.auth.AWSCredentialsProvider; //導入依賴的package包/類
@Bean
public SQSConnection sqsConnection(final AWSCredentialsProvider awsCredentialsProvider,
    final ClientConfiguration awsClientConfig, final Region awsRegion) throws JMSException {
    
    SQSConnectionFactory connectionFactory = SQSConnectionFactory.builder()
        .withRegion(awsRegion) //Gets region form meta data
        .withAWSCredentialsProvider(awsCredentialsProvider)
        .withClientConfiguration(awsClientConfig)
        .build();

    return connectionFactory.createConnection();
}
 
開發者ID:shinesolutions,項目名稱:aem-orchestrator,代碼行數:13,代碼來源:AwsConfig.java

示例14: amazonEC2Client

import com.amazonaws.auth.AWSCredentialsProvider; //導入依賴的package包/類
@Bean
public AmazonEC2 amazonEC2Client(final AWSCredentialsProvider awsCredentialsProvider,
    final ClientConfiguration awsClientConfig, final Region awsRegion) {
    return AmazonEC2ClientBuilder.standard()
        .withCredentials(awsCredentialsProvider)
        .withClientConfiguration(awsClientConfig)
        .withRegion(awsRegion.getName())
        .build();
}
 
開發者ID:shinesolutions,項目名稱:aem-orchestrator,代碼行數:10,代碼來源:AwsConfig.java

示例15: amazonElbClient

import com.amazonaws.auth.AWSCredentialsProvider; //導入依賴的package包/類
@Bean
public AmazonElasticLoadBalancing amazonElbClient(final AWSCredentialsProvider awsCredentialsProvider,
    final ClientConfiguration awsClientConfig, final Region awsRegion) {
    return AmazonElasticLoadBalancingClientBuilder.standard()
        .withCredentials(awsCredentialsProvider)
        .withClientConfiguration(awsClientConfig)
        .withRegion(awsRegion.getName())
        .build();
}
 
開發者ID:shinesolutions,項目名稱:aem-orchestrator,代碼行數:10,代碼來源:AwsConfig.java


注:本文中的com.amazonaws.auth.AWSCredentialsProvider類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。