1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  *  http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 package software.amazon.awssdk.http.auth.aws.signer;
17 
18 import java.time.Duration;
19 import software.amazon.awssdk.annotations.SdkPublicApi;
20 import software.amazon.awssdk.checksums.spi.ChecksumAlgorithm;
21 import software.amazon.awssdk.http.auth.spi.signer.HttpSigner;
22 import software.amazon.awssdk.http.auth.spi.signer.SignerProperty;
23 import software.amazon.awssdk.identity.spi.Identity;
24 
25 /**
26  * An interface shared by {@link AwsV4HttpSigner} and {@link AwsV4aHttpSigner} for defining signer properties that are common
27  * across both signers.
28  */
29 @SdkPublicApi
30 public interface AwsV4FamilyHttpSigner<T extends Identity> extends HttpSigner<T> {
31     /**
32      * The name of the AWS service. This property is required.
33      */
34     SignerProperty<String> SERVICE_SIGNING_NAME =
35         SignerProperty.create(AwsV4FamilyHttpSigner.class, "ServiceSigningName");
36 
37     /**
38      * A boolean to indicate whether to double url-encode the resource path when constructing the canonical request. This property
39      * defaults to true.
40      */
41     SignerProperty<Boolean> DOUBLE_URL_ENCODE =
42         SignerProperty.create(AwsV4FamilyHttpSigner.class, "DoubleUrlEncode");
43 
44     /**
45      * A boolean to indicate whether the resource path should be "normalized" according to RFC3986 when constructing the canonical
46      * request. This property defaults to true.
47      */
48     SignerProperty<Boolean> NORMALIZE_PATH =
49         SignerProperty.create(AwsV4FamilyHttpSigner.class, "NormalizePath");
50 
51     /**
52      * The location where auth-related data is inserted, as a result of signing. This property defaults to HEADER.
53      */
54     SignerProperty<AuthLocation> AUTH_LOCATION =
55         SignerProperty.create(AwsV4FamilyHttpSigner.class, "AuthLocation");
56 
57     /**
58      * The duration for the request to be valid. This property defaults to null. This can be set to presign the request for
59      * later use. The maximum allowed value for this property is 7 days. This is only supported when AuthLocation=QUERY.
60      */
61     SignerProperty<Duration> EXPIRATION_DURATION =
62         SignerProperty.create(AwsV4FamilyHttpSigner.class, "ExpirationDuration");
63 
64     /**
65      * Whether to indicate that a payload is signed or not. This property defaults to true. This can be set false to disable
66      * payload signing.
67      */
68     SignerProperty<Boolean> PAYLOAD_SIGNING_ENABLED =
69         SignerProperty.create(AwsV4FamilyHttpSigner.class, "PayloadSigningEnabled");
70 
71     /**
72      * Whether to indicate that a payload is chunk-encoded or not. This property defaults to false. This can be set true to
73      * enable the `aws-chunk` content-encoding
74      */
75     SignerProperty<Boolean> CHUNK_ENCODING_ENABLED =
76         SignerProperty.create(AwsV4FamilyHttpSigner.class, "ChunkEncodingEnabled");
77 
78     /**
79      * The algorithm to use for calculating a "flexible" checksum. This property is optional.
80      */
81     SignerProperty<ChecksumAlgorithm> CHECKSUM_ALGORITHM =
82         SignerProperty.create(AwsV4FamilyHttpSigner.class, "ChecksumAlgorithm");
83 
84     /**
85      * This enum represents where auth-related data is inserted, as a result of signing.
86      */
87     enum AuthLocation {
88         /**
89          * Indicates auth-related data is inserted in HTTP headers.
90          */
91         HEADER,
92 
93         /**
94          * Indicates auth-related data is inserted in HTTP query-parameters.
95          */
96         QUERY_STRING
97     }
98 }
99