Java 类com.amazonaws.auth.DefaultAWSCredentialsProviderChain 实例源码

项目:hekate    文件:AwsCredentialsSupplier.java   
@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();
}
项目:strongbox    文件:IntegrationTestHelper.java   
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);
}
项目:MCSFS    文件:S3Store.java   
@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();
}
项目:MCSFS    文件:S3Store.java   
@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);
}
项目:aws-auto-operations-using-lambda    文件:EBSSnapshotFunction.java   
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();
        }
    }
项目:aws-encryption-sdk-java    文件:KMSProviderBuilderIntegrationTests.java   
@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();
}
项目:zipkin    文件:ZipkinElasticsearchAwsStorageAutoConfiguration.java   
/** 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
      );
    }
  };
}
项目:aws-codebuild-jenkins-plugin    文件:AWSClientFactoryTest.java   
@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);
}
项目:cloudkeeper    文件:ITS3StagingArea.java   
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;
    }
}
项目:cerberus-lifecycle-cli    文件:ConfigStore.java   
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(), "");
    }
}
项目:ingestion-service    文件:KafkaKinesisIntegrationTest.java   
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);
}
项目:ingestion-service    文件:KafkaKinesisIntegrationTest.java   
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);
}
项目:ingestion-service    文件:KafkaKinesisIntegrationTest.java   
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");
}
项目:herd    文件:S3DaoImpl.java   
/**
 * <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()]));
}
项目:dynamodb-streams-kafka    文件:KafkaDynamoStreamAdapter.java   
public KafkaDynamoStreamAdapter(String regionName, String srcTable, IRecordProcessorFactory processorFactory) {
    sourceTable = srcTable;
    credentialsProvider = new DefaultAWSCredentialsProviderChain();
    recordProcessorFactory = processorFactory;

    adapterClient = new AmazonDynamoDBStreamsAdapterClient(credentialsProvider, new ClientConfiguration());
    dynamoDBClient = new AmazonDynamoDBClient(credentialsProvider, new ClientConfiguration());
    cloudWatchClient = new AmazonCloudWatchClient(credentialsProvider, new ClientConfiguration());

    if ("local".equalsIgnoreCase(regionName)) {
        setClientEndpoints(localddbEndpoint);
    } else if (regionName != null) {
        Region region = Region.getRegion(Regions.fromName(regionName));
        adapterClient.setRegion(region);
        dynamoDBClient.setRegion(region);
        cloudWatchClient.setRegion(region);
    }
}
项目:bamboo-opsworks    文件:ConfigurationMapCredentialsProvider.java   
@Override
public AWSCredentials getCredentials() {
    // if profile is specified, use that
    final String profile = configuration.get(AWSConstants.PROFILE);
    if(!StringUtils.isNullOrEmpty(profile)) {
        return new ProfileCredentialsProvider(profile).getCredentials();
    }

    // then try access key and secret
    final String accessKeyId = configuration.get(AWSConstants.ACCESS_KEY_ID);
    final String secretAccessKey = configuration.get(AWSConstants.SECRET_ACCESS_KEY);
    if(!StringUtils.isNullOrEmpty(accessKeyId) && !StringUtils.isNullOrEmpty(secretAccessKey)) {
        return new BasicAWSCredentials(accessKeyId, secretAccessKey);
    }

    // fall back to default
    return new DefaultAWSCredentialsProviderChain().getCredentials();
}
项目:presto-kinesis    文件:KinesisClientManager.java   
@Inject
KinesisClientManager(KinesisConnectorConfig kinesisConnectorConfig)
{
    log.info("Creating new client for Consumer");
    if (nonEmpty(kinesisConnectorConfig.getAccessKey()) && nonEmpty(kinesisConnectorConfig.getSecretKey())) {
        this.kinesisAwsCredentials = new KinesisAwsCredentials(kinesisConnectorConfig.getAccessKey(), kinesisConnectorConfig.getSecretKey());
        this.client = new AmazonKinesisClient(this.kinesisAwsCredentials);
        this.amazonS3Client = new AmazonS3Client(this.kinesisAwsCredentials);
        this.dynamoDBClient = new AmazonDynamoDBClient(this.kinesisAwsCredentials);
    }
    else {
        this.kinesisAwsCredentials = null;
        DefaultAWSCredentialsProviderChain defaultChain = new DefaultAWSCredentialsProviderChain();
        this.client = new AmazonKinesisClient(defaultChain);
        this.amazonS3Client = new AmazonS3Client(defaultChain);
        this.dynamoDBClient = new AmazonDynamoDBClient(defaultChain);
    }

    this.client.setEndpoint("kinesis." + kinesisConnectorConfig.getAwsRegion() + ".amazonaws.com");
    this.dynamoDBClient.setEndpoint("dynamodb." + kinesisConnectorConfig.getAwsRegion() + ".amazonaws.com");
}
项目:jackrabbit-dynamodb-store    文件:DynamoDBStoreBaseTest.java   
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;
}
项目:amazon-kinesis-aggregators    文件:SensorReadingProducer.java   
private void run(final int events, final OutputFormat format,
        final String streamName, final String region) throws Exception {
    AmazonKinesis kinesisClient = new AmazonKinesisClient(
            new DefaultAWSCredentialsProviderChain());
    kinesisClient.setRegion(Region.getRegion(Regions.fromName(region)));
    int count = 0;
    SensorReading r = null;
    do {
        r = nextSensorReading(format);

        try {
            PutRecordRequest req = new PutRecordRequest()
                    .withPartitionKey("" + rand.nextLong())
                    .withStreamName(streamName)
                    .withData(ByteBuffer.wrap(r.toString().getBytes()));
            kinesisClient.putRecord(req);
        } catch (ProvisionedThroughputExceededException e) {
            Thread.sleep(BACKOFF);
        }

        System.out.println(r);
        count++;
    } while (count < events);
}
项目:mrgeo    文件:HadoopFileUtils.java   
/**
 * Return an AmazonS3Client set up with the proper endpoint
 * defined in core-site.xml using a property like fs.s3a.endpoint.
 * This mimics code found in S3AFileSystem.
 *
 * @param conf
 * @param scheme
 * @return
 */
