com.amazonaws.auth.AnonymousAWSCredentials#com.amazonaws.auth.PropertiesCredentials源码实例Demo

下面列出了com.amazonaws.auth.AnonymousAWSCredentials#com.amazonaws.auth.PropertiesCredentials 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: localization_nifi   文件: AbstractAWSProcessor.java
protected AWSCredentials getCredentials(final ProcessContext context) {
    final String accessKey = context.getProperty(ACCESS_KEY).evaluateAttributeExpressions().getValue();
    final String secretKey = context.getProperty(SECRET_KEY).evaluateAttributeExpressions().getValue();

    final String credentialsFile = context.getProperty(CREDENTIALS_FILE).getValue();

    if (credentialsFile != null) {
        try {
            return new PropertiesCredentials(new File(credentialsFile));
        } catch (final IOException ioe) {
            throw new ProcessException("Could not read Credentials File", ioe);
        }
    }

    if (accessKey != null && secretKey != null) {
        return new BasicAWSCredentials(accessKey, secretKey);
    }

    return new AnonymousAWSCredentials();

}
 
源代码2 项目: nifi   文件: AbstractAWSProcessor.java
protected AWSCredentials getCredentials(final ProcessContext context) {
    final String accessKey = context.getProperty(ACCESS_KEY).evaluateAttributeExpressions().getValue();
    final String secretKey = context.getProperty(SECRET_KEY).evaluateAttributeExpressions().getValue();

    final String credentialsFile = context.getProperty(CREDENTIALS_FILE).getValue();

    if (credentialsFile != null) {
        try {
            return new PropertiesCredentials(new File(credentialsFile));
        } catch (final IOException ioe) {
            throw new ProcessException("Could not read Credentials File", ioe);
        }
    }

    if (accessKey != null && secretKey != null) {
        return new BasicAWSCredentials(accessKey, secretKey);
    }

    return new AnonymousAWSCredentials();

}
 
源代码3 项目: nifi   文件: TestAWSCredentials.java
@Test
public void testCredentialsFile() {
    runner.setProperty(AbstractAWSProcessor.CREDENTIALS_FILE, "src/test/resources/mock-aws-credentials.properties");

    runner.assertValid();
    runner.run(1);

    assertEquals(PropertiesCredentials.class, awsCredentials.getClass());
    assertNull(awsCredentialsProvider);
}
 
@BeforeClass
public static void beforeClass() throws Exception {
    FileInputStream fis = new FileInputStream(CREDENTIALS_FILE);
    final PropertiesCredentials credentials = new PropertiesCredentials(fis);
    amazonDynamoDBClient = new AmazonDynamoDBClient(credentials);
    dynamoDB = new DynamoDB(amazonDynamoDBClient);
    amazonDynamoDBClient.setRegion(Region.getRegion(Regions.US_WEST_2));

    ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
    attributeDefinitions
        .add(new AttributeDefinition().withAttributeName("hashS").withAttributeType("S"));
    attributeDefinitions
        .add(new AttributeDefinition().withAttributeName("rangeS").withAttributeType("S"));

    ArrayList<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>();
    keySchema.add(new KeySchemaElement().withAttributeName("hashS").withKeyType(KeyType.HASH));
    keySchema.add(new KeySchemaElement().withAttributeName("rangeS").withKeyType(KeyType.RANGE));

    CreateTableRequest request = new CreateTableRequest()
        .withTableName(stringHashStringRangeTableName)
        .withKeySchema(keySchema)
        .withAttributeDefinitions(attributeDefinitions)
        .withProvisionedThroughput(new ProvisionedThroughput()
            .withReadCapacityUnits(5L)
            .withWriteCapacityUnits(6L));
    Table stringHashStringRangeTable = dynamoDB.createTable(request);
    stringHashStringRangeTable.waitForActive();

    attributeDefinitions = new ArrayList<AttributeDefinition>();
    attributeDefinitions
        .add(new AttributeDefinition().withAttributeName("hashN").withAttributeType("N"));
    attributeDefinitions
        .add(new AttributeDefinition().withAttributeName("rangeN").withAttributeType("N"));

    keySchema = new ArrayList<KeySchemaElement>();
    keySchema.add(new KeySchemaElement().withAttributeName("hashN").withKeyType(KeyType.HASH));
    keySchema.add(new KeySchemaElement().withAttributeName("rangeN").withKeyType(KeyType.RANGE));

    request = new CreateTableRequest()
        .withTableName(numberHashNumberRangeTableName)
        .withKeySchema(keySchema)
        .withAttributeDefinitions(attributeDefinitions)
        .withProvisionedThroughput(new ProvisionedThroughput()
            .withReadCapacityUnits(5L)
            .withWriteCapacityUnits(6L));
    Table numberHashNumberRangeTable = dynamoDB.createTable(request);
    numberHashNumberRangeTable.waitForActive();

    attributeDefinitions = new ArrayList<AttributeDefinition>();
    attributeDefinitions
        .add(new AttributeDefinition().withAttributeName("hashN").withAttributeType("N"));

    keySchema = new ArrayList<KeySchemaElement>();
    keySchema.add(new KeySchemaElement().withAttributeName("hashN").withKeyType(KeyType.HASH));

    request = new CreateTableRequest()
        .withTableName(numberHashOnlyTableName)
        .withKeySchema(keySchema)
        .withAttributeDefinitions(attributeDefinitions)
        .withProvisionedThroughput(new ProvisionedThroughput()
            .withReadCapacityUnits(5L)
            .withWriteCapacityUnits(6L));
    Table numberHashOnlyTable = dynamoDB.createTable(request);
    numberHashOnlyTable.waitForActive();

}
 
