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])); }
@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); }
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; }
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; }
@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); }
MyCredentialsProvider() { super(new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), // Removed due to ElasticBeanstalk environment not being setup with a profile dir // new ProfileCredentialsProvider(), new InstanceProfileCredentialsProvider(), new ClasspathPropertiesFileCredentialsProvider()); }
AuthenticationInfoAWSCredentialsProviderChain(AuthenticationInfo authenticationInfo) { super( new InstanceProfileCredentialsProvider(), new ProfileCredentialsProvider(), new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new InstanceProfileCredentialsProvider()); }
@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); }
/** * * @return */ private AWSCredentialsProvider getCredentials() { return new AWSCredentialsProviderChain(new StaticCredentialsProvider( new AppenderCredentials()), new SystemPropertiesCredentialsProvider(), new EnvironmentVariableCredentialsProvider(), new ProfileCredentialsProvider(), new InstanceProfileCredentialsProvider()); }
@Bean @Scope(WebApplicationContext.SCOPE_APPLICATION) public AWSCredentialsProvider credentials() { return new AWSCredentialsProviderChain( new InstanceProfileCredentialsProvider(), new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider() ); }
private AWSCredentialsProvider createCredentialsProvider(){ return new AWSCredentialsProviderChain( new InstanceProfileCredentialsProvider(), new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new AWSCredentialsConfigFileProvider() ); }
DefaultAWSCredentialsProviderChain(Config config) { super(new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new ConfigurationCredentialsProvider(config), new ProfileCredentialsProvider(), new InstanceProfileCredentialsProvider()); }
public AWSCredentialsProvider getCredentials(AWSCredentials credentials) { return new AWSCredentialsProviderChain( new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new StaticCredentialsProvider(credentials == null ? new NullCredentials() : credentials), new ProfileCredentialsProvider(), new InstanceProfileCredentialsProvider() ); }
public CustomCredentialsProviderChain(ClientConfiguration clientConfiguration, ProfileIdentifier profile, Supplier<MFAToken> mfaTokenSupplier) { super(new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new ProfileCredentialProvider(clientConfiguration, profile, mfaTokenSupplier), new EC2ContainerCredentialsProviderWrapper()); }
@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); // } }
public CustomCredentialsProviderChain() { super(new ClasspathPropertiesFileCredentialsProvider(), new InstanceProfileCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new EnvironmentVariableCredentialsProvider(), new ProfileCredentialsProvider()); }
public CustomCredentialsProviderChain() { super(new ClasspathPropertiesFileCredentialsProvider(), new InstanceProfileCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new EnvironmentVariableCredentialsProvider()); }
public CustomCredentialsProviderChain() { super(new EnvironmentVariableCredentialsProvider(), new SystemPropertiesCredentialsProvider(), new ClasspathPropertiesFileCredentialsProvider(), new InstanceProfileCredentialsProvider()); }