List of usage examples for com.amazonaws.auth PropertiesFileCredentialsProvider PropertiesFileCredentialsProvider
public PropertiesFileCredentialsProvider(String credentialsFilePath)
From source file:com.datatorrent.lib.io.jms.SQSTestBase.java
License:Apache License
public SQSTestBase() { PropertiesFileCredentialsProvider file = new PropertiesFileCredentialsProvider(getTestCredsFilePath()); testCreds = (PropertiesCredentials) file.getCredentials(); sqs = new AmazonSQSClient(testCreds); }
From source file:com.google.crypto.tink.integration.awskms.AwsKmsClient.java
License:Apache License
/** * Loads AWS credentials from a properties file. * * <p>The AWS access key ID is expected to be in the <code>accessKey</code> property and the AWS * secret key is expected to be in the <code>secretKey</code> property. * * @throws GeneralSecurityException if the client initialization fails *//*from ww w . j a va 2s. co m*/ @Override public KmsClient withCredentials(String credentialPath) throws GeneralSecurityException { try { if (credentialPath == null) { return withDefaultCredentials(); } return withCredentialsProvider(new PropertiesFileCredentialsProvider(credentialPath)); } catch (AmazonServiceException e) { throw new GeneralSecurityException("cannot load credentials", e); } }
From source file:com.ipcglobal.awscdh.util.Utils.java
License:Apache License
/** * Inits the credentials./*from ww w . j a va 2 s. c o m*/ * * @param credentialsFileName * the credentials file name * @return the AWS credentials provider */ public static AWSCredentialsProvider initCredentials(String credentialsFileName) { // Get credentials from IMDS. If unsuccessful, get them from the // credential profiles file. AWSCredentialsProvider credentialsProvider = null; try { credentialsProvider = new InstanceProfileCredentialsProvider(); // Verify we can fetch credentials from the provider credentialsProvider.getCredentials(); log.info("Obtained credentials from the IMDS."); } catch (AmazonClientException e) { log.warn("Unable to obtain credentials from the IMDS, trying credentialsFileName"); // If the credentialsFileName contains a path, assume it contains // the entire drive:/path/name.ext // this is necessary when running as a service on Windows String credentialsPathNameExt = null; // safest to check for both if (credentialsFileName.indexOf("/") > -1 || credentialsFileName.indexOf("\\") > -1) credentialsPathNameExt = credentialsFileName; else credentialsPathNameExt = System.getProperty("user.home") + System.getProperty("file.separator") + ".aws" + System.getProperty("file.separator") + credentialsFileName; credentialsProvider = new PropertiesFileCredentialsProvider(credentialsPathNameExt); log.info("Obtained credentials from the credentialsFileName file."); } return credentialsProvider; }
From source file:org.apache.nifi.processors.aws.credentials.provider.factory.strategies.FileCredentialsStrategy.java
License:Apache License
@Override public AWSCredentialsProvider getCredentialsProvider(Map<PropertyDescriptor, String> properties) { String credsFile = properties.get(CredentialPropertyDescriptors.CREDENTIALS_FILE); return new PropertiesFileCredentialsProvider(credsFile); }