Class: Arrow::Session::MD5Id
- Inherits:
-
Id
- Object
- Arrow::Object
- Id
- Arrow::Session::MD5Id
- Defined in:
- lib/arrow/session/md5id.rb
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
Please see the file LICENSE in the top-level directory for licensing details.
Class Method Summary
-
+ (Object) generate(uri, request)
Generate a new id.
-
+ (Object) validate(uri, idstr)
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 Arrow::Object
deprecate_class_method, deprecate_method, inherited
Methods included from Arrow::Loggable
Constructor Details
This class inherits a constructor from Arrow::Session::Id
Class Method Details
+ (Object) generate(uri, request)
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 |
+ (Object) validate(uri, idstr)
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 |