Add expiration support for message_verifier and message_encryptor

The patch will bake the expiration into message_verifier's signed message and message_encryptor's encrypted message to prevent the expiration from being forged. It will check the expiration every time you try to verify a signed message or decrypt an encrypted message. If the message is expired, it will raise an exception ExpiredMessage.
```ruby
encrypted_message = encryptor.encrypt_and_sign( data, 1.hour.from_now)
encryptor.decrypt_and_verify(encrypted_message) #=> data if not expired
encryptor.decrypt_and_verify(encrypted_message) #> raise ExpiredMessage if expired
```
cc @rafaelfranca @chancancode
`Time` is a wrapper around an Epoch integer. http://www.ruby-doc.org/core-2.1.2/Time.html

Anyway do it which ever way you want. I just think using `Time` for the comparisons seems more correct :smile:

Den 22/08/2014 kl. 22.59 skrev Xuchu Zhang <notifications@github.com>:

> In activesupport/lib/active_support/message_verifier.rb:
> 
> > +      end
> > +      [expiration, value]
> > +    end
> > +
> > +    def encode_expiration(time)
> > +      if time.is_a?(Time) || time.is_a?(DateTime)
> > +        "#{time.to_i}"
> > +      elsif time.is_a?(Date)
> > +        "#{time.to_time.to_i}"
> > +      else
> > +        raise ArgumentError
> > +      end
> > +    end
> > +
> > +    def is_expired?(timestamp)
> > +      timestamp && Time.now.to_i > timestamp.to_i
> @kaspth, I think comparing two integer number is more accuracy and efficient than comparing two Time objects.
> 
> —
> Reply to this email directly or view it on GitHub.
> 

--
Kasper