private static AmazonS3Client getS3Client(Configuration conf, String scheme)
{
  AmazonS3Client s3Client = new AmazonS3Client(new DefaultAWSCredentialsProviderChain());
  String endpointKey = "fs." + scheme.toLowerCase() + ".endpoint";
  String endPoint = conf.getTrimmed(endpointKey,"");
  log.debug("Using endpoint setting " + endpointKey);
  if (!endPoint.isEmpty()) {
    try {
      log.debug("Setting S3 client endpoint to " + endPoint);
      s3Client.setEndpoint(endPoint);
    } catch (IllegalArgumentException e) {
      String msg = "Incorrect endpoint: "  + e.getMessage();
      log.error(msg);
      throw new IllegalArgumentException(msg, e);
    }
  }
  return s3Client;
}
项目:route53-dynamic-dns    文件:UpdateDns.java   
public static void main(String[] args) throws IOException {
    Arguments arguments = new Arguments();
    CmdLineParser parser = new CmdLineParser(arguments);
    try {
        parser.parseArgument(args);
    } catch (CmdLineException e) {
        System.err.println("Usage: java -jar dyndns.jar <arguments>");
        parser.printUsage(System.err);
        System.exit(1);
    }

    AmazonRoute53 route53 = new AmazonRoute53Client(new DefaultAWSCredentialsProviderChain());

    UpdateDns updateDns = new UpdateDns(route53, arguments.hostedZoneId);
    updateDns.updateDns(arguments.recordSetName, arguments.force);
}
项目:cfnassist    文件:TestPictureGeneration.java   
@Before
public void beforeEachTestRuns() {
    AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain();
    AmazonEC2 ec2Client = EnvironmentSetupForTests.createEC2Client();
    AmazonElasticLoadBalancing awsElbClient = EnvironmentSetupForTests.createELBClient();
    AmazonCloudFormation cfnClient = EnvironmentSetupForTests.createCFNClient();
    AmazonRDS awsRdsClient = EnvironmentSetupForTests.createRDSClient();

    CloudClient cloudClient = new CloudClient(ec2Client, new DefaultAwsRegionProviderChain());
    LoadBalancerClient elbClient = new LoadBalancerClient(awsElbClient);
    VpcRepository vpcRepository = new VpcRepository(cloudClient);

    CloudFormationClient cloudFormationClient = new CloudFormationClient(cfnClient);
    cloudRepository = new CloudRepository(cloudClient);
    ResourceRepository cfnRepository = new CfnRepository(cloudFormationClient, cloudRepository, "CfnAssist");

    elbRepository = new ELBRepository(elbClient, vpcRepository, cfnRepository);
    rdsClient = new RDSClient(awsRdsClient);
}
项目:storm-crawler    文件:AbstractS3CacheBolt.java   
/** Returns an S3 client given the configuration **/
public static AmazonS3Client getS3Client(Map conf) {
    AWSCredentialsProvider provider = new DefaultAWSCredentialsProviderChain();
    AWSCredentials credentials = provider.getCredentials();
    ClientConfiguration config = new ClientConfiguration();

    AmazonS3Client client = new AmazonS3Client(credentials, config);

    String regionName = ConfUtils.getString(conf, REGION);
    if (StringUtils.isNotBlank(regionName)) {
        client.setRegion(RegionUtils.getRegion(regionName));
    }

    String endpoint = ConfUtils.getString(conf, ENDPOINT);
    if (StringUtils.isNotBlank(endpoint)) {
        client.setEndpoint(endpoint);
    }
    return client;
}
项目:carina    文件:AmazonS3Manager.java   
/**
 * Method to download file from s3 to local file system
 * @param bucketName AWS S3 bucket name
 * @param key (example: android/apkFolder/ApkName.apk)
 * @param file (local file name)
 * @param pollingInterval (polling interval in sec for S3 download status determination)
 */
