Subversion Info

Rev
406
Last Checked In
2007-07-18 17:01:59 (9 months ago)
Checked in by
bbleything

Methods

Class Index

Quicksearch

Arrow::Session::SHA1Id

MD5 Session IDs class.

Constants

SVNRev
SVN Revision
SVNId
SVN Id
DEFAULT_SALT
Default salt characters

Public Class Methods

generate( uri, request ) click to toggle source

Generate a new id

    # File /Users/ged/source/ruby/Arrow/lib/arrow/session/sha1id.rb, line 50
50:     def self::generate( uri, request )
51:         salt = uri.opaque || DEFAULT_SALT
52:         seed = [
53:             salt,
54:             Time.new.to_s,
55:             Object.new.inspect,
56:             rand(),
57:             Process.pid,
58:         ].join
59:         return Digest::SHA1.hexdigest( Digest::SHA1.hexdigest(seed) )
60:     end
validate( uri, idstr ) click to toggle source

Returns the validated id if the given id is in the expected form for this type, or nil if it is not.

    # File /Users/ged/source/ruby/Arrow/lib/arrow/session/sha1id.rb, line 64
64:     def self::validate( uri, idstr )
65:         rval = idstr[/^([a-f0-9]{40})$/]
66:         rval.untaint
67:         return rval
68:     end

secsequence

--- SEC00117

seccomment

--- ""

method_list

--- 
- methods: 
  - visibility: public
    aref: M000049
    name: generate
    sourcecode: "    <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session/sha1id.rb, line 50</span>\n\
      50:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">generate</span>( <span class=\"ruby-identifier\">uri</span>, <span class=\"ruby-identifier\">request</span> )\n\
      51:         <span class=\"ruby-identifier\">salt</span> = <span class=\"ruby-identifier\">uri</span>.<span class=\"ruby-identifier\">opaque</span> <span class=\"ruby-operator\">||</span> <span class=\"ruby-constant\">DEFAULT_SALT</span>\n\
      52:         <span class=\"ruby-identifier\">seed</span> = [\n\
      53:             <span class=\"ruby-identifier\">salt</span>,\n\
      54:             <span class=\"ruby-constant\">Time</span>.<span class=\"ruby-identifier\">new</span>.<span class=\"ruby-identifier\">to_s</span>,\n\
      55:             <span class=\"ruby-constant\">Object</span>.<span class=\"ruby-identifier\">new</span>.<span class=\"ruby-identifier\">inspect</span>,\n\
      56:             <span class=\"ruby-identifier\">rand</span>(),\n\
      57:             <span class=\"ruby-constant\">Process</span>.<span class=\"ruby-identifier\">pid</span>,\n\
      58:         ].<span class=\"ruby-identifier\">join</span>\n\
      59:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-constant\">Digest</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">SHA1</span>.<span class=\"ruby-identifier\">hexdigest</span>( <span class=\"ruby-constant\">Digest</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">SHA1</span>.<span class=\"ruby-identifier\">hexdigest</span>(<span class=\"ruby-identifier\">seed</span>) )\n\
      60:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Generate a new id
      </p>
    params: ( uri, request )
  - visibility: public
    aref: M000050
    name: validate
    sourcecode: "    <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/session/sha1id.rb, line 64</span>\n\
      64:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span><span class=\"ruby-operator\">::</span><span class=\"ruby-identifier\">validate</span>( <span class=\"ruby-identifier\">uri</span>, <span class=\"ruby-identifier\">idstr</span> )\n\
      65:         <span class=\"ruby-identifier\">rval</span> = <span class=\"ruby-identifier\">idstr</span>[<span class=\"ruby-regexp re\">/^([a-f0-9]{40})$/</span>]\n\
      66:         <span class=\"ruby-identifier\">rval</span>.<span class=\"ruby-identifier\">untaint</span>\n\
      67:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-identifier\">rval</span>\n\
      68:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Returns the validated id if the given id is in the expected form for this
      type, or <tt>nil</tt> if it is not.
      </p>
    params: ( uri, idstr )
  category: Class
  type: Public

sectitle

--- 

constants

--- 
- name: SVNRev
  desc: |+
    
    SVN Revision
    
  value: "%q$Rev: 406 $"
- name: SVNId
  desc: |+
    
    SVN <a href="Id.html">Id</a>
    
  value: "%q$Id: sha1id.rb 406 2007-07-18 17:01:59Z bbleything $"
- name: DEFAULT_SALT
  desc: |+
    
    Default salt characters
    
  value: "'sadblkw456jbhgsdfi7283hnehonaseegop26m'"

[Validate]

Generated with the Darkfish Rdoc Generator.