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


Java DefaultAWSCredentialsProviderChain類代碼示例

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


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

示例1: retrieve

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; //導入依賴的package包/類
@Override
public String retrieve(String file) throws Exception {
	LogUtils.debug(LOG_TAG, "Downloading file: " + file);
       TransferManager tm = new TransferManager(new DefaultAWSCredentialsProviderChain());
       // TransferManager processes all transfers asynchronously, 
       // so this call will return immediately.
       File downloadedFile = new File(Constants.MCSFS_WORKING_DIR + Constants.S3_WORKING_DIR + file + System.currentTimeMillis());
	downloadedFile.getParentFile().mkdirs();
	downloadedFile.createNewFile();
	Download download = tm.download(bucketName, file, downloadedFile);
       download.waitForCompletion();
       LogUtils.debug(LOG_TAG, "Successfully downloaded file from bucket.\nName: " + file + "\nBucket name: " +
               bucketName);
       tm.shutdownNow();
	return downloadedFile.getAbsolutePath();
}
 
開發者ID:darshanmaiya,項目名稱:MCSFS,代碼行數:17,代碼來源:S3Store.java

示例2: createRepository

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; //導入依賴的package包/類
public static ContentRepository createRepository(boolean reset) {
    if (isDynamoDBStore()) {
        AmazonDynamoDBClient dynamodb = new AmazonDynamoDBClient(new DefaultAWSCredentialsProviderChain());
        dynamodb.setEndpoint("http://localhost:8000");
        performReset(reset, dynamodb);
        NodeStore store = new DocumentMK.Builder()
                .setDynamoDB(dynamodb)
                .open().getNodeStore();
        return new Oak(store)
                .with(new InitialContent())
                .with(new OpenSecurityProvider())
                .createContentRepository();

    }
    return null;
}
 
開發者ID:denismo,項目名稱:jackrabbit-dynamodb-store,代碼行數:17,代碼來源:DynamoDBStoreBaseTest.java

示例3: get

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; //導入依賴的package包/類
@Override
public Credentials get() {
    if (getIdentity() == null || getIdentity().trim().isEmpty() || getCredential() == null || getCredential().trim().isEmpty()) {
        DefaultAWSCredentialsProviderChain chain = new DefaultAWSCredentialsProviderChain();

        AWSCredentials cred = chain.getCredentials();

        if (cred instanceof BasicSessionCredentials) {
            BasicSessionCredentials sesCred = (BasicSessionCredentials)cred;

            return new SessionCredentials.Builder()
                .identity(sesCred.getAWSAccessKeyId())
                .credential(sesCred.getAWSSecretKey())
                .sessionToken(sesCred.getSessionToken())
                .build();
        } else {
            return new Credentials.Builder<>()
                .identity(cred.getAWSAccessKeyId())
                .credential(cred.getAWSSecretKey())
                .build();
        }
    }

    return super.get();
}
 
開發者ID:hekate-io,項目名稱:hekate,代碼行數:26,代碼來源:AwsCredentialsSupplier.java

示例4: createSQSAsync

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; //導入依賴的package包/類
@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;
}
 
開發者ID:riboseinc,項目名稱:aws-codecommit-trigger-plugin,代碼行數:9,代碼來源:SQSFactoryImpl.java

示例5: cleanUpFromPreviousRuns

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; //導入依賴的package包/類
public static void cleanUpFromPreviousRuns(Regions testRegion, String groupPrefix) {
    LOG.info("Cleaning up from previous test runs...");

    // Get time an hour ago to clean up anything that was created more than an hour ago. That should be more than
    // enough time for test runs so anything left over by that time will be junk to clean up.
    Date createdBeforeThreshold = new Date(System.currentTimeMillis() - (60 * 60 * 1000));

    // Resource prefix for the test groups so we only clean up the resources related to the tests.
    // TODO is there a method somewhere that will construct this for me so it will always match the
    // actual names constructed by the code?
    String testResourcePrefix = String.format(
            "strongbox_%s_%s", testRegion.getName(),
            AWSResourceNameSerialization.encodeSecretsGroupName(groupPrefix));

    AWSCredentialsProvider awsCredentials = new DefaultAWSCredentialsProviderChain();

    cleanUpDynamoDBTables(testRegion, testResourcePrefix, createdBeforeThreshold, awsCredentials);
    cleanUpKMSKeys(testRegion, testResourcePrefix, createdBeforeThreshold, awsCredentials);
    cleanUpIAM(testRegion, testResourcePrefix, createdBeforeThreshold, awsCredentials);
}
 
