1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[storage|ninefold] use Fog::HMAC

This commit is contained in:
geemus 2011-08-31 15:32:12 -05:00
parent a0d3fe9dd2
commit e9cda00650

View file

@ -51,6 +51,8 @@ module Fog
@ninefold_storage_secret = options[:ninefold_storage_secret] @ninefold_storage_secret = options[:ninefold_storage_secret]
@ninefold_storage_secret_decoded = Base64.decode64( @ninefold_storage_secret ) @ninefold_storage_secret_decoded = Base64.decode64( @ninefold_storage_secret )
@hmac = Fog::HMAC.new('sha1', @ninefold_storage_secret_decoded)
Excon.ssl_verify_peer = false if options[:rackspace_servicenet] == true Excon.ssl_verify_peer = false if options[:rackspace_servicenet] == true
@connection = Fog::Connection.new("#{Fog::Storage::Ninefold::STORAGE_SCHEME}://#{Fog::Storage::Ninefold::STORAGE_HOST}:#{Fog::Storage::Ninefold::STORAGE_PORT}", true) # persistent @connection = Fog::Connection.new("#{Fog::Storage::Ninefold::STORAGE_SCHEME}://#{Fog::Storage::Ninefold::STORAGE_HOST}:#{Fog::Storage::Ninefold::STORAGE_PORT}", true) # persistent
end end
@ -60,7 +62,7 @@ module Fog
end end
def sign(string) def sign(string)
value = ::HMAC::SHA1.digest( @ninefold_storage_secret_decoded, string ) value = @hmac.sign(string)
Base64.encode64( value ).chomp() Base64.encode64( value ).chomp()
end end
@ -117,7 +119,7 @@ module Fog
signstring += key + ":" + value.strip.chomp.squeeze( " " ) + "\n" signstring += key + ":" + value.strip.chomp.squeeze( " " ) + "\n"
} }
digest = ::HMAC::SHA1.digest( @ninefold_storage_secret_decoded, signstring.chomp() ) digest = @hmac.sign(signstring.chomp())
signature = Base64.encode64( digest ).chomp() signature = Base64.encode64( digest ).chomp()
params[:headers]["x-emc-signature"] = signature params[:headers]["x-emc-signature"] = signature