software.amazon.awssdk.auth.credentials.AwsBasicCredentials Java Examples
The following examples show how to use
software.amazon.awssdk.auth.credentials.AwsBasicCredentials.
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: S3Manager.java From joyqueue with Apache License 2.0 | 9 votes |
private String getS3Url(String objectKey) { AwsCredentialsProvider credentialsProvider = StaticCredentialsProvider.create(AwsBasicCredentials.create(accessKey, secretKey)); S3Presigner preSigner = S3Presigner.builder() .credentialsProvider(credentialsProvider) .endpointOverride(URI.create(endpoint)) .region(clientRegion).build(); GetObjectRequest getObjectRequest = GetObjectRequest.builder() .bucket(bucketName) .key(objectKey) .build(); GetObjectPresignRequest getObjectPresignRequest = GetObjectPresignRequest.builder() .getObjectRequest(getObjectRequest).signatureDuration(Duration.ofDays(7)).build(); PresignedGetObjectRequest presignedGetObjectRequest = preSigner.presignGetObject(getObjectPresignRequest); String url = presignedGetObjectRequest.url().toString(); preSigner.close(); return url; }
Example #2
Source File: S3PinotFS.java From incubator-pinot with Apache License 2.0 | 7 votes |
@Override public void init(Configuration config) { Preconditions.checkArgument(!isNullOrEmpty(config.getString(REGION))); String region = config.getString(REGION); AwsCredentialsProvider awsCredentialsProvider; try { if (!isNullOrEmpty(config.getString(ACCESS_KEY)) && !isNullOrEmpty(config.getString(SECRET_KEY))) { String accessKey = config.getString(ACCESS_KEY); String secretKey = config.getString(SECRET_KEY); AwsBasicCredentials awsBasicCredentials = AwsBasicCredentials.create(accessKey, secretKey); awsCredentialsProvider = StaticCredentialsProvider.create(awsBasicCredentials); } else { awsCredentialsProvider = AwsCredentialsProviderChain.builder().addCredentialsProvider(SystemPropertyCredentialsProvider.create()) .addCredentialsProvider(EnvironmentVariableCredentialsProvider.create()).build(); } _s3Client = S3Client.builder().region(Region.of(region)).credentialsProvider(awsCredentialsProvider).build(); } catch (S3Exception e) { throw new RuntimeException("Could not initialize S3PinotFS", e); } }
Example #3
Source File: ChecksumResetsOnRetryTest.java From aws-sdk-java-v2 with Apache License 2.0 | 7 votes |
@Before public void setup() { StaticCredentialsProvider credentials = StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")); s3Client = S3Client.builder() .credentialsProvider(credentials) .region(Region.US_WEST_2) .endpointOverride(URI.create("http://localhost:" + mockServer.port())) .build(); s3AsyncClient = S3AsyncClient.builder() .credentialsProvider(credentials) .region(Region.US_WEST_2) .endpointOverride(URI.create("http://localhost:" + mockServer.port())) .build(); body = "foo".getBytes(StandardCharsets.UTF_8); String checksumAsHexString = "acbd18db4cc2f85cedef654fccc4a4d8"; bodyEtag = "\"" + checksumAsHexString + "\""; bodyWithTrailingChecksum = ArrayUtils.addAll(body, BinaryUtils.fromHex(checksumAsHexString)); }
Example #4
Source File: DefaultPollyPresignerTest.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Test public void presign_requestLevelCredentials_honored() { AwsCredentials requestCredentials = AwsBasicCredentials.create("akid2", "skid2"); PollyPresigner presigner = DefaultPollyPresigner.builder() .region(Region.US_EAST_1) .credentialsProvider(credentialsProvider) .build(); SynthesizeSpeechRequest synthesizeSpeechRequest = BASIC_SYNTHESIZE_SPEECH_REQUEST.toBuilder() .overrideConfiguration(AwsRequestOverrideConfiguration.builder() .credentialsProvider(StaticCredentialsProvider.create(requestCredentials)).build()) .build(); SynthesizeSpeechPresignRequest presignRequest = SynthesizeSpeechPresignRequest.builder() .synthesizeSpeechRequest(synthesizeSpeechRequest) .signatureDuration(Duration.ofHours(3)) .build(); PresignedSynthesizeSpeechRequest presignedSynthesizeSpeechRequest = presigner.presignSynthesizeSpeech(presignRequest); assertThat(presignedSynthesizeSpeechRequest.url().getQuery()).contains("X-Amz-Credential=akid2"); }
Example #5
Source File: Aws4SignerTest.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Test public void testPresigning() throws Exception { final String expectedAmzSignature = "bf7ae1c2f266d347e290a2aee7b126d38b8a695149d003b9fab2ed1eb6d6ebda"; final String expectedAmzCredentials = "access/19810216/us-east-1/demo/aws4_request"; final String expectedAmzHeader = "19810216T063000Z"; final String expectedAmzExpires = "604800"; AwsBasicCredentials credentials = AwsBasicCredentials.create("access", "secret"); // Test request without 'x-amz-sha256' header SdkHttpFullRequest request = generateBasicRequest().build(); SdkHttpFullRequest signed = SignerTestUtils.presignRequest(signer, request, credentials, null, "demo", signingOverrideClock, "us-east-1"); assertEquals(expectedAmzSignature, signed.rawQueryParameters().get("X-Amz-Signature").get(0)); assertEquals(expectedAmzCredentials, signed.rawQueryParameters().get("X-Amz-Credential").get(0)); assertEquals(expectedAmzHeader, signed.rawQueryParameters().get("X-Amz-Date").get(0)); assertEquals(expectedAmzExpires, signed.rawQueryParameters().get("X-Amz-Expires").get(0)); }
Example #6
Source File: EnvironmentAwsCredentialsProvider.java From micronaut-aws with Apache License 2.0 | 6 votes |
@Override public AwsCredentials resolveCredentials() { String accessKey = environment.getProperty(ACCESS_KEY_ENV_VAR, String.class, environment.getProperty(ALTERNATE_ACCESS_KEY_ENV_VAR, String.class, (String) null)); String secretKey = environment.getProperty(SECRET_KEY_ENV_VAR, String.class, environment.getProperty(ALTERNATE_SECRET_KEY_ENV_VAR, String.class, (String) null)); accessKey = StringUtils.trim(accessKey); secretKey = StringUtils.trim(secretKey); String sessionToken = StringUtils.trim(environment.getProperty(AWS_SESSION_TOKEN_ENV_VAR, String.class, (String) null)); if (StringUtils.isBlank(accessKey) || StringUtils.isBlank(secretKey)) { throw SdkClientException.create( "Unable to load AWS credentials from environment " + "(" + ACCESS_KEY_ENV_VAR + " (or " + ALTERNATE_ACCESS_KEY_ENV_VAR + ") and " + SECRET_KEY_ENV_VAR + " (or " + ALTERNATE_SECRET_KEY_ENV_VAR + "))"); } return sessionToken == null ? AwsBasicCredentials.create(accessKey, secretKey) : AwsSessionCredentials.create(accessKey, secretKey, sessionToken); }
Example #7
Source File: QueryRequestTransformTest.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Before public void setupClient() { client = ProtocolQueryClient.builder() .credentialsProvider(StaticCredentialsProvider.create( AwsBasicCredentials.create("akid", "skid"))) .region(Region.US_EAST_1) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .build(); asyncClient = ProtocolQueryAsyncClient.builder() .credentialsProvider(StaticCredentialsProvider.create( AwsBasicCredentials.create("akid", "skid"))) .region(Region.US_EAST_1) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .build(); }
Example #8
Source File: Aws4SignerTest.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Test public void queryParamsWithNullValuesAreStillSignedWithTrailingEquals() throws Exception { final String expectedAuthorizationHeaderWithoutSha256Header = "AWS4-HMAC-SHA256 Credential=access/19810216/us-east-1/demo/aws4_request, " + "SignedHeaders=host;x-amz-archive-description;x-amz-date, " + "Signature=c45a3ff1f028e83017f3812c06b4440f0b3240264258f6e18cd683b816990ba4"; AwsBasicCredentials credentials = AwsBasicCredentials.create("access", "secret"); // Test request without 'x-amz-sha256' header SdkHttpFullRequest.Builder request = generateBasicRequest().putRawQueryParameter("Foo", (String) null); SdkHttpFullRequest signed = SignerTestUtils.signRequest(signer, request.build(), credentials, "demo", signingOverrideClock, "us-east-1"); assertThat(signed.firstMatchingHeader("Authorization")) .hasValue(expectedAuthorizationHeaderWithoutSha256Header); }
Example #9
Source File: AwsS3Sender.java From fluency with Apache License 2.0 | 6 votes |
@VisibleForTesting protected S3Client buildClient(S3ClientBuilder s3ClientBuilder) { if (config.getEndpoint() != null) { try { URI uri = new URI(config.getEndpoint()); s3ClientBuilder.endpointOverride(uri); } catch (URISyntaxException e) { throw new NonRetryableException( String.format("Invalid endpoint. %s", config.getEndpoint()), e); } } if (config.getRegion() != null) { s3ClientBuilder.region(Region.of(config.getRegion())); } if (config.getAwsAccessKeyId() != null && config.getAwsSecretAccessKey() != null) { AwsBasicCredentials credentials = AwsBasicCredentials.create(config.getAwsAccessKeyId(), config.getAwsSecretAccessKey()); s3ClientBuilder.credentialsProvider(StaticCredentialsProvider.create(credentials)); } return s3ClientBuilder.build(); }
Example #10
Source File: AsyncBatchGetItemTest.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Before public void setup() { DynamoDbAsyncClient dynamoDbClient = DynamoDbAsyncClient.builder() .region(Region.US_WEST_2) .credentialsProvider(() -> AwsBasicCredentials.create("foo", "bar")) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .endpointDiscoveryEnabled(false) .build(); enhancedClient = DynamoDbEnhancedAsyncClient.builder() .dynamoDbClient(dynamoDbClient) .build(); StaticTableSchema<Record> tableSchema = StaticTableSchema.builder(Record.class) .newItemSupplier(Record::new) .addAttribute(Integer.class, a -> a.name("id") .getter(Record::getId) .setter(Record::setId) .tags(primaryPartitionKey())) .build(); table = enhancedClient.table("table", tableSchema); }
Example #11
Source File: GeneratePreSignUrlInterceptorTest.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Test public void copySnapshotRequest_httpsProtocolAddedToEndpoint() { SdkHttpFullRequest request = SdkHttpFullRequest.builder() .uri(URI.create("https://ec2.us-west-2.amazonaws.com")) .method(SdkHttpMethod.POST) .build(); CopySnapshotRequest ec2Request = CopySnapshotRequest.builder() .sourceRegion("us-west-2") .destinationRegion("us-east-2") .build(); when(mockContext.httpRequest()).thenReturn(request); when(mockContext.request()).thenReturn(ec2Request); ExecutionAttributes attrs = new ExecutionAttributes(); attrs.putAttribute(AWS_CREDENTIALS, AwsBasicCredentials.create("foo", "bar")); SdkHttpRequest modifiedRequest = INTERCEPTOR.modifyHttpRequest(mockContext, attrs); String presignedUrl = modifiedRequest.rawQueryParameters().get("PresignedUrl").get(0); assertThat(presignedUrl).startsWith("https://"); }
Example #12
Source File: BatchGetItemTest.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Before public void setup() { DynamoDbClient dynamoDbClient = DynamoDbClient.builder() .region(Region.US_WEST_2) .credentialsProvider(() -> AwsBasicCredentials.create("foo", "bar")) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .endpointDiscoveryEnabled(false) .build(); enhancedClient = DynamoDbEnhancedClient.builder() .dynamoDbClient(dynamoDbClient) .build(); StaticTableSchema<Record> tableSchema = StaticTableSchema.builder(Record.class) .newItemSupplier(Record::new) .addAttribute(Integer.class, a -> a.name("id") .getter(Record::getId) .setter(Record::setId) .tags(primaryPartitionKey())) .build(); table = enhancedClient.table("table", tableSchema); }
Example #13
Source File: EmbeddedSqsServer.java From beam with Apache License 2.0 | 6 votes |
static void start() { sqsRestServer = SQSRestServerBuilder.withPort(port).start(); client = SqsClient.builder() .credentialsProvider( StaticCredentialsProvider.create(AwsBasicCredentials.create("x", "x"))) .endpointOverride(URI.create(endPoint)) .region(Region.US_WEST_2) .build(); CreateQueueRequest createQueueRequest = CreateQueueRequest.builder().queueName(queueName).build(); final CreateQueueResponse queue = client.createQueue(createQueueRequest); queueUrl = queue.queueUrl(); }
Example #14
Source File: EnhancedClientPutOverheadBenchmark.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Setup public void setup(Blackhole bh) { ddb = DynamoDbClient.builder() .credentialsProvider(StaticCredentialsProvider.create( AwsBasicCredentials.create("akid", "skid"))) .httpClient(new MockHttpClient("{}", "{}")) .overrideConfiguration(c -> c.addExecutionInterceptor(new ExecutionInterceptor() { @Override public void afterUnmarshalling(Context.AfterUnmarshalling context, ExecutionAttributes executionAttributes) { bh.consume(context); bh.consume(executionAttributes); } })) .build(); DynamoDbEnhancedClient ddbEnh = DynamoDbEnhancedClient.builder() .dynamoDbClient(ddb) .build(); enhTable = ddbEnh.table(testItem.name(), testItem.tableSchema); }
Example #15
Source File: PaginatorInUserAgentTest.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Before public void setup() { dynamoDbClient = DynamoDbClient.builder() .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("test", "test"))) .region(Region.US_WEST_2).endpointOverride(URI.create("http://localhost:" + mockServer .port())) .build(); dynamoDbAsyncClient = DynamoDbAsyncClient.builder() .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials .create("test", "test"))) .region(Region.US_WEST_2).endpointOverride(URI.create("http://localhost:" + mockServer.port())) .build(); }
Example #16
Source File: SdkHttpResponseTest.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Before public void setupClient() { client = ProtocolRestJsonClient.builder() .region(Region.US_WEST_1) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .credentialsProvider(() -> AwsBasicCredentials.create("akid", "skid")) .build(); asyncClient = ProtocolRestJsonAsyncClient.builder() .region(Region.US_WEST_1) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .credentialsProvider(() -> AwsBasicCredentials.create("akid", "skid")) .build(); }
Example #17
Source File: SyncApiCallTimeoutTest.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Before public void setup() { client = ProtocolRestJsonClient.builder() .region(Region.US_WEST_1) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .credentialsProvider(() -> AwsBasicCredentials.create("akid", "skid")) .overrideConfiguration(b -> b.apiCallTimeout(Duration.ofMillis(TIMEOUT)) .retryPolicy(RetryPolicy.none())) .build(); clientWithRetry = ProtocolRestJsonClient.builder() .region(Region.US_WEST_1) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .credentialsProvider(() -> AwsBasicCredentials.create("akid", "skid")) .overrideConfiguration(b -> b.apiCallTimeout(Duration.ofMillis(TIMEOUT)) .retryPolicy(RetryPolicy.builder().numRetries(1) .build())) .build(); }
Example #18
Source File: SyncApiCallAttemptTimeoutTest.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Before public void setup() { client = ProtocolRestJsonClient.builder() .region(Region.US_WEST_1) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .credentialsProvider(() -> AwsBasicCredentials.create("akid", "skid")) .overrideConfiguration( b -> b.apiCallAttemptTimeout(Duration.ofMillis(API_CALL_ATTEMPT_TIMEOUT)) .retryPolicy(RetryPolicy.none())) .build(); clientWithRetry = ProtocolRestJsonClient.builder() .region(Region.US_WEST_1) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .credentialsProvider(() -> AwsBasicCredentials.create("akid", "skid")) .overrideConfiguration( b -> b.apiCallAttemptTimeout(Duration.ofMillis(API_CALL_ATTEMPT_TIMEOUT)) .retryPolicy(RetryPolicy.builder() .numRetries(1) .build())) .build(); }
Example #19
Source File: S3EndpointResolutionTest.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Test public void regionalSettingEnabledViaProfile_usesRegionalIadEndpoint() throws UnsupportedEncodingException { String profile = "[profile test]\n" + "s3_us_east_1_regional_endpoint = regional"; ProfileFile profileFile = ProfileFile.builder() .content(new StringInputStream(profile)) .type(ProfileFile.Type.CONFIGURATION) .build(); mockHttpClient.stubNextResponse(mockListObjectsResponse()); S3Client s3Client = S3Client.builder() .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid"))) .httpClient(mockHttpClient) .region(Region.US_EAST_1) .overrideConfiguration(c -> c.defaultProfileFile(profileFile) .defaultProfileName("test")) .serviceConfiguration(c -> c.pathStyleAccessEnabled(true)) .build(); s3Client.listObjects(ListObjectsRequest.builder().bucket(BUCKET).build()); assertThat(mockHttpClient.getLastRequest().getUri().getHost()).isEqualTo("s3.us-east-1.amazonaws.com"); }
Example #20
Source File: AsyncApiCallTimeoutTest.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Before public void setup() { client = ProtocolRestJsonAsyncClient.builder() .region(Region.US_WEST_1) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .credentialsProvider(() -> AwsBasicCredentials.create("akid", "skid")) .overrideConfiguration(b -> b.apiCallTimeout(Duration.ofMillis(TIMEOUT)) .retryPolicy(RetryPolicy.none())) .build(); clientWithRetry = ProtocolRestJsonAsyncClient.builder() .region(Region.US_WEST_1) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .credentialsProvider(() -> AwsBasicCredentials.create("akid", "skid")) .overrideConfiguration(b -> b.apiCallTimeout(Duration.ofMillis(TIMEOUT)) .retryPolicy(RetryPolicy.builder().numRetries(1).build())) .build(); }
Example #21
Source File: S3EndpointResolutionTest.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Test public void regionalSettingUnset_usesGlobalEndpoint() throws UnsupportedEncodingException { mockHttpClient.stubNextResponse(mockListObjectsResponse()); S3Client s3Client = S3Client.builder() .credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid"))) .httpClient(mockHttpClient) .region(Region.US_EAST_1) .serviceConfiguration(S3Configuration.builder() .pathStyleAccessEnabled(true) .build()) .build(); s3Client.listObjects(ListObjectsRequest.builder().bucket(BUCKET).build()); assertThat(mockHttpClient.getLastRequest().getUri().getHost()).isEqualTo("s3.amazonaws.com"); }
Example #22
Source File: AsyncApiCallAttemptsTimeoutTest.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Before public void setup() { client = ProtocolRestJsonAsyncClient.builder() .region(Region.US_WEST_1) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .credentialsProvider(() -> AwsBasicCredentials.create("akid", "skid")) .overrideConfiguration(b -> b.apiCallAttemptTimeout(Duration.ofMillis(API_CALL_ATTEMPT_TIMEOUT)) .retryPolicy(RetryPolicy.none())) .build(); clientWithRetry = ProtocolRestJsonAsyncClient.builder() .region(Region.US_WEST_1) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .credentialsProvider(() -> AwsBasicCredentials.create("akid", "skid")) .overrideConfiguration(b -> b.apiCallAttemptTimeout(Duration.ofMillis(API_CALL_ATTEMPT_TIMEOUT)) .retryPolicy(RetryPolicy.builder() .numRetries(1) .build())) .build(); }
Example #23
Source File: SqsMessageQueueReceiverEndpointIntegrationTest.java From synapse with Apache License 2.0 | 6 votes |
@Before public void setUp() { new SqsClientHelper(asyncClient).createChannelIfNotExists(SQS_INTEGRATION_TEST_CHANNEL); AwsProperties awsProperties = new AwsProperties(); awsProperties.setRegion(Region.EU_CENTRAL_1.id()); delegateAsyncClient = SqsAsyncClient.builder() .credentialsProvider(StaticCredentialsProvider.create( AwsBasicCredentials.create("foobar", "foobar"))) .overrideConfiguration(ClientOverrideConfiguration.builder() .apiCallAttemptTimeout(Duration.ofMillis(200)) .retryPolicy(new SqsAutoConfiguration(awsProperties) .sqsRetryPolicy()).build()) .endpointOverride(URI.create("http://localhost:8080/")) .build(); }
Example #24
Source File: AsyncOperationCancelTest.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
@Before public void setUp() { client = ProtocolRestJsonAsyncClient.builder() .region(Region.US_EAST_1) .credentialsProvider(StaticCredentialsProvider.create( AwsBasicCredentials.create("foo", "bar"))) .httpClient(mockHttpClient) .build(); executeFuture = new CompletableFuture(); when(mockHttpClient.execute(any())).thenReturn(executeFuture); }
Example #25
Source File: Aws4SignerRequestParamsTest.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
private void offsetTest(int offsetSeconds) { Aws4SignerParams signerParams = Aws4SignerParams.builder() .awsCredentials(AwsBasicCredentials.create("akid", "skid")) .doubleUrlEncode(false) .signingName("test-service") .signingRegion(Region.US_WEST_2) .timeOffset(offsetSeconds) .build(); Instant now = Instant.now(); Aws4SignerRequestParams requestParams = new Aws4SignerRequestParams(signerParams); Instant requestSigningInstant = Instant.ofEpochMilli(requestParams.getRequestSigningDateTimeMilli()); // The offset is subtracted from the current time if (offsetSeconds > 0) { assertThat(requestSigningInstant).isBefore(now); } else { assertThat(requestSigningInstant).isAfter(now); } Duration diff = Duration.between(requestSigningInstant, now.minusSeconds(offsetSeconds)); // Allow some wiggle room in the difference since we can't use a clock // override for complete accuracy as it doesn't apply the offset when // using a clock override assertThat(diff).isLessThanOrEqualTo(Duration.ofMillis(100)); }
Example #26
Source File: ResponseTransformerTest.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
private ProtocolRestJsonClientBuilder testClientBuilder() { return ProtocolRestJsonClient.builder() .region(Region.US_WEST_1) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .credentialsProvider(() -> AwsBasicCredentials.create("akid", "skid")) .httpClientBuilder(ApacheHttpClient.builder().socketTimeout(Duration.ofSeconds(1))); }
Example #27
Source File: BaseSyncStreamingTimeoutTest.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
@Before public void setup() { client = ProtocolRestJsonClient.builder() .region(Region.US_WEST_1) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .credentialsProvider(() -> AwsBasicCredentials.create("akid", "skid")) .overrideConfiguration(clientOverrideConfiguration()) .build(); }
Example #28
Source File: ProfileCredentialsUtilsTest.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
@Test public void profileFileWithProcessCredentialsLoadsCorrectly() { ProfileFile profileFile = allTypesProfile(); assertThat(profileFile.profile("profile-credential-process")).hasValueSatisfying(profile -> { assertThat(profile.property(ProfileProperty.REGION)).isNotPresent(); assertThat(new ProfileCredentialsUtils(profile, profileFile::profile).credentialsProvider()).hasValueSatisfying(credentialsProvider -> { assertThat(credentialsProvider.resolveCredentials()).satisfies(credentials -> { assertThat(credentials).isInstanceOf(AwsBasicCredentials.class); assertThat(credentials.accessKeyId()).isEqualTo("defaultAccessKey"); assertThat(credentials.secretAccessKey()).isEqualTo("defaultSecretAccessKey"); }); }); }); }
Example #29
Source File: InspectorErrorUnmarshallingTest.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
@Before public void setup() { StaticCredentialsProvider credsProvider = StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid")); inspector = InspectorClient.builder() .credentialsProvider(credsProvider) .region(Region.US_EAST_1) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .build(); }
Example #30
Source File: LocalDynamoDb.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
/** * Create a standard AWS v2 SDK client pointing to the local DynamoDb instance * @return A DynamoDbClient pointing to the local DynamoDb instance */ DynamoDbClient createClient() { String endpoint = String.format("http://localhost:%d", port); return DynamoDbClient.builder() .endpointOverride(URI.create(endpoint)) // The region is meaningless for local DynamoDb but required for client builder validation .region(Region.US_EAST_1) .credentialsProvider(StaticCredentialsProvider.create( AwsBasicCredentials.create("dummy-key", "dummy-secret"))) .overrideConfiguration(o -> o.addExecutionInterceptor(new VerifyUserAgentInterceptor())) .build(); }