public void download(final String bucketName, final String key, final File file, long pollingInterval) {
    LOGGER.info("App will be downloaded from s3.");
    LOGGER.info(String.format("[Bucket name: %s] [Key: %s] [File: %s]", bucketName, key, file.getAbsolutePath()));
    DefaultAWSCredentialsProviderChain credentialProviderChain = new DefaultAWSCredentialsProviderChain();
    TransferManager tx = new TransferManager(
                   credentialProviderChain.getCredentials());
    Download appDownload = tx.download(bucketName, key, file);
    try {
        LOGGER.info("Transfer: " + appDownload.getDescription());
        LOGGER.info("   State: " + appDownload.getState());
        LOGGER.info("   Progress: ");
        // You can poll your transfer's status to check its progress
        while (!appDownload.isDone()) {
            LOGGER.info("       transferred: " +(int) (appDownload.getProgress().getPercentTransferred() + 0.5) + "%" );
            CommonUtils.pause(pollingInterval);
        }
        LOGGER.info("   State: " + appDownload.getState());
        //appDownload.waitForCompletion();
    } catch (AmazonClientException e) {
        throw new RuntimeException("File wasn't downloaded from s3. See log: ".concat(e.getMessage()));
    }
    //tx.shutdownNow();
}
项目:aws-hal-client-java    文件:HalService.java   
private HalClient getHalClient() {
    if (halClient == null) {
        this.halClient = new HalClient(clientConfiguration == null ? new ClientConfiguration() : clientConfiguration,
                                       endpoint,
                                       serviceName,
                                       awsCredentialsProvider == null ? new DefaultAWSCredentialsProviderChain() : awsCredentialsProvider,
                                       resourceCache == null ? ImmediatelyExpiringCache.getInstance() : resourceCache,
                                       errorResponseHandler);

        if (regionId != null) {
            halClient.setSignerRegionOverride(regionId);
        }
    }

    return halClient;
}
项目:skid-road    文件:RequestLogUploadConfiguration.java   
public AWSCredentialsProvider getAWSCredentialsProvider() {
    if (StringUtils.isNotBlank(accessKeyID)) {
        return new AWSCredentialsProvider() {
            @Override
            public AWSCredentials getCredentials() {
                return new BasicAWSCredentials(accessKeyID,secretAccessKey);
            }

            @Override
            public void refresh() {
                // no op
            }
        };
    }
    return new DefaultAWSCredentialsProviderChain();
}
项目:secrets-locker    文件:KmsDecryptionService.java   
/**
 * {@inheritDoc }
 */
