Class: Rubymail::Secure

Inherits:
Object show all
Defined in:
lib/rubymail/secure.rb

Instance Method Summary collapse

Constructor Details

#initialize(rubymail) ⇒ Secure

Returns a new instance of Secure.



3
4
5
# File 'lib/rubymail/secure.rb', line 3

def initialize(rubymail)
  @rubymail = rubymail
end

Instance Method Details

#check_request_auth(timestamp, token, signature, offset = -5)) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rubymail/secure.rb', line 7

def check_request_auth(timestamp, token, signature, offset=-5)
  if offset != 0
    offset = Time.now.to_i + offset * 60
    return false if timestamp < offset
  end
  
  return signature == OpenSSL::HMAC.hexdigest(
    OpenSSL::Digest::Digest.new('sha256'),
    Rubymail.api_key,
    '%s%s' % [timestamp, token])
end