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

项目:detective    文件:AwsUtils.java   
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]));
}
项目:galaxy-fds-migration-tool    文件:S3Source.java   
@Override
public void init(Configuration conf, String keyPrefix) {
  bucketName = conf.get(keyPrefix + S3_BUCKET_NAME);
  String endpoint = conf.get(keyPrefix + S3_ENDPOINT_NAME);
  String key = conf.get(keyPrefix + S3_ACCESS_KEY);
  String secret = conf.get(keyPrefix + S3_ACCESS_SECRET);

  System.setProperty(SDKGlobalConfiguration.ACCESS_KEY_SYSTEM_PROPERTY, key);
  System.setProperty(SDKGlobalConfiguration.SECRET_KEY_SYSTEM_PROPERTY, secret);
  AWSCredentialsProvider provider = new SystemPropertiesCredentialsProvider();
  client = new AmazonS3Client(provider);
  client.setEndpoint(endpoint);
  override = conf.getBoolean(keyPrefix + "override", true);
  acls = new AccessControlList();
  acls.grantPermission(GroupGrantee.AllUsers, Permission.FullControl);
  acls.grantPermission(GroupGrantee.AllUsers, Permission.Read);
  acls.grantPermission(GroupGrantee.AllUsers, Permission.Write);
}
项目:cerberus-lifecycle-cli    文件:CerberusModule.java   
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;
}
项目:carina    文件:AmazonS3Manager.java   
public static AmazonS3Manager getInstance() {
    if (instance == null) {
        synchronized (AmazonS3Manager.class) {
            if (instance == null) {
                instance = new AmazonS3Manager();
                String accessKey = Configuration.get(Parameter.ACCESS_KEY_ID);
                String secretKey = Configuration.get(Parameter.SECRET_KEY);

                System.setProperty("aws.accessKeyId", accessKey);
                System.setProperty("aws.secretKey", secretKey);

                s3client = new AmazonS3Client(new SystemPropertiesCredentialsProvider());


            }
        }
    }
    return instance;
}
项目:aml    文件:ApiImporter.java   
@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);
}
项目:aws-iot-mqtt-load-generator    文件:MyCredentialsProvider.java   
MyCredentialsProvider() {
    super(new EnvironmentVariableCredentialsProvider(),
            new SystemPropertiesCredentialsProvider(),
            // Removed due to ElasticBeanstalk environment not being setup with a profile dir
            // new ProfileCredentialsProvider(),
            new InstanceProfileCredentialsProvider(),
            new ClasspathPropertiesFileCredentialsProvider());
}
项目:lambadaframework    文件:AuthenticationInfoAWSCredentialsProviderChain.java   
AuthenticationInfoAWSCredentialsProviderChain(AuthenticationInfo authenticationInfo) {
    super(
            new InstanceProfileCredentialsProvider(),
            new ProfileCredentialsProvider(),
            new EnvironmentVariableCredentialsProvider(),
            new SystemPropertiesCredentialsProvider(),
            new InstanceProfileCredentialsProvider());
}
项目:gradle-beanstalk-plugin    文件:DeployTask.java   
@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);
}
项目:logback-sqs    文件:SqsAppender.java   
/**
 * 
 * @return
 */