開發者ID:schibsted,項目名稱:strongbox,代碼行數:21,代碼來源:IntegrationTestHelper.java

示例6: remove

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; //導入依賴的package包/類
@Override
public void remove(String accessKey) throws Exception {
	LogUtils.debug(LOG_TAG, "Deleting file with access key: " + accessKey);
	AmazonS3 s3Client = new AmazonS3Client(new DefaultAWSCredentialsProviderChain());
	DeleteObjectsRequest multiObjectDeleteRequest = new DeleteObjectsRequest(bucketName);
	
	List<KeyVersion> keys = new ArrayList<KeyVersion>();
	keys.add(new KeyVersion(accessKey));
	keys.add(new KeyVersion(accessKey + "_key"));
	        
	multiObjectDeleteRequest.setKeys(keys);

	s3Client.deleteObjects(multiObjectDeleteRequest);

	LogUtils.debug(LOG_TAG, "Deleted file with access key: " + accessKey);
}
 
開發者ID:darshanmaiya,項目名稱:MCSFS,代碼行數:17,代碼來源:S3Store.java

示例7: createSnapshotFromTagName

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; //導入依賴的package包/類
public void createSnapshotFromTagName(TagNameRequest tagNameRequest, Context context) {

		LambdaLogger logger = context.getLogger();
		logger.log("create ebs snapshot from tag name Start. backup target[" + tagNameRequest + "]");

		String regionName = System.getenv("AWS_DEFAULT_REGION");
		AmazonEC2Async client = RegionUtils.getRegion(regionName).createClient(AmazonEC2AsyncClient.class,
				new DefaultAWSCredentialsProviderChain(), cc);

		try {
			List<Volume> volumes = describeBackupVolumes(client, tagNameRequest);

			for (Volume volume : volumes) {
				createSnapshot(volume.getVolumeId(), tagNameRequest.getGenerationCount(), context);
			}
		} finally {
			client.shutdown();
		}
	}
 
開發者ID:uzresk,項目名稱:aws-auto-operations-using-lambda,代碼行數:20,代碼來源:EBSSnapshotFunction.java

示例8: whenCustomCredentialsSet_theyAreUsed

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; //導入依賴的package包/類
@Test
public void whenCustomCredentialsSet_theyAreUsed() throws Exception {
    AWSCredentialsProvider customProvider = spy(new DefaultAWSCredentialsProviderChain());

    KmsMasterKeyProvider mkp = KmsMasterKeyProvider.builder()
                                                   .withCredentials(customProvider)
                                                   .withKeysForEncryption(KMSTestFixtures.TEST_KEY_IDS[0])
                                                   .build();

    new AwsCrypto().encryptData(mkp, new byte[1]);

    verify(customProvider, atLeastOnce()).getCredentials();

    AWSCredentials customCredentials = spy(customProvider.getCredentials());

    mkp = KmsMasterKeyProvider.builder()
                                                   .withCredentials(customCredentials)
                                                   .withKeysForEncryption(KMSTestFixtures.TEST_KEY_IDS[0])
                                                   .build();

    new AwsCrypto().encryptData(mkp, new byte[1]);

    verify(customCredentials, atLeastOnce()).getAWSSecretKey();
}
 
開發者ID:awslabs,項目名稱:aws-encryption-sdk-java,代碼行數:25,代碼來源:KMSProviderBuilderIntegrationTests.java

