« blib/lib/CGI/Session/Authenticator/Backdoor.pm
↑ Summary
Session/blib/lib/CGI/Session/Authenticator/LDAP.pm »
| 1 | #!/usr/local/bin/perl5 | ||
| 2 | # | ||
| 3 | |||
| 4 | package CGI::Session::CookieJar; | ||
| 5 | |||
| 6 | 2 | ▶ | use Carp; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | =item CGI::Session::CookieJar | ||
| 9 | |||
| 10 | An abstract data store for cookies. | ||
| 11 | |||
| 12 | The general usage is as follows: | ||
| 13 | |||
| 14 | my $cookiejar; | ||
| 15 | $cookiejar = new CGI::Session::CookieJar::YOUR_JAR_HERE( PARAMETERS ); | ||
| 16 | $cookiejar->open(); | ||
| 17 | ... | ||
| 18 | ... cookie operations | ||
| 19 | ... | ||
| 20 | $cookiejar->close(); | ||
| 21 | |||
| 22 | |||
| 23 | Most functions manipulating cookies use "queries" to specify the | ||
| 24 | cookies which will be operated upon. These queries are references to | ||
| 25 | associative arrays. The keys indicate variables which will be | ||
| 26 | compared, and the values specify the query operations. These | ||
| 27 | intersection of all the results determines which ones will be | ||
| 28 | selected. | ||
| 29 | |||
| 30 | Here are examples of simple queries: | ||
| 31 | |||
| 32 | { user => "bob" } selects all cookies with the user value of "bob" | ||
| 33 | |||
| 34 | { expiration => "<".time() } selects all cookies which have already | ||
| 35 | expired | ||
| 36 | |||
| 37 | { expiration => ">".time() } selects all cookies which have not | ||
| 38 | expired | ||
| 39 | |||
| 40 | { cookie_name => "$cookie" } selects all cookies which are named $cookie | ||
| 41 | |||
| 42 | { passkey => "435765" } selects all cookies which have the passkey value | ||
| 43 | of "435765" | ||
| 44 | |||
| 45 | |||
| 46 | { user => "bob", passkey => "6578" } selects all cookies which have the user | ||
| 47 | "bob" and the passkey set to "6578" | ||
| 48 | |||
| 49 | There is no way to select a union of search results. | ||
| 50 | |||
| 51 | =cut | ||
| 52 | |||
| 53 | =item CGI::Session::CookieJar::open | ||
| 54 | |||
| 55 | $cookiejar->open(); | ||
| 56 | |||
| 57 | Opens up the cookie jar. This must be called before any operations | ||
| 58 | can take place. When you are through with the cookie jar the close | ||
| 59 | operation me be called. | ||
| 60 | |||
| 61 | =cut | ||
| 62 | |||
| 63 | 0 | ▶ | sub open { my $p=__PACKAGE__; croak "The $p::open operation must be defined."; } |
|
Subroutine
open: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 64 | |||
| 65 | |||
| 66 | =item CGI::Session::CookieJar::close | ||
| 67 | |||
| 68 | $cookiejar->close; | ||
| 69 | |||
| 70 | Closes a previously opened cookie jar. This must be done before your program ends. | ||
| 71 | |||
| 72 | =cut | ||
| 73 | |||
| 74 | 0 | ▶ | sub close { my $p = __PACKAGE__; croak "The method $p::close must be defined."; } |
|
Subroutine
close: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 75 | |||
| 76 | |||
| 77 | =item CGI::Session::CookieJar::contains | ||
| 78 | |||
| 79 | Determines if a session contains a given cookie. | ||
| 80 | |||
| 81 | my $time = time; | ||
| 82 | my %query = ( user=>'bob', | ||
| 83 | cookie_name=>'3476dfgh', | ||
| 84 | passkey=>'23438', | ||
| 85 | expiration=>'>$time' ); | ||
| 86 | |||
| 87 | my $has_cookie = $cookie_jar->contains( -query => \$query ); | ||
| 88 | |||
| 89 | =cut | ||
| 90 | |||
| 91 | 0 | ▶ | sub contains { my $p=__PACKAGE__; croak "$p::contains is not implemented, but it must be."; }; |
|
Subroutine
contains: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 92 | |||
| 93 | |||
| 94 | |||
| 95 | |||
| 96 | =item CGI::Session::CookieJar::cookie | ||
| 97 | |||
| 98 | Retreives a cookie from the cookie jar using a specified query. If no | ||
| 99 | cookie is found then it returns 'undef'. | ||
| 100 | |||
| 101 | By default all cookie fields are returned as an array of hashes . If | ||
| 102 | your application potentially contains large 'server_side_data' fields | ||
| 103 | this may not be what you want. In this case cases you can specify | ||
| 104 | that the server_side_data field will not be returned by setting the | ||
| 105 | -omit_server_side_data option to a true value. | ||
| 106 | |||
| 107 | my $time = time; | ||
| 108 | my %query = ( user=>'bob', | ||
| 109 | cookie_name=>'3476dfgh', | ||
| 110 | passkey=>'23438', | ||
| 111 | expiration=>">$time" ); | ||
| 112 | |||
| 113 | my $cookie = $cookie_jar->cookie( -query => \%query ); | ||
| 114 | |||
| 115 | if ( !defined $cookie ) { croak "There is no such cookie."; } | ||
| 116 | |||
| 117 | ...or... | ||
| 118 | |||
| 119 | my @sessions = $cookie_jar->session( -query => \%query, | ||
| 120 | -omit_server_side_data=>1 ); | ||
| 121 | |||
| 122 | =cut | ||
| 123 | |||
| 124 | 0 | ▶ | sub session { my $p=__PACKAGE__; croak "$p::session is not implemented, but it must be."; }; |
|
Subroutine
session: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 125 | |||
| 126 | |||
| 127 | |||
| 128 | =item CGI::Session::CookieJar::delete | ||
| 129 | |||
| 130 | Deletes the specified cookies from the cookie jar. | ||
| 131 | |||
| 132 | my $time = time; | ||
| 133 | my %query = ( expiration=>'<$time' ); | ||
| 134 | $cookie_jar->delete( -query => \$query ); | ||
| 135 | |||
| 136 | =cut | ||
| 137 | |||
| 138 | 0 | ▶ | sub delete { my $p=__PACKAGE__; croak "$p::delete is not implemented, but it must be."; }; |
|
Subroutine
delete: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 139 | |||
| 140 | |||
| 141 | |||
| 142 | |||
| 143 | =item CGI::Session::CookieJar::set_session | ||
| 144 | |||
| 145 | Sets the session variables for a previously created user entry. The | ||
| 146 | user entry must already exist. If it does not exist then it must | ||
| 147 | be created with CGI::Session::CookieJar::register_user. | ||
| 148 | |||
| 149 | The 'user' field is required for the c | ||
| 150 | |||
| 151 | my $time = time; | ||
| 152 | my %session = ( user=>'bob', | ||
| 153 | cookie_name=>'3476dfgh', | ||
| 154 | passkey=>'23438', | ||
| 155 | expiration=>'$time', | ||
| 156 | server_data=>$data ); | ||
| 157 | |||
| 158 | my $cookie_jar->set_session( -session => \%session ); | ||
| 159 | |||
| 160 | =cut | ||
| 161 | |||
| 162 | 0 | ▶ | sub set_session { my $p=__PACKAGE__; croak "$p::set_session is not implemented, but it must be."; }; |
|
Subroutine
set_session: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 163 | |||
| 164 | |||
| 165 | |||
| 166 | =item CGI::Session::CookieJar::register_user | ||
| 167 | |||
| 168 | Creates an entry for the specified user within the cookie jar. Attempting | ||
| 169 | to register a user which does not exist will result in an error. | ||
| 170 | |||
| 171 | if ( ! $cookie_jar->contains( -user=>$username ) ) | ||
| 172 | { | ||
| 173 | $cookie_jar->register_user( $username ); | ||
| 174 | } | ||
| 175 | |||
| 176 | =cut | ||
| 177 | |||
| 178 | |||
| 179 | =item CGI::Session::CookieJar::version | ||
| 180 | |||
| 181 | Returns the version of CGI::Session that was used to create this | ||
| 182 | data store. | ||
| 183 | |||
| 184 | my $version => $cookie_jar->version(); | ||
| 185 | |||
| 186 | =cut | ||
| 187 | |||
| 188 | 0 | ▶ | sub version { my $p=__PACKAGE__; croak "$p::version is not implemented, but it must be."; }; |
|
Subroutine
version: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 189 | |||
| 190 | |||
| 191 | =item CGI::Session::CookieJar::create_cookie_jar | ||
| 192 | |||
| 193 | Creates a new cookie jar. For a database cookie jar this would create | ||
| 194 | the necessary tables. For a file based cookie jar this might set up | ||
| 195 | the required directory structure. | ||
| 196 | |||
| 197 | This should only be necessary once. | ||
| 198 | |||
| 199 | $cookie_jar->create_cookie_jar(); | ||
| 200 | |||
| 201 | =cut | ||
| 202 | |||
| 203 | 0 | ▶ | sub create_cookie_jar { my $p=__PACKAGE__; croak "$p::create_cookie_jar is not implemented, but it must be."; }; |
|
Subroutine
create_cookie_jar: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 204 | |||
| 205 | |||
| 206 | =item CGI::Session::CookieJar::destroy_cookie_jar | ||
| 207 | |||
| 208 | Destroys an existing cookie jar. For a database cookie jar this would | ||
| 209 | drop all of the tables. For a file based cookie jar this might | ||
| 210 | delete all the existing files and directories. | ||
| 211 | |||
| 212 | This should only be necessary once. | ||
| 213 | |||
| 214 | $cookie_jar->destroy_cookie_jar(); | ||
| 215 | |||
| 216 | =cut | ||
| 217 | |||
| 218 | 0 | ▶ | sub destroy_cookie_jar { my $p=__PACKAGE__; croak "$p::destroy_cookie_jar is not implemented, but it must be."; }; |
|
Subroutine
destroy_cookie_jar: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 219 | |||
| 220 | |||
| 221 | |||
| 222 | |||
| 223 | =item CGI::Session::CookieJar::error | ||
| 224 | |||
| 225 | If the previous cookie operation resulted in an error then | ||
| 226 | the value of this error will be found here. If the operation | ||
| 227 | did not result in an error then this will return 'undef'. | ||
| 228 | |||
| 229 | Calling error() does not alter the value. Each cookie jar object has | ||
| 230 | it's own error state, which is independent of the backend database. | ||
| 231 | |||
| 232 | my $error = $cookie_jar->error(); | ||
| 233 | |||
| 234 | =cut | ||
| 235 | |||
| 236 | 0 | ▶ | sub error { my $p=__PACKAGE__; croak "$p::error is not implemented, but it must be."; }; |
|
Subroutine
error: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 237 | |||
| 238 | |||
| 239 | |||
| 240 | 2 | 1; | |
| 241 | |||
| 242 | |||
| 243 | |||
| 244 | |||
| 245 | |||
| 246 | |||
| 247 | |||
| 248 | |||
| 249 | |||
| 250 | |||
| 251 | |||
| 252 | |||
| 253 | |||
| 254 | |||
| 255 | |||