13
13
* permissions and limitations under the License.
14
14
*/
15
15
16
+ using Amazon . Util ;
16
17
using System ;
18
+ using System . Globalization ;
17
19
using System . Text ;
18
20
19
21
namespace Amazon . Runtime . Internal . Auth
@@ -38,7 +40,7 @@ public class AWS4aSigningResult : AWSSigningResultBase
38
40
/// <param name="awsAccessKeyId">The access key that was included in the signature</param>
39
41
/// <param name="signedAt">Date/time (UTC) that the signature was computed</param>
40
42
/// <param name="signedHeaders">The collection of headers names that were included in the signature</param>
41
- /// <param name="scope">Formatted 'scope' value for signing (YYYYMMDD/region/ service/aws4_request)</param>
43
+ /// <param name="scope">Formatted 'scope' value for signing (YYYYMMDD/service/aws4_request)</param>
42
44
/// <param name="regionSet">The set of AWS regions this signature is valid for</param>
43
45
/// <param name="signature">Computed signature</param>
44
46
/// <param name="service">Service the request was signed for</param>
@@ -87,6 +89,25 @@ public override string ForAuthorizationHeader
87
89
}
88
90
}
89
91
92
+ /// <summary>
93
+ /// Returns the signature in a form usable as a set of query string parameters.
94
+ /// </summary>
95
+ public string ForQueryParameters
96
+ {
97
+ get
98
+ {
99
+ var authParams = new StringBuilder ( )
100
+ . AppendFormat ( "{0}={1}" , AWSSDKUtils . UrlEncode ( HeaderKeys . XAmzAlgorithm , false ) , AWSSDKUtils . UrlEncode ( AWS4Signer . AWS4aAlgorithmTag , false ) )
101
+ . AppendFormat ( "&{0}={1}" , AWSSDKUtils . UrlEncode ( HeaderKeys . XAmzRegionSetHeader , false ) , AWSSDKUtils . UrlEncode ( RegionSet , false ) )
102
+ . AppendFormat ( "&{0}={1}" , AWSSDKUtils . UrlEncode ( HeaderKeys . XAmzCredential , false ) , AWSSDKUtils . UrlEncode ( string . Format ( CultureInfo . InvariantCulture , "{0}/{1}" , AccessKeyId , Scope ) , false ) )
103
+ . AppendFormat ( "&{0}={1}" , AWSSDKUtils . UrlEncode ( HeaderKeys . XAmzDateHeader , false ) , AWSSDKUtils . UrlEncode ( ISO8601DateTime , false ) )
104
+ . AppendFormat ( "&{0}={1}" , AWSSDKUtils . UrlEncode ( HeaderKeys . XAmzSignedHeadersHeader , false ) , AWSSDKUtils . UrlEncode ( SignedHeaders , false ) )
105
+ . AppendFormat ( "&{0}={1}" , AWSSDKUtils . UrlEncode ( HeaderKeys . XAmzSignature , false ) , AWSSDKUtils . UrlEncode ( Signature , false ) ) ;
106
+
107
+ return authParams . ToString ( ) ;
108
+ }
109
+ }
110
+
90
111
/// <summary>
91
112
/// Returns the set of regions this signature is valid for
92
113
/// </summary>
@@ -99,6 +120,7 @@ public string RegionSet
99
120
/// <summary>
100
121
/// Returns the full presigned Uri
101
122
/// </summary>
123
+ [ Obsolete ( "This property is always empty in objects returned by AWS4aSigner. Use the ForQueryParameters property instead, to get the query parameters for a presigned URL." ) ]
102
124
public string PresignedUri
103
125
{
104
126
get { return _presignedUri ; }
0 commit comments