Sha256: 0a8a1f5fac466c7cea0cd0f33791faf8b241f2db79b71b389a0911fd3dd64b4c

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

# Copyright 2011-2013 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.

require 'time'

module AWS
  class CloudFront

    # @private
    class Request < Core::Http::Request

      def add_authorization! credentials

        self.access_key_id = credentials.access_key_id

        auth = "AWS #{access_key_id}:#{signature(credentials)}"
        headers['authorization'] = auth

      end

      protected

      def signature credentials
        Core::Signer.sign(credentials.secret_access_key, string_to_sign, 'sha1')
      end

      def string_to_sign
        headers['date'] ||= Time.now.rfc822
      end

    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aws-sdk-1.8.1.2 lib/aws/cloud_front/request.rb
aws-sdk-1.8.1.1 lib/aws/cloud_front/request.rb
aws-sdk-1.8.1 lib/aws/cloud_front/request.rb