Search in sources :

Example 1 with AwsS3V4Signer

use of software.amazon.awssdk.auth.signer.AwsS3V4Signer in project aws-sdk-java-v2 by aws.

the class AwsS3V4SignerIntegrationTest method test_SignMethod_WithModeledParam_And_WithoutUsingSdkClient.

@Test
public void test_SignMethod_WithModeledParam_And_WithoutUsingSdkClient() throws Exception {
    AwsS3V4Signer signer = AwsS3V4Signer.create();
    SdkHttpFullRequest httpFullRequest = generateBasicGetRequest();
    // sign the request
    SdkHttpFullRequest signedRequest = signer.sign(httpFullRequest, constructSignerParams());
    SdkHttpClient httpClient = ApacheHttpClient.builder().build();
    HttpExecuteResponse response = httpClient.prepareRequest(HttpExecuteRequest.builder().request(signedRequest).build()).call();
    assertEquals("Non success http status code", 200, response.httpResponse().statusCode());
    String actualResult = IoUtils.toUtf8String(response.responseBody().get());
    assertEquals(CONTENT, actualResult);
}
Also used : HttpExecuteResponse(software.amazon.awssdk.http.HttpExecuteResponse) SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) SdkHttpClient(software.amazon.awssdk.http.SdkHttpClient) AwsS3V4Signer(software.amazon.awssdk.auth.signer.AwsS3V4Signer) Test(org.junit.Test)

Example 2 with AwsS3V4Signer

use of software.amazon.awssdk.auth.signer.AwsS3V4Signer in project aws-sdk-java-v2 by aws.

the class AwsS3V4SignerIntegrationTest method test_SignMethod_WithExecutionAttributes_And_WithoutUsingSdkClient.

@Test
public void test_SignMethod_WithExecutionAttributes_And_WithoutUsingSdkClient() throws Exception {
    AwsS3V4Signer signer = AwsS3V4Signer.create();
    SdkHttpFullRequest httpFullRequest = generateBasicGetRequest();
    // sign the request
    SdkHttpFullRequest signedRequest = signer.sign(httpFullRequest, constructExecutionAttributes());
    SdkHttpClient httpClient = ApacheHttpClient.builder().build();
    HttpExecuteResponse response = httpClient.prepareRequest(HttpExecuteRequest.builder().request(signedRequest).build()).call();
    assertEquals("Non success http status code", 200, response.httpResponse().statusCode());
    String actualResult = IoUtils.toUtf8String(response.responseBody().get());
    assertEquals(CONTENT, actualResult);
}
Also used : HttpExecuteResponse(software.amazon.awssdk.http.HttpExecuteResponse) SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) SdkHttpClient(software.amazon.awssdk.http.SdkHttpClient) AwsS3V4Signer(software.amazon.awssdk.auth.signer.AwsS3V4Signer) Test(org.junit.Test)

Example 3 with AwsS3V4Signer

use of software.amazon.awssdk.auth.signer.AwsS3V4Signer in project aws-sdk-java-v2 by aws.

the class AwsS3V4SignerIntegrationTest method testPresigning.

@Test
public void testPresigning() throws MalformedURLException {
    AwsS3V4Signer signer = AwsS3V4Signer.create();
    SdkHttpFullRequest httpFullRequest = generateBasicGetRequest();
    SdkHttpFullRequest signedRequest = signer.presign(httpFullRequest, constructPresignerParams());
    URL presignedUri = signedRequest.getUri().toURL();
    assertEquals(CONTENT, getContentFromPresignedUrl(presignedUri));
}
Also used : SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) URL(java.net.URL) AwsS3V4Signer(software.amazon.awssdk.auth.signer.AwsS3V4Signer) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 AwsS3V4Signer (software.amazon.awssdk.auth.signer.AwsS3V4Signer)3 SdkHttpFullRequest (software.amazon.awssdk.http.SdkHttpFullRequest)3 HttpExecuteResponse (software.amazon.awssdk.http.HttpExecuteResponse)2 SdkHttpClient (software.amazon.awssdk.http.SdkHttpClient)2 URL (java.net.URL)1