com.amazonaws.auth.BasicAWSCredentials Java Examples
The following examples show how to use
com.amazonaws.auth.BasicAWSCredentials.
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: ITSQSCollector.java From zipkin-aws with Apache License 2.0 | 6 votes |
@Before public void setup() { store = InMemoryStorage.newBuilder().build(); metrics = new InMemoryCollectorMetrics(); collector = new SQSCollector.Builder() .queueUrl(sqsRule.queueUrl()) .parallelism(2) .waitTimeSeconds(1) // using short wait time to make test teardown faster .endpointConfiguration(new EndpointConfiguration(sqsRule.queueUrl(), "us-east-1")) .credentialsProvider( new AWSStaticCredentialsProvider(new BasicAWSCredentials("x", "x"))) .metrics(metrics) .sampler(CollectorSampler.ALWAYS_SAMPLE) .storage(store) .build() .start(); metrics = metrics.forTransport("sqs"); }
Example #2
Source File: AwsQueryInjection.java From Android_Code_Arbiter with GNU Lesser General Public License v3.0 | 6 votes |
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 #3
Source File: BaragonServiceModule.java From Baragon with Apache License 2.0 | 6 votes |
@Provides @Named(BARAGON_AWS_ELB_CLIENT_V2) public com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingClient providesAwsElbClientV2(Optional<ElbConfiguration> configuration) { com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingClient elbClient; if (configuration.isPresent() && configuration.get().getAwsAccessKeyId() != null && configuration.get().getAwsAccessKeySecret() != null) { elbClient = new com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingClient(new BasicAWSCredentials(configuration.get().getAwsAccessKeyId(), configuration.get().getAwsAccessKeySecret())); } else { elbClient = new com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingClient(); } if (configuration.isPresent() && configuration.get().getAwsEndpoint().isPresent()) { elbClient.setEndpoint(configuration.get().getAwsEndpoint().get()); } if (configuration.isPresent() && configuration.get().getAwsRegion().isPresent()) { elbClient.configureRegion(Regions.fromName(configuration.get().getAwsRegion().get())); } return elbClient; }
Example #4
Source File: ProductInfoRepositoryIntegrationTest.java From tutorials with MIT License | 6 votes |
@BeforeClass public static void setupClass() { Properties testProperties = loadFromFileInClasspath("test.properties") .filter(properties -> !isEmpty(properties.getProperty(AWS_ACCESSKEY))) .filter(properties -> !isEmpty(properties.getProperty(AWS_SECRETKEY))) .filter(properties -> !isEmpty(properties.getProperty(DYNAMODB_ENDPOINT))) .orElseThrow(() -> new RuntimeException("Unable to get all of the required test property values")); String amazonAWSAccessKey = testProperties.getProperty(AWS_ACCESSKEY); String amazonAWSSecretKey = testProperties.getProperty(AWS_SECRETKEY); String amazonDynamoDBEndpoint = testProperties.getProperty(DYNAMODB_ENDPOINT); amazonDynamoDB = new AmazonDynamoDBClient(new BasicAWSCredentials(amazonAWSAccessKey, amazonAWSSecretKey)); amazonDynamoDB.setEndpoint(amazonDynamoDBEndpoint); dynamoDBMapper = new DynamoDBMapper(amazonDynamoDB); }
Example #5
Source File: AwsS3Test.java From ecs-sync with Apache License 2.0 | 6 votes |
@Before public void setup() throws Exception { Properties syncProperties = TestConfig.getProperties(); endpoint = syncProperties.getProperty(TestConfig.PROP_S3_ENDPOINT); accessKey = syncProperties.getProperty(TestConfig.PROP_S3_ACCESS_KEY_ID); secretKey = syncProperties.getProperty(TestConfig.PROP_S3_SECRET_KEY); region = syncProperties.getProperty(TestConfig.PROP_S3_REGION); String proxyUri = syncProperties.getProperty(TestConfig.PROP_HTTP_PROXY_URI); Assume.assumeNotNull(endpoint, accessKey, secretKey); endpointUri = new URI(endpoint); ClientConfiguration config = new ClientConfiguration().withSignerOverride("S3SignerType"); if (proxyUri != null) { URI uri = new URI(proxyUri); config.setProxyHost(uri.getHost()); config.setProxyPort(uri.getPort()); } AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard() .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey))) .withClientConfiguration(config) .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, region)); s3 = builder.build(); }
Example #6
Source File: PrestoS3FileSystem.java From presto with Apache License 2.0 | 6 votes |
private static Optional<AWSCredentials> getAwsCredentials(Configuration conf) { String accessKey = conf.get(S3_ACCESS_KEY); String secretKey = conf.get(S3_SECRET_KEY); if (isNullOrEmpty(accessKey) || isNullOrEmpty(secretKey)) { return Optional.empty(); } String sessionToken = conf.get(S3_SESSION_TOKEN); if (!isNullOrEmpty(sessionToken)) { return Optional.of(new BasicSessionCredentials(accessKey, secretKey, sessionToken)); } return Optional.of(new BasicAWSCredentials(accessKey, secretKey)); }
Example #7
Source File: EventPublisherAmazonKinesis.java From konker-platform with Apache License 2.0 | 6 votes |
public com.amazonaws.services.kinesis.AmazonKinesis build(AmazonKinesis kinesisProperties) { com.amazonaws.services.kinesis.AmazonKinesisClientBuilder clientBuilder = com.amazonaws.services.kinesis.AmazonKinesisClientBuilder.standard(); clientBuilder.setRegion(kinesisProperties.getRegion()); clientBuilder.setCredentials(new AWSCredentialsProvider() { @Override public AWSCredentials getCredentials() { return new BasicAWSCredentials(kinesisProperties.getKey(), kinesisProperties.getSecret()); } @Override public void refresh() { } }); clientBuilder.setClientConfiguration(new ClientConfiguration()); return clientBuilder.build(); }
Example #8
Source File: AwsModuleTest.java From beam with Apache License 2.0 | 6 votes |
@Test public void testAWSStaticCredentialsProviderSerializationDeserialization() throws Exception { String awsKeyId = "key-id"; String awsSecretKey = "secret-key"; AWSStaticCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(new BasicAWSCredentials(awsKeyId, awsSecretKey)); String serializedCredentialsProvider = objectMapper.writeValueAsString(credentialsProvider); AWSCredentialsProvider deserializedCredentialsProvider = objectMapper.readValue(serializedCredentialsProvider, AWSCredentialsProvider.class); assertEquals(credentialsProvider.getClass(), deserializedCredentialsProvider.getClass()); assertEquals( credentialsProvider.getCredentials().getAWSAccessKeyId(), deserializedCredentialsProvider.getCredentials().getAWSAccessKeyId()); assertEquals( credentialsProvider.getCredentials().getAWSSecretKey(), deserializedCredentialsProvider.getCredentials().getAWSSecretKey()); }
Example #9
Source File: AmazonMailSenderTest.java From Cheddar with Apache License 2.0 | 6 votes |
@Test public void shouldInitializeWithCredentialsAndTransport_givenAwsCredentials() { // Given final String awsAccessKeyId = randomString(10); final String awsAccessSecretId = randomString(10); final AWSCredentials awsCredentials = new BasicAWSCredentials(awsAccessKeyId, awsAccessSecretId); final AmazonMailSender mailSender = new AmazonMailSender(awsCredentials); // When mailSender.init(); final Properties properties = mailSender.getJavaMailProperties(); // Then assertEquals("aws", properties.getProperty("mail.transport.protocol")); assertEquals(awsAccessKeyId, properties.getProperty(AWSJavaMailTransport.AWS_ACCESS_KEY_PROPERTY)); assertEquals(awsAccessSecretId, properties.getProperty(AWSJavaMailTransport.AWS_SECRET_KEY_PROPERTY)); }
Example #10
Source File: AmazonAwsClientFactory.java From primecloud-controller with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public AmazonEC2 createEc2Client(String awsAccessId, String awsSecretKey) { AWSCredentials credentials = new BasicAWSCredentials(awsAccessId, awsSecretKey); ClientConfiguration configuration = createConfiguration(); AmazonEC2 client = new AmazonEC2Client(credentials, configuration); if (host != null) { client.setEndpoint(AmazonEC2.ENDPOINT_PREFIX + "." + host); } client = new ExceptionHandleAwsClientWrapper().wrap(client); return client; }
Example #11
Source File: SqsIOTest.java From beam with Apache License 2.0 | 6 votes |
@Override protected void before() { sqsRestServer = SQSRestServerBuilder.start(); String endpoint = "http://localhost:9324"; String region = "elasticmq"; String accessKey = "x"; String secretKey = "x"; client = AmazonSQSClientBuilder.standard() .withCredentials( new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey))) .withEndpointConfiguration( new AwsClientBuilder.EndpointConfiguration(endpoint, region)) .build(); final CreateQueueResult queue = client.createQueue("test"); queueUrl = queue.getQueueUrl(); }
Example #12
Source File: WarehouseExport.java From usergrid with Apache License 2.0 | 6 votes |
private void copyToS3( String fileName ) { String bucketName = ( String ) properties.get( BUCKET_PROPNAME ); String accessId = ( String ) properties.get( ACCESS_ID_PROPNAME ); String secretKey = ( String ) properties.get( SECRET_KEY_PROPNAME ); Properties overrides = new Properties(); overrides.setProperty( "s3" + ".identity", accessId ); overrides.setProperty( "s3" + ".credential", secretKey ); final Iterable<? extends Module> MODULES = ImmutableSet .of( new JavaUrlHttpCommandExecutorServiceModule(), new Log4JLoggingModule(), new NettyPayloadModule() ); AWSCredentials credentials = new BasicAWSCredentials(accessId, secretKey); ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setProtocol( Protocol.HTTP); AmazonS3Client s3Client = new AmazonS3Client(credentials, clientConfig); s3Client.createBucket( bucketName ); File uploadFile = new File( fileName ); PutObjectResult putObjectResult = s3Client.putObject( bucketName, uploadFile.getName(), uploadFile ); logger.info("Uploaded file etag={}", putObjectResult.getETag()); }
Example #13
Source File: S3StorageIT.java From digdag with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { assumeThat(TEST_S3_ENDPOINT, not(isEmptyOrNullString())); projectDir = folder.getRoot().toPath().resolve("foobar"); config = folder.newFile().toPath(); client = DigdagClient.builder() .host(server.host()) .port(server.port()) .build(); AWSCredentials credentials = new BasicAWSCredentials(TEST_S3_ACCESS_KEY_ID, TEST_S3_SECRET_ACCESS_KEY); s3 = new AmazonS3Client(credentials); s3.setEndpoint(TEST_S3_ENDPOINT); s3.createBucket(archiveBucket); s3.createBucket(logStorageBucket); }
Example #14
Source File: TracingHandlerTest.java From aws-xray-sdk-java with Apache License 2.0 | 6 votes |
@Test public void testRaceConditionOnRecorderInitialization() { AWSXRay.setGlobalRecorder(null); // TracingHandler will not have the initialized recorder AWSLambda lambda = AWSLambdaClientBuilder .standard() .withRequestHandlers(new TracingHandler()) .withRegion(Regions.US_EAST_1) .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("fake", "fake"))) .build(); mockHttpClient(lambda, "null"); // Now init the global recorder AWSXRayRecorder recorder = AWSXRayRecorderBuilder.defaultRecorder(); recorder.setContextMissingStrategy(new LogErrorContextMissingStrategy()); AWSXRay.setGlobalRecorder(recorder); // Test logic InvokeRequest request = new InvokeRequest(); request.setFunctionName("testFunctionName"); lambda.invoke(request); }
Example #15
Source File: AlertJanitor.java From s3mper with Apache License 2.0 | 6 votes |
public void initalize(URI uri, Configuration conf) { this.conf = conf; String keyId = conf.get("fs."+uri.getScheme()+".awsAccessKeyId"); String keySecret = conf.get("fs."+uri.getScheme()+".awsSecretAccessKey"); //An override option for accessing across accounts keyId = conf.get("fs."+uri.getScheme()+".override.awsAccessKeyId", keyId); keySecret = conf.get("fs."+uri.getScheme()+".override.awsSecretAccessKey", keySecret); sqs = new AmazonSQSClient(new BasicAWSCredentials(keyId, keySecret)); //SQS Consistency Queue consistencyQueue = conf.get("fs"+uri.getScheme()+".alert.sqs.queue", consistencyQueue); consistencyQueue = sqs.getQueueUrl(new GetQueueUrlRequest(consistencyQueue)).getQueueUrl(); //SQS Timeout Queue timeoutQueue = conf.get("fs"+uri.getScheme()+".timeout.sqs.queue", timeoutQueue); timeoutQueue = sqs.getQueueUrl(new GetQueueUrlRequest(timeoutQueue)).getQueueUrl(); }
Example #16
Source File: TerminateInstancesExample.java From aws-mock with MIT License | 6 votes |
/** * Terminate specified instances (power-on the instances). * * @param instanceIDs * IDs of the instances to terminate * @return a list of state changes for the instances */ public static List<InstanceStateChange> terminateInstances(final List<String> instanceIDs) { // pass any credentials as aws-mock does not authenticate them at all AWSCredentials credentials = new BasicAWSCredentials("foo", "bar"); AmazonEC2Client amazonEC2Client = new AmazonEC2Client(credentials); // the mock endpoint for ec2 which runs on your computer String ec2Endpoint = "http://localhost:8000/aws-mock/ec2-endpoint/"; amazonEC2Client.setEndpoint(ec2Endpoint); // send the terminate request with args as instance IDs TerminateInstancesRequest request = new TerminateInstancesRequest(); request.withInstanceIds(instanceIDs); TerminateInstancesResult result = amazonEC2Client.terminateInstances(request); return result.getTerminatingInstances(); }
Example #17
Source File: TracingHandlerTest.java From aws-xray-sdk-java with Apache License 2.0 | 6 votes |
@Test public void testLambdaInvokeSubsegmentContainsFunctionName() { // Setup test AWSLambda lambda = AWSLambdaClientBuilder .standard() .withRequestHandlers(new TracingHandler()) .withRegion(Regions.US_EAST_1) .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("fake", "fake"))) .build(); mockHttpClient(lambda, "null"); // Lambda returns "null" on successful fn. with no return value // Test logic Segment segment = AWSXRay.beginSegment("test"); InvokeRequest request = new InvokeRequest(); request.setFunctionName("testFunctionName"); lambda.invoke(request); Assert.assertEquals(1, segment.getSubsegments().size()); Assert.assertEquals("Invoke", segment.getSubsegments().get(0).getAws().get("operation")); Assert.assertEquals("testFunctionName", segment.getSubsegments().get(0).getAws().get("function_name")); }
Example #18
Source File: GenericApiGatewayClientTest.java From apigateway-generic-java-sdk with Apache License 2.0 | 6 votes |
@Before public void setUp() throws IOException { AWSCredentialsProvider credentials = new AWSStaticCredentialsProvider(new BasicAWSCredentials("foo", "bar")); mockClient = Mockito.mock(SdkHttpClient.class); HttpResponse resp = new BasicHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1, 200, "OK")); BasicHttpEntity entity = new BasicHttpEntity(); entity.setContent(new ByteArrayInputStream("test payload".getBytes())); resp.setEntity(entity); Mockito.doReturn(resp).when(mockClient).execute(any(HttpUriRequest.class), any(HttpContext.class)); ClientConfiguration clientConfig = new ClientConfiguration(); client = new GenericApiGatewayClientBuilder() .withClientConfiguration(clientConfig) .withCredentials(credentials) .withEndpoint("https://foobar.execute-api.us-east-1.amazonaws.com") .withRegion(Region.getRegion(Regions.fromName("us-east-1"))) .withApiKey("12345") .withHttpClient(new AmazonHttpClient(clientConfig, mockClient, null)) .build(); }
Example #19
Source File: S3DataTransfererFactory.java From oodt with Apache License 2.0 | 6 votes |
@Override public S3DataTransferer createDataTransfer() { String bucketName = System.getProperty(BUCKET_NAME_PROPERTY); String region = System.getProperty(REGION_PROPERTY); String accessKey = System.getProperty(ACCESS_KEY_PROPERTY); String secretKey = System.getProperty(SECRET_KEY_PROPERTY); boolean encrypt = Boolean.getBoolean(ENCRYPT_PROPERTY); AmazonS3Client s3 = (AmazonS3Client) AmazonS3ClientBuilder.standard() .withRegion(region) .withCredentials( new AWSStaticCredentialsProvider( new BasicAWSCredentials(accessKey, secretKey))) .build(); return new S3DataTransferer(s3, bucketName, encrypt); }
Example #20
Source File: TestAmazonS3Target.java From datacollector with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUpClass() throws IOException, InterruptedException { File dir = new File(new File("target", UUID.randomUUID().toString()), "fakes3_root").getAbsoluteFile(); Assert.assertTrue(dir.mkdirs()); fakeS3Root = dir.getAbsolutePath(); port = TestUtil.getFreePort(); fakeS3 = new FakeS3(fakeS3Root, port); Assume.assumeTrue("Please install fakes3 in your system", fakeS3.fakes3Installed()); //Start the fakes3 server executorService = Executors.newSingleThreadExecutor(); executorService.submit(fakeS3); BasicAWSCredentials credentials = new BasicAWSCredentials("foo", "bar"); s3client = AmazonS3ClientBuilder .standard() .withCredentials(new AWSStaticCredentialsProvider(credentials)) .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("http://localhost:" + port, null)) .withPathStyleAccessEnabled(true) .withChunkedEncodingDisabled(true) // FakeS3 does not correctly calculate checksums with chunked encoding enabled. .build(); TestUtil.createBucket(s3client, BUCKET_NAME); TestUtil.createBucket(s3client, SECOND_BUCKET_NAME); }
Example #21
Source File: Configuration.java From reinvent2013-mobile-photo-share with Apache License 2.0 | 6 votes |
private static String getAWSAccountID() { try { String accessKey = AWS_ACCESS_KEY_ID; String secretKey = AWS_SECRET_KEY; if (Utilities.isEmpty(accessKey) || Utilities.isEmpty(secretKey)) { return null; } AWSCredentials creds = new BasicAWSCredentials(accessKey, secretKey); AmazonIdentityManagementClient iam = new AmazonIdentityManagementClient(creds); return iam.getUser().getUser().getArn().split(":")[4]; } catch (AmazonClientException e) { throw new RuntimeException("Failed to get AWS account id", e); } }
Example #22
Source File: KinesisPersistReader.java From streams with Apache License 2.0 | 6 votes |
@Override public void prepare(Object configurationObject) { // Connect to Kinesis synchronized (this) { // Create the credentials Object AWSCredentials credentials = new BasicAWSCredentials(config.getKey(), config.getSecretKey()); ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setProtocol(Protocol.valueOf(config.getProtocol().toString())); this.client = new AmazonKinesisClient(credentials, clientConfig); if (StringUtils.isNotEmpty(config.getRegion())) this.client.setRegion(Region.getRegion(Regions.fromName(config.getRegion()))); } streamNames = this.config.getStreams(); executor = Executors.newFixedThreadPool(streamNames.size()); }
Example #23
Source File: Utilities.java From dynamodb-geo with Apache License 2.0 | 6 votes |
private synchronized void setupGeoDataManager() { if (geoDataManager == null) { String accessKey = System.getProperty("AWS_ACCESS_KEY_ID"); String secretKey = System.getProperty("AWS_SECRET_KEY"); String tableName = System.getProperty("PARAM1"); String regionName = System.getProperty("PARAM2"); Region region = Region.getRegion(Regions.fromName(regionName)); ClientConfiguration clientConfiguration = new ClientConfiguration().withMaxErrorRetry(20); AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); AmazonDynamoDBClient ddb = new AmazonDynamoDBClient(credentials, clientConfiguration); ddb.setRegion(region); GeoDataManagerConfiguration config = new GeoDataManagerConfiguration(ddb, tableName); geoDataManager = new GeoDataManager(config); } }
Example #24
Source File: ContextCredentialsAutoConfiguration.java From spring-cloud-aws with Apache License 2.0 | 6 votes |
private List<AWSCredentialsProvider> resolveCredentialsProviders( AwsCredentialsProperties properties) { List<AWSCredentialsProvider> providers = new ArrayList<>(); if (StringUtils.hasText(properties.getAccessKey()) && StringUtils.hasText(properties.getSecretKey())) { providers.add(new AWSStaticCredentialsProvider(new BasicAWSCredentials( properties.getAccessKey(), properties.getSecretKey()))); } if (properties.isInstanceProfile()) { providers.add(new EC2ContainerCredentialsProviderWrapper()); } if (properties.getProfileName() != null) { providers.add(properties.getProfilePath() != null ? new ProfileCredentialsProvider(properties.getProfilePath(), properties.getProfileName()) : new ProfileCredentialsProvider(properties.getProfileName())); } return providers; }
Example #25
Source File: AwsIamAuthenticationUnitTests.java From spring-vault with Apache License 2.0 | 6 votes |
@Test void shouldAuthenticate() { this.mockRest.expect(requestTo("/auth/aws/login")).andExpect(method(HttpMethod.POST)) .andExpect(jsonPath("$.iam_http_request_method").value("POST")) .andExpect(jsonPath("$.iam_request_url").exists()).andExpect(jsonPath("$.iam_request_body").exists()) .andExpect(jsonPath("$.iam_request_headers").exists()).andExpect(jsonPath("$.role").value("foo-role")) .andRespond(withSuccess().contentType(MediaType.APPLICATION_JSON).body( "{" + "\"auth\":{\"client_token\":\"my-token\", \"renewable\": true, \"lease_duration\": 10}" + "}")); AwsIamAuthenticationOptions options = AwsIamAuthenticationOptions.builder().role("foo-role") .credentials(new BasicAWSCredentials("foo", "bar")).build(); AwsIamAuthentication sut = new AwsIamAuthentication(options, this.restTemplate); VaultToken login = sut.login(); assertThat(login).isInstanceOf(LoginToken.class); assertThat(login.getToken()).isEqualTo("my-token"); assertThat(((LoginToken) login).getLeaseDuration()).isEqualTo(Duration.ofSeconds(10)); assertThat(((LoginToken) login).isRenewable()).isTrue(); }
Example #26
Source File: AmazonS3Configuration.java From mojito with Apache License 2.0 | 5 votes |
@Bean public AmazonS3 amazonS3Client(AmazonS3ConfigurationProperties amazonS3ConfigurationProperties) { AmazonS3ClientBuilder amazonS3ClientBuilder = AmazonS3ClientBuilder .standard() .withRegion(Regions.fromName(amazonS3ConfigurationProperties.getRegion())); if (amazonS3ConfigurationProperties.getAccessKeyId() != null) { AWSCredentials credentials = new BasicAWSCredentials(amazonS3ConfigurationProperties.getAccessKeyId(), amazonS3ConfigurationProperties.getAccessKeySecret()); amazonS3ClientBuilder.withCredentials(new AWSStaticCredentialsProvider(credentials)); } AmazonS3 amazonS3 = amazonS3ClientBuilder.build(); return amazonS3; }
Example #27
Source File: S3OutputStream.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 5 votes |
private void upload() throws IOException { if (uploaded) { return; } try { uploaded = true; os.close(); os = null; if (!S3InputStream.isS3File(url)) { throw new IllegalArgumentException("Not an Amazon S3 host"); } String accessKey = S3InputStream.getAccessKey(url); String secretKey = S3InputStream.getSecretKey(url); String path = url.getFile(); if (path.startsWith("/")) { path = path.substring(1); } AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); AmazonS3Client service = new AmazonS3Client(credentials); transferManager = new TransferManager(service); TransferManagerConfiguration config = new TransferManagerConfiguration(); config.setMultipartUploadThreshold(MULTIPART_UPLOAD_THRESHOLD); config.setMinimumUploadPartSize(MULTIPART_UPLOAD_THRESHOLD); transferManager.setConfiguration(config); String bucket = S3InputStream.getBucket(url); // CLO-4724: S3Utils.uploadFile(transferManager, tempFile, bucket, path); } finally { tempFile.delete(); if (transferManager != null) { transferManager.shutdownNow(); } } }
Example #28
Source File: AWSDDBMetadataRetrieval.java From syndesis with Apache License 2.0 | 5 votes |
DescribeTableResult fetchTableDescription(Map<String, Object> properties) { AWSCredentials credentials = new BasicAWSCredentials(properties.get("accessKey").toString(), properties.get("secretKey").toString()); AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials); AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().withCredentials(credentialsProvider) .withRegion(Regions.valueOf(properties.get("region").toString())).build(); return client.describeTable(properties.get("tableName").toString()); }
Example #29
Source File: S3CheckpointSpiStartStopSSEAlgorithmSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected void spiConfigure(S3CheckpointSpi spi) throws Exception { AWSCredentials cred = new BasicAWSCredentials(IgniteS3TestSuite.getAccessKey(), IgniteS3TestSuite.getSecretKey()); spi.setAwsCredentials(cred); spi.setBucketNameSuffix(S3CheckpointSpiSelfTest.getBucketNameSuffix()); spi.setSSEAlgorithm("AES256"); super.spiConfigure(spi); }
Example #30
Source File: AccessKeyPairCredentialsStrategy.java From nifi with Apache License 2.0 | 5 votes |
@Override public AWSCredentialsProvider getCredentialsProvider(Map<PropertyDescriptor, String> properties) { String accessKey = properties.get(CredentialPropertyDescriptors.ACCESS_KEY); String secretKey = properties.get(CredentialPropertyDescriptors.SECRET_KEY); BasicAWSCredentials creds = new BasicAWSCredentials(accessKey, secretKey); return new StaticCredentialsProvider(creds); }