com.amazonaws.services.simpledb.AmazonSimpleDBClient Java Examples

The following examples show how to use com.amazonaws.services.simpledb.AmazonSimpleDBClient. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AwsQueryInjection.java    From Android_Code_Arbiter with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException{
    try{
        String customerID = request.getParameter("customerID");
  BasicAWSCredentials awsCredentials = new BasicAWSCredentials("test", "test");
        AmazonSimpleDBClient sdbc = new AmazonSimpleDBClient(awsCredentials);
        
        String query = "select * from invoices where customerID = '"
            + customerID;
        SelectResult sdbResult = sdbc.select(new SelectRequest(query)); //BAD

        SelectResult sdbResult2 = sdbc.select(new SelectRequest(query, false)); //BAD

        SelectRequest sdbRequest = new SelectRequest();
        SelectResult sdbResult3 = sdbc.select(sdbRequest.withSelectExpression(query)); //BAD
        
        String query2 = "select * from invoices where customerID = 123";
        SelectResult sdbResult4 = sdbc.select(new SelectRequest(query2)); //OK

    }catch(Exception e){
        System.out.println(e);
   }
}
 
Example #2
Source File: SimpleDb.java    From spring-data-simpledb with MIT License 6 votes vote down vote up
@Override
public final void afterPropertiesSet() {
	final AWSCredentials awsCredentials = new AWSCredentials() {

		@Override
		public String getAWSAccessKeyId() {
			return accessID;
		}

		@Override
		public String getAWSSecretKey() {
			return secretKey;
		}
	};

	this.simpleDbClient = new AmazonSimpleDBClient(awsCredentials);

	simpleDbDomain = new SimpleDbDomain(domainPrefix);
}
 
Example #3
Source File: SDBIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
public static void assertNoStaleDomain(AmazonSimpleDBClient client, String when) {
    List<String> staleInstances = client.listDomains().getDomainNames().stream() //
            .filter(name -> !name.startsWith(SDBIntegrationTest.class.getSimpleName())
                    || System.currentTimeMillis() - AWSUtils.toEpochMillis(name) > AWSUtils.HOUR) //
            .collect(Collectors.toList());
    Assert.assertEquals(String.format("Found stale SDB domans %s running the test: %s", when, staleInstances), 0,
            staleInstances.size());
}
 
Example #4
Source File: SDBUtils.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
public static AmazonSimpleDBClient createDBClient() {
    BasicCredentialsProvider credentials = BasicCredentialsProvider.standard();
    AmazonSimpleDBClient client = !credentials.isValid() ? null : (AmazonSimpleDBClient)
            AmazonSimpleDBClientBuilder.standard()
            .withCredentials(credentials)
            .withRegion("eu-west-1").build();
    return client;
}
 
Example #5
Source File: SDBUtils.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
public static void createDomain(AmazonSimpleDBClient client, String domainName) throws InterruptedException {
    client.createDomain(new CreateDomainRequest(domainName));

    // Unfortunatly, there is no waiters for domain create

    int retries = 10;
    List<String> domainNames = client.listDomains().getDomainNames();
    while (!domainNames.contains(domainName) && 0 < retries--) {
        Thread.sleep(500);
        domainNames = client.listDomains().getDomainNames();
    }
    Assert.assertTrue(domainNames.contains(domainName));
}
 
Example #6
Source File: SDBClientProducer.java    From wildfly-camel with Apache License 2.0 4 votes vote down vote up
SDBClientProvider(AmazonSimpleDBClient client) {
    this.client = client;
}
 
Example #7
Source File: SDBClientProducer.java    From wildfly-camel with Apache License 2.0 4 votes vote down vote up
public AmazonSimpleDBClient getClient() {
    return client;
}
 
Example #8
Source File: SDBClientProducer.java    From wildfly-camel with Apache License 2.0 4 votes vote down vote up
@Produces
@Singleton
public SDBClientProvider getClientProvider() throws Exception {
    AmazonSimpleDBClient client = SDBUtils.createDBClient();
    return new SDBClientProvider(client);
}