11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/hawk/timestamp_mac_header.rb', line 11
def build(options)
options[:ts] ||= Time.now.to_i
credentials = options[:credentials]
REQUIRED_CREDENTIAL_MEMBERS.each do |key|
unless credentials.has_key?(key)
raise InvalidCredentialsError.new("#{key.inspect} is missing!")
end
end
unless SUPPORTED_ALGORITHMS.include?(credentials[:algorithm])
raise InvalidAlgorithmError.new("#{credentials[:algorithm].inspect} is not a supported algorithm! Use one of the following: #{SUPPORTED_ALGORITHMS.join(', ')}")
end
tsm = Crypto.ts_mac(options)
%(Hawk ts="#{options[:ts]}", tsm="#{tsm}")
end
|