示例9: credentials

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; //導入依賴的package包/類
/** By default, get credentials from the {@link DefaultAWSCredentialsProviderChain} */
@Bean
@ConditionalOnMissingBean
AWSCredentials.Provider credentials() {
  return new AWSCredentials.Provider() {
    AWSCredentialsProvider delegate = new DefaultAWSCredentialsProviderChain();

    @Override public AWSCredentials get() {
      com.amazonaws.auth.AWSCredentials result = delegate.getCredentials();
      String sessionToken = result instanceof AWSSessionCredentials
          ? ((AWSSessionCredentials) result).getSessionToken()
          : null;
      return new AWSCredentials(
          result.getAWSAccessKeyId(),
          result.getAWSSecretKey(),
          sessionToken
      );
    }
  };
}
 
開發者ID:liaominghua,項目名稱:zipkin,代碼行數:21,代碼來源:ZipkinElasticsearchAwsStorageAutoConfiguration.java

示例10: setUp

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; //導入依賴的package包/類
@Before
public void setUp() {
    PowerMockito.mockStatic(CredentialsMatchers.class);
    PowerMockito.mockStatic(SystemCredentialsProvider.class);
    PowerMockito.mockStatic(DefaultAWSCredentialsProviderChain.class);
    when(CredentialsMatchers.firstOrNull(any(Iterable.class), any(CredentialsMatcher.class))).thenReturn(mockCBCreds);
    when(mockCBCreds.getCredentials()).thenReturn(mockAWSCreds);
    when(mockCBCreds.getCredentialsDescriptor()).thenReturn(codeBuildDescriptor);
    when(mockCBCreds.getProxyHost()).thenReturn(proxyHost);
    when(mockCBCreds.getProxyPort()).thenReturn(proxyPort);

    when(mockAWSCreds.getAWSAccessKeyId()).thenReturn("a");
    when(mockAWSCreds.getAWSSecretKey()).thenReturn("s");
    when(SystemCredentialsProvider.getInstance()).thenReturn(mockSysCreds);

    when(DefaultAWSCredentialsProviderChain.getInstance()).thenReturn(cpChain);
}
 
開發者ID:awslabs,項目名稱:aws-codebuild-jenkins-plugin,代碼行數:18,代碼來源:AWSClientFactoryTest.java

示例11: setup

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; //導入依賴的package包/類
public void setup() {
    AWSCredentialsProvider awsCredentialsProvider = new DefaultAWSCredentialsProviderChain();
    try {
        awsCredentialsProvider.getCredentials();

        s3Bucket = System.getenv("CLOUDKEEPER_S3_TEST_BUCKET");
        if (s3Bucket == null) {
            s3Bucket = System.getProperty("xyz.cloudkeeper.s3.testbucket");
        }

        if (s3Bucket != null) {
            executorService = Executors.newScheduledThreadPool(4);

            AmazonS3 s3Client = new AmazonS3Client(awsCredentialsProvider);
            s3Connection = new S3ConnectionBuilder(s3Client, executorService).build();
            skipTest = false;

            cleanS3(s3Connection, s3Bucket);
        }
    } catch (AmazonClientException exception) {
        credentialsException = exception;
    }
}
 
開發者ID:cloudkeeper-project,項目名稱:cloudkeeper,代碼行數:24,代碼來源:ITS3StagingArea.java

示例12: initEncryptedConfigStoreService

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; //導入依賴的package包/類
private void initEncryptedConfigStoreService() {
    if (encryptedConfigStoreService == null) {
        final Environment environment = getEnvironmentData();

        KMSEncryptionMaterialsProvider materialProvider =
                new KMSEncryptionMaterialsProvider(environment.getConfigKeyId());

        AmazonS3EncryptionClient encryptionClient =
                new AmazonS3EncryptionClient(
                        new DefaultAWSCredentialsProviderChain(),
                        materialProvider,
                        new CryptoConfiguration()
                                .withAwsKmsRegion(Region.getRegion(environmentMetadata.getRegions())))
                        .withRegion(Region.getRegion(environmentMetadata.getRegions()));

        encryptedConfigStoreService = new S3StoreService(encryptionClient, environmentMetadata.getBucketName(), "");
    }
}
 
