/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ using Amazon.Util; using System; namespace Amazon.Runtime.Internal.Auth { /// /// Base class for the various fields and eventual signing value /// that make up an AWS request signature. /// public abstract class AWSSigningResultBase { private readonly string _awsAccessKeyId; private readonly DateTime _originalDateTime; private readonly string _signedHeaders; private readonly string _scope; /// /// Constructs a new signing result instance for a computed signature /// /// The access key that was included in the signature /// Date/time (UTC) that the signature was computed /// The collection of headers names that were included in the signature /// Formatted 'scope' value for signing (YYYYMMDD/region/service/aws4_request) public AWSSigningResultBase(string awsAccessKeyId, DateTime signedAt, string signedHeaders, string scope) { _awsAccessKeyId = awsAccessKeyId; _originalDateTime = signedAt; _signedHeaders = signedHeaders; _scope = scope; } /// /// The access key that was used in signature computation. /// public string AccessKeyId { get { return _awsAccessKeyId; } } /// /// ISO8601 formatted date/time that the signature was computed /// public string ISO8601DateTime { get { return AWS4Signer.FormatDateTime(_originalDateTime, AWSSDKUtils.ISO8601BasicDateTimeFormat); } } /// /// ISO8601 formatted date that the signature was computed /// public string ISO8601Date { get { return AWS4Signer.FormatDateTime(_originalDateTime, AWSSDKUtils.ISO8601BasicDateFormat); } } /// /// Original date/time that the signature was computed /// public DateTime DateTime { get { return _originalDateTime; } } /// /// The ;-delimited collection of header names that were included in the signature computation /// public string SignedHeaders { get { return _signedHeaders; } } /// /// Formatted 'scope' value for signing (YYYYMMDD/region/service/aws4_request) /// public string Scope { get { return _scope; } } public abstract string Signature { get; } public abstract string ForAuthorizationHeader { get; } } }