@Override
public void decryptFile(
        final String encryptedFilename, 
        final String decryptedFilename) {

    final KmsMasterKeyProvider provider
            = new KmsMasterKeyProvider(
                    new DefaultAWSCredentialsProviderChain());

    final AwsCrypto awsCrypto
            = new AwsCrypto();

    try (final FileInputStream fileInputStream
            = new FileInputStream(
                    encryptedFilename);

            final FileOutputStream fileOutputStream
                    = new FileOutputStream(
                            decryptedFilename);

            final CryptoInputStream<?> decryptingStream
                    = awsCrypto
                            .createDecryptingStream(
                                    provider, 
                                    fileInputStream)) {

        IOUtils.copy(
                decryptingStream,
                fileOutputStream);

    } catch (IOException exception) {
        throw new DecryptionException(exception);
    }
}
项目:secrets-locker    文件:KmsDecryptionService.java   
/**
 * {@inheritDoc }
 */
@Override
public String decryptFile(
        final String encryptedFilename) {

    final KmsMasterKeyProvider provider
            = new KmsMasterKeyProvider(
                    new DefaultAWSCredentialsProviderChain());

    final AwsCrypto awsCrypto
            = new AwsCrypto();

    try (final FileInputStream fileInputStream
            = new FileInputStream(
                    encryptedFilename);

            final CryptoInputStream<?> decryptingStream
                    = awsCrypto
                            .createDecryptingStream(
                                    provider, 
                                    fileInputStream)) {

        return IOUtils.toString(
                decryptingStream);

    } catch (IOException exception) {
        throw new DecryptionException(exception);
    }
}
项目:secrets-locker    文件:KmsEncryptionService.java   
private MasterKeyProvider<?> masterKeyProvider() {

        final AWSCredentialsProvider credentials
                = new DefaultAWSCredentialsProviderChain();

        List<KmsMasterKey> masterKeys
                = new LinkedList<>();

        for (String region : this.regions) {
            KmsMasterKeyProvider provider
                    = new KmsMasterKeyProvider(
                            credentials,
                            Region.getRegion(
                                    Regions.fromName(
                                            region)),
                            new ClientConfiguration(),
                            this.keyId);



            masterKeys.add(
                    provider.getMasterKey(
                            this.keyId));
        }

        return MultipleProviderFactory
                .buildMultiProvider(
                        masterKeys);
    }
项目:aem-stack-manager    文件:AwsConfig.java   
@Bean
public AWSCredentialsProvider awsCredentialsProvider() {
    /*
     * For info on how this works, see:
     * http://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/
     * credentials.html
     */
    return new DefaultAWSCredentialsProviderChain();
}
项目:aws-photosharing-example    文件:ContentFacadeTest.java   
@BeforeClass
public void initTest() throws IOException {
    userFacade = new UserFacade();
    contentFacade = new ContentFacade();
    s3Client = new AmazonS3Client(new DefaultAWSCredentialsProviderChain()).withRegion(Regions.EU_WEST_1);
    this.uploadDataToBucket();
}
项目:kinesis-kafka-connector    文件:AmazonKinesisSinkTask.java   
private KinesisProducer getKinesisProducer() {
    KinesisProducerConfiguration config = new KinesisProducerConfiguration();
    config.setRegion(regionName);
    config.setCredentialsProvider(new DefaultAWSCredentialsProviderChain());
    config.setMaxConnections(maxConnections);

    config.setAggregationEnabled(aggregration);

    // Limits the maximum allowed put rate for a shard, as a percentage of
    // the
    // backend limits.
    config.setRateLimit(rateLimit);

    // Maximum amount of time (milliseconds) a record may spend being
    // buffered
    // before it gets sent. Records may be sent sooner than this depending
    // on the
    // other buffering limits
    config.setRecordMaxBufferedTime(maxBufferedTime);

    // Set a time-to-live on records (milliseconds). Records that do not get
    // successfully put within the limit are failed.
    config.setRecordTtl(ttl);

    // Controls the number of metrics that are uploaded to CloudWatch.
    // Expected pattern: none|summary|detailed
    config.setMetricsLevel(metricsLevel);

    // Controls the granularity of metrics that are uploaded to CloudWatch.
    // Greater granularity produces more metrics.
    // Expected pattern: global|stream|shard
    config.setMetricsGranularity(metricsGranuality);

    // The namespace to upload metrics under.
    config.setMetricsNamespace(metricsNameSpace);

    return new KinesisProducer(config);

}
项目:aws-codecommit-trigger-plugin    文件:SQSFactoryImpl.java   
@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;
}
项目:strongbox    文件:StrongboxGUI.java   
public static void main(String[] args) {
    Singleton.secretsGroupManager = new DefaultSecretsGroupManager();
    Singleton.region = Region.EU_WEST_1;
    Singleton.randomGenerator = new KMSRandomGenerator();
    Singleton.principalAutoSuggestion = PrincipalAutoSuggestion.fromCredentials(new DefaultAWSCredentialsProviderChain(), new ClientConfiguration());
    StrongboxGUI strongboxGUI = new StrongboxGUI();
    strongboxGUI.run();
}
项目:ibm-cos-sdk-java    文件:S3CryptoModuleEO.java   
/**
 * Used for testing purposes only.
 */