private AWSCredentialsProvider getCredentials() {
  return new AWSCredentialsProviderChain(new StaticCredentialsProvider(
      new AppenderCredentials()), new SystemPropertiesCredentialsProvider(),
      new EnvironmentVariableCredentialsProvider(),
      new ProfileCredentialsProvider(),
      new InstanceProfileCredentialsProvider());
}
项目:amediamanager    文件:ServerConfig.java   
@Bean
@Scope(WebApplicationContext.SCOPE_APPLICATION)
public AWSCredentialsProvider credentials() {
    return new AWSCredentialsProviderChain(
          new InstanceProfileCredentialsProvider(),
          new EnvironmentVariableCredentialsProvider(),
          new SystemPropertiesCredentialsProvider()
            );
}
项目:detective    文件:AwsServiceImpl.java   
private AWSCredentialsProvider createCredentialsProvider(){
  return new AWSCredentialsProviderChain(
      new InstanceProfileCredentialsProvider(),
      new EnvironmentVariableCredentialsProvider(),
      new SystemPropertiesCredentialsProvider(),
      new AWSCredentialsConfigFileProvider()
      );
}
项目:incubator-gobblin    文件:AWSClusterSecurityManager.java   
DefaultAWSCredentialsProviderChain(Config config) {
  super(new EnvironmentVariableCredentialsProvider(),
          new SystemPropertiesCredentialsProvider(),
          new ConfigurationCredentialsProvider(config),
          new ProfileCredentialsProvider(),
          new InstanceProfileCredentialsProvider());
}
项目:logback-ext    文件:AwsSupport.java   
public AWSCredentialsProvider getCredentials(AWSCredentials credentials) {
    return new AWSCredentialsProviderChain(
            new EnvironmentVariableCredentialsProvider(),
            new SystemPropertiesCredentialsProvider(),
            new StaticCredentialsProvider(credentials == null ? new NullCredentials() : credentials),
            new ProfileCredentialsProvider(),
            new InstanceProfileCredentialsProvider()
    );
}
项目:strongbox    文件:CustomCredentialsProviderChain.java   
public CustomCredentialsProviderChain(ClientConfiguration clientConfiguration, ProfileIdentifier profile, Supplier<MFAToken> mfaTokenSupplier) {
    super(new EnvironmentVariableCredentialsProvider(),
            new SystemPropertiesCredentialsProvider(),
            new ProfileCredentialProvider(clientConfiguration, profile, mfaTokenSupplier),
            new EC2ContainerCredentialsProviderWrapper());
}
项目:ismartonline    文件:AwsFileManager.java   
@Override
public String write(String baseFolder, MultipartFile file, String fileName) {

    String webPath = baseFolder + "/" + fileName;

    AmazonS3 s3client = new AmazonS3Client(new SystemPropertiesCredentialsProvider());
    try {
        System.out.println("Uploading a new object to S3 from a file\n");
        s3client.putObject(new PutObjectRequest(bucketName, webPath, convert(file)));

    } catch (AmazonServiceException ase) {
        System.out.println("Caught an AmazonServiceException, which " + "means your request made it "
                + "to Amazon S3, but was rejected with an error response" + " for some reason.");
        System.out.println("Error Message:    " + ase.getMessage());
        System.out.println("HTTP Status Code: " + ase.getStatusCode());
        System.out.println("AWS Error Code:   " + ase.getErrorCode());
        System.out.println("Error Type:       " + ase.getErrorType());
        System.out.println("Request ID:       " + ase.getRequestId());
    } catch (AmazonClientException ace) {
        System.out.println("Caught an AmazonClientException, which " + "means the client encountered "
                + "an internal error while trying to " + "communicate with S3, "
                + "such as not being able to access the network.");
        System.out.println("Error Message: " + ace.getMessage());
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return webPath;

    // System.out.println(context.getContextPath());
    // System.out.println(context.getRealPath(context.getContextPath()));
    //
    // String homePath = System.getProperty("user.home");
    // String baseFolderPath = homePath + "/" + baseFolder;
    //
    // File folder = new File(baseFolderPath);
    // if (! folder.exists())
    // folder.mkdirs();
    //
    // String filePath = baseFolderPath + "/" + file.getOriginalFilename();
    //
    // System.out.println(filePath);
    //
    // try {
    // file.transferTo(new File(filePath));
    // return filePath;
    // } catch (IllegalStateException | IOException e) {
    // e.printStackTrace();
    // throw new RuntimeException(e);
    // }
}
项目:kinesis-logback-appender    文件:CustomCredentialsProviderChain.java   
public CustomCredentialsProviderChain() {
  super(new ClasspathPropertiesFileCredentialsProvider(), new InstanceProfileCredentialsProvider(),
      new SystemPropertiesCredentialsProvider(), new EnvironmentVariableCredentialsProvider(),
      new ProfileCredentialsProvider());
}
项目:kinesis-log4j-appender    文件:CustomCredentialsProviderChain.java   
public CustomCredentialsProviderChain() {
  super(new ClasspathPropertiesFileCredentialsProvider(), new InstanceProfileCredentialsProvider(),
      new SystemPropertiesCredentialsProvider(), new EnvironmentVariableCredentialsProvider());
}
项目:aws-big-data-blog    文件:CustomCredentialsProviderChain.java   
public CustomCredentialsProviderChain() {
    super(new EnvironmentVariableCredentialsProvider(),
            new SystemPropertiesCredentialsProvider(),
            new ClasspathPropertiesFileCredentialsProvider(),
            new InstanceProfileCredentialsProvider());
}