private static void createClient() throws IOException {
    AWSCredentials credentials = new PropertiesCredentials(
        LowLevelBatchWriteSyntax.class.getResourceAsStream("AwsCredentials.properties"));

    client = new AmazonDynamoDBClient(credentials);
}
 
源代码6 项目: attic-apex-malhar   文件: SQSTestBase.java
public SQSTestBase()
{
  PropertiesFileCredentialsProvider file = new PropertiesFileCredentialsProvider(getTestCredsFilePath());
  testCreds = (PropertiesCredentials)file.getCredentials();
  sqs = new AmazonSQSClient(testCreds);
}
 
源代码7 项目: nifi   文件: ITDeleteSQS.java
@Before
public void setUp() throws IOException {
    PropertiesCredentials credentials = new PropertiesCredentials(new File(CREDENTIALS_FILE));
    sqsClient = new AmazonSQSClient(credentials);
    sqsClient.withRegion(Regions.fromName(TEST_REGION));
}
 
源代码8 项目: nifi   文件: ITAbstractDynamoDBTest.java
@BeforeClass
public static void beforeClass() throws Exception {
    FileInputStream fis = new FileInputStream(CREDENTIALS_FILE);
    final PropertiesCredentials credentials = new PropertiesCredentials(fis);
    amazonDynamoDBClient = new AmazonDynamoDBClient(credentials);
    dynamoDB = new DynamoDB(amazonDynamoDBClient);
    amazonDynamoDBClient.setRegion(Region.getRegion(Regions.US_WEST_2));

    ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
    attributeDefinitions
        .add(new AttributeDefinition().withAttributeName("hashS").withAttributeType("S"));
    attributeDefinitions
        .add(new AttributeDefinition().withAttributeName("rangeS").withAttributeType("S"));

    ArrayList<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>();
    keySchema.add(new KeySchemaElement().withAttributeName("hashS").withKeyType(KeyType.HASH));
    keySchema.add(new KeySchemaElement().withAttributeName("rangeS").withKeyType(KeyType.RANGE));

    CreateTableRequest request = new CreateTableRequest()
        .withTableName(stringHashStringRangeTableName)
        .withKeySchema(keySchema)
        .withAttributeDefinitions(attributeDefinitions)
        .withProvisionedThroughput(new ProvisionedThroughput()
            .withReadCapacityUnits(5L)
            .withWriteCapacityUnits(6L));
    Table stringHashStringRangeTable = dynamoDB.createTable(request);
    stringHashStringRangeTable.waitForActive();

    attributeDefinitions = new ArrayList<AttributeDefinition>();
    attributeDefinitions
        .add(new AttributeDefinition().withAttributeName("hashN").withAttributeType("N"));
    attributeDefinitions
        .add(new AttributeDefinition().withAttributeName("rangeN").withAttributeType("N"));

    keySchema = new ArrayList<KeySchemaElement>();
    keySchema.add(new KeySchemaElement().withAttributeName("hashN").withKeyType(KeyType.HASH));
    keySchema.add(new KeySchemaElement().withAttributeName("rangeN").withKeyType(KeyType.RANGE));

    request = new CreateTableRequest()
        .withTableName(numberHashNumberRangeTableName)
        .withKeySchema(keySchema)
        .withAttributeDefinitions(attributeDefinitions)
        .withProvisionedThroughput(new ProvisionedThroughput()
            .withReadCapacityUnits(5L)
            .withWriteCapacityUnits(6L));
    Table numberHashNumberRangeTable = dynamoDB.createTable(request);
    numberHashNumberRangeTable.waitForActive();

    attributeDefinitions = new ArrayList<AttributeDefinition>();
    attributeDefinitions
        .add(new AttributeDefinition().withAttributeName("hashN").withAttributeType("N"));

    keySchema = new ArrayList<KeySchemaElement>();
    keySchema.add(new KeySchemaElement().withAttributeName("hashN").withKeyType(KeyType.HASH));

    request = new CreateTableRequest()
        .withTableName(numberHashOnlyTableName)
        .withKeySchema(keySchema)
        .withAttributeDefinitions(attributeDefinitions)
        .withProvisionedThroughput(new ProvisionedThroughput()
            .withReadCapacityUnits(5L)
            .withWriteCapacityUnits(6L));
    Table numberHashOnlyTable = dynamoDB.createTable(request);
    numberHashOnlyTable.waitForActive();

}
 
private static void createClient() throws IOException {
    AWSCredentials credentials = new PropertiesCredentials(
            LowLevelBatchWriteSyntax.class.getResourceAsStream("AwsCredentials.properties"));

    client = new AmazonDynamoDBClient(credentials);        
}