Class: Arrow::Session::SHA1Id
- Inherits:
 - 
      Id
      
        
- Object
 - Arrow::Object
 - Id
 - Arrow::Session::SHA1Id
 
 - Defined in:
 - lib/arrow/session/sha1id.rb
 
Overview
The Arrow::Session::SHA1Id class, a derivative of Arrow::Session::Id. Instances of this class are session IDs created by SHA1-hashing some semi-random data.
Synopsis
  # In arrow.conf:
session:
idType: sha1:.
Authors
Michael Granger
Please see the file LICENSE in the top-level directory for licensing details.
Constant Summary
- DEFAULT_SALT =
          
Default salt characters
 'sadblkw456jbhgsdfi7283hnehonaseegop26m'
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
      34 35 36 37 38 39 40 41 42 43 44  | 
    
      # File 'lib/arrow/session/sha1id.rb', line 34 def self::generate( uri, request ) salt = uri.opaque || DEFAULT_SALT seed = [ salt, Time.new.to_s, Object.new.inspect, rand(), Process.pid, ].join return Digest::SHA1.hexdigest( Digest::SHA1.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.
      48 49 50 51 52  | 
    
      # File 'lib/arrow/session/sha1id.rb', line 48 def self::validate( uri, idstr ) rval = idstr[/^([a-f0-9]{40})$/] rval.untaint return rval end  |