開發者ID:Nike-Inc,項目名稱:cerberus-lifecycle-cli,代碼行數:19,代碼來源:ConfigStore.java

示例13: sendDataToKinesis

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; //導入依賴的package包/類
private void sendDataToKinesis() {
    AWSCredentialsProvider credentialsProvider = new
            DefaultAWSCredentialsProviderChain();

    AmazonKinesisClient amazonKinesisClient = new AmazonKinesisClient(credentialsProvider);
    amazonKinesisClient.setRegion(Region.getRegion(Regions.fromName("eu-west-1")));

    PutRecordsRequest putRecordsRequest = new PutRecordsRequest();
    putRecordsRequest.setStreamName(TestConstants.stream);
    List<PutRecordsRequestEntry> putRecordsRequestEntryList = new ArrayList<>();
    PutRecordsRequestEntry putRecordsRequestEntry = new PutRecordsRequestEntry();
    putRecordsRequestEntry.setData(ByteBuffer.wrap(String.valueOf("This is just a test").getBytes()));
    putRecordsRequestEntry.setPartitionKey("partitionKey-1");
    putRecordsRequestEntryList.add(putRecordsRequestEntry);

    putRecordsRequest.setRecords(putRecordsRequestEntryList);
    PutRecordsResult putRecordsResult = amazonKinesisClient.putRecords(putRecordsRequest);
    logger.info("Put Result" + putRecordsResult);
}
 
開發者ID:SaschaMoellering,項目名稱:ingestion-service,代碼行數:20,代碼來源:KafkaKinesisIntegrationTest.java

示例14: startKinesisConsumer

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; //導入依賴的package包/類
private void startKinesisConsumer() throws Exception {
    AWSCredentialsProvider credentialsProvider = new
            DefaultAWSCredentialsProviderChain();

    String region = "eu-west-1";
    logger.info("Starting in Region " + region);

    String workerId = InetAddress.getLocalHost().getCanonicalHostName() + ":" + UUID.randomUUID();

    KinesisClientLibConfiguration kinesisClientLibConfiguration = new KinesisClientLibConfiguration(
            this.getClass().getName(), TestConstants.stream, credentialsProvider, workerId)
            .withInitialPositionInStream(InitialPositionInStream.LATEST).withRegionName(region);

    IRecordProcessorFactory recordProcessorFactory = new
            RecordFactory();
    worker = new Worker(recordProcessorFactory,
            kinesisClientLibConfiguration);

    es = Executors.newSingleThreadExecutor();
    es.execute(worker);
}
 
開發者ID:SaschaMoellering,項目名稱:ingestion-service,代碼行數:22,代碼來源:KafkaKinesisIntegrationTest.java

示例15: deleteKinesisStream

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; //導入依賴的package包/類
private void deleteKinesisStream() {
    AWSCredentialsProvider credentialsProvider = new
            DefaultAWSCredentialsProviderChain();

    AmazonKinesisClient amazonKinesisClient = new AmazonKinesisClient(credentialsProvider);
    amazonKinesisClient.setRegion(Region.getRegion(Regions.fromName("eu-west-1")));

    DeleteStreamRequest createStreamRequest = new DeleteStreamRequest();
    createStreamRequest.setStreamName(TestConstants.stream);

    amazonKinesisClient.deleteStream(createStreamRequest);

    DescribeStreamRequest describeStreamRequest = new DescribeStreamRequest();
    describeStreamRequest.setStreamName(TestConstants.stream);

    logger.info("Stream " + TestConstants.stream + " deleted");
}
 
開發者ID:SaschaMoellering,項目名稱:ingestion-service,代碼行數:18,代碼來源:KafkaKinesisIntegrationTest.java


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