Class: Ronin::Web::SessionCookie::Cookie
- Inherits:
-
Object
- Object
- Ronin::Web::SessionCookie::Cookie
- Includes:
- Enumerable
- Defined in:
- lib/ronin/web/session_cookie/cookie.rb
Overview
Base class for all session cookie classes.
Constant Summary collapse
- STRICT_BASE64_REGEXP =
Regular expression for a URI decoded Base64 blob.
%r{(?:[A-Za-z0-9+/]{4})+(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?|[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=}
- URI_ENCODED_BASE64_REGEXP =
Regular expression for a URI escaped Base64 blob.
%r{(?:[A-Za-z0-9+/]{4})+(?:[A-Za-z0-9+/]{2}%3D%3D|[A-Za-z0-9+/]{3}%3D)?|[A-Za-z0-9+/]{2}%3D|[A-Za-z0-9+/]{3}%3D}
- URL_SAFE_BASE64_REGEXP =
Regular expression for a URL-safe encoded Base64 blob.
/[A-Za-z0-9_-]{2,}/
Instance Attribute Summary collapse
-
#params ⇒ Hash
readonly
The cookie params.
Class Method Summary collapse
-
.extract(response) ⇒ Cookie?
abstract
Extracts and parses the session cookie from an HTTP response.
-
.identify?(string) ⇒ Boolean
abstract
Determines if the given string is a valid session cookie.
-
.parse(string) ⇒ Cookie
abstract
Parses a session cookie value.
Instance Method Summary collapse
-
#[](key) ⇒ Object?
Returns the value for the given session cookie param.
-
#each {|key, value| ... } ⇒ Enumerator
Enumerates over the params within the session cookie.
-
#has_key?(params) ⇒ Boolean
Determines if the session cookie contains the given param.
-
#initialize(params) ⇒ Cookie
constructor
private
Initializes the session cookie.
-
#to_h ⇒ Hash
Converts the session cookie into a Hash.
Constructor Details
#initialize(params) ⇒ Cookie
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the session cookie.
51 52 53 |
# File 'lib/ronin/web/session_cookie/cookie.rb', line 51 def initialize(params) @params = params end |
Instance Attribute Details
#params ⇒ Hash (readonly)
The cookie params.
41 42 43 |
# File 'lib/ronin/web/session_cookie/cookie.rb', line 41 def params @params end |
Class Method Details
.extract(response) ⇒ Cookie?
Extracts and parses the session cookie from an HTTP response.
99 100 101 |
# File 'lib/ronin/web/session_cookie/cookie.rb', line 99 def self.extract(response) raise(NotImplementedError,"#{self}.extract was not implemented") end |
.identify?(string) ⇒ Boolean
Determines if the given string is a valid session cookie.
66 67 68 |
# File 'lib/ronin/web/session_cookie/cookie.rb', line 66 def self.identify?(string) raise(NotImplementedError,"#{self}.identify? was not implemented") end |
.parse(string) ⇒ Cookie
Parses a session cookie value.
81 82 83 |
# File 'lib/ronin/web/session_cookie/cookie.rb', line 81 def self.parse(string) raise(NotImplementedError,"#{self}.parse was not implemented") end |
Instance Method Details
#[](key) ⇒ Object?
Returns the value for the given session cookie param.
125 126 127 |
# File 'lib/ronin/web/session_cookie/cookie.rb', line 125 def [](key) @params[key] end |
#each {|key, value| ... } ⇒ Enumerator
Enumerates over the params within the session cookie.
142 143 144 |
# File 'lib/ronin/web/session_cookie/cookie.rb', line 142 def each(&block) @params.each(&block) end |
#has_key?(params) ⇒ Boolean
Determines if the session cookie contains the given param.
112 113 114 |
# File 'lib/ronin/web/session_cookie/cookie.rb', line 112 def has_key?(params) @params.has_key?(params) end |
#to_h ⇒ Hash
Converts the session cookie into a Hash.
153 154 155 |
# File 'lib/ronin/web/session_cookie/cookie.rb', line 153 def to_h @params end |