S3CryptoModuleEO(S3Direct s3,
        EncryptionMaterialsProvider encryptionMaterialsProvider,
        CryptoConfiguration cryptoConfig) {
    this(null, s3, new DefaultAWSCredentialsProviderChain(),
            encryptionMaterialsProvider, cryptoConfig);
}
项目:ibm-cos-sdk-java    文件:S3CryptoModuleEO.java   
/**
 * Used for testing purposes only.
 */
S3CryptoModuleEO(AWSKMS kms, S3Direct s3,
        EncryptionMaterialsProvider encryptionMaterialsProvider,
        CryptoConfiguration cryptoConfig) {
    this(kms, s3, new DefaultAWSCredentialsProviderChain(),
            encryptionMaterialsProvider, cryptoConfig);
}
项目:ibm-cos-sdk-java    文件:S3CryptoModuleAE.java   
/**
 * Used for testing purposes only.
 */
S3CryptoModuleAE(S3Direct s3,
        EncryptionMaterialsProvider encryptionMaterialsProvider,
        CryptoConfiguration cryptoConfig) {
    this(null, s3, new DefaultAWSCredentialsProviderChain(),
            encryptionMaterialsProvider, cryptoConfig);
}
项目:ibm-cos-sdk-java    文件:S3CryptoModuleAE.java   
/**
 * Used for testing purposes only.
 */
S3CryptoModuleAE(AWSKMS kms, S3Direct s3,
                 EncryptionMaterialsProvider encryptionMaterialsProvider,
                 CryptoConfiguration cryptoConfig) {
    this(kms, s3, new DefaultAWSCredentialsProviderChain(),
            encryptionMaterialsProvider, cryptoConfig);
}
项目:jenkins-aws-bucket-credentials    文件:AwsS3ClientBuilder.java   
public AmazonS3Client build() {
    ClientConfiguration config = new ClientConfiguration();
    if (!Util.fixNull(host).trim().isEmpty()) {
        config.setProxyHost(this.host);
        config.setProxyPort(this.port);
    }
    AmazonS3Client client = new AmazonS3Client(new DefaultAWSCredentialsProviderChain(), config);
    if (!Util.fixNull(region).trim().isEmpty()) {
        client.setRegion(Region.getRegion(Regions.fromName(region)));
    }
    return client;
}
项目:jenkins-aws-bucket-credentials    文件:AwsKmsClientBuilder.java   
public AWSKMSClient build() {
    ClientConfiguration config = new ClientConfiguration();
    if (!Util.fixNull(host).trim().isEmpty()) {
        config.setProxyHost(this.host);
        config.setProxyPort(this.port);
    }
    AWSKMSClient client = new AWSKMSClient(new DefaultAWSCredentialsProviderChain(), config);
    if (!Util.fixNull(region).trim().isEmpty()) {
        client.setRegion(Region.getRegion(Regions.fromName(region)));
    }
    return client;
}