Class: Arrow::Session::MD5Id
Overview
The Arrow::Session::MD5Id class, a derivative of Arrow::Session::Id. Instances of this class are session IDs created by MD5-hashing some semi-random data.
Authors
-
Michael Granger <[email protected]>
Please see the file LICENSE in the top-level directory for licensing details.
Class Method Summary collapse
-
.generate(uri, request) ⇒ Object
Generate a new id.
-
.validate(uri, idstr) ⇒ Object
Returns the validated id if the given id is in the expected form for this type, or
nil
if it is not.
Methods inherited from Id
create, derivativeDirs, #initialize, #new?, #to_s
Methods inherited from Object
deprecate_class_method, deprecate_method, inherited
Constructor Details
This class inherits a constructor from Arrow::Session::Id
Class Method Details
.generate(uri, request) ⇒ Object
Generate a new id
24 25 26 27 28 29 30 31 32 |
# File 'lib/arrow/session/md5id.rb', line 24 def self::generate( uri, request ) seed = [ Time.new.to_s, Object.new.inspect, rand(), Process.pid, ].join return Digest::MD5.hexdigest( Digest::MD5.hexdigest(seed) ) end |
.validate(uri, idstr) ⇒ Object
Returns the validated id if the given id is in the expected form for this type, or nil
if it is not.
36 37 38 39 40 |
# File 'lib/arrow/session/md5id.rb', line 36 def self::validate( uri, idstr ) rval = idstr[/^([a-f0-9]{32})$/] rval.untaint return rval end |