Class: Arrow::Session::UserTrackId

Inherits:
Id show all
Defined in:
lib/arrow/session/usertrackid.rb

Overview

The Arrow::Session::UsertrackId class, a derivative of Arrow::Session::Id. This class creates session id objects which uses Apache’s builtin mod_usertrack for the session key.

Authors

  • Michael Granger

Please see the file LICENSE in the top-level directory for licensing details.

Class Method Summary

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

#log

Constructor Details

This class inherits a constructor from Arrow::Session::Id

Class Method Details

+ (Object) generate(uri, request)

Generate a new id string for the given request



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/arrow/session/usertrackid.rb', line 35

def self::generate( uri, request )
  if uri.path
    cookieName = uri.path.sub( %r{^/}, '' )
  else
    cookieName = 'Apache'
  end

  unless request.cookies.key?( cookieName )
    raise SessionError, "No cookie named '%s' was found. Make sure "\
      "mod_usertrack is enabled and configured correctly" %
      cookieName
  end

  return validate( uri, request.cookies[cookieName].value )
end

+ (Object) validate(uri, idstring)

Returns an untainted copy of the specified idstring if it is in the expected form for this type of id.



26
27
28
29
30
31
# File 'lib/arrow/session/usertrackid.rb', line 26

def self::validate( uri, idstring )
  return nil if idstring.nil?
  rval = idstring[/^[\w.]+\.\d+$/] or return nil?
  rval.untaint
  return rval
end