line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Application::Plugin::Authentication::Store; |
2
|
|
|
|
|
|
|
$CGI::Application::Plugin::Authentication::Store::VERSION = '0.21'; |
3
|
23
|
|
|
23
|
|
6654
|
use strict; |
|
23
|
|
|
|
|
47
|
|
|
23
|
|
|
|
|
632
|
|
4
|
23
|
|
|
23
|
|
83
|
use warnings; |
|
23
|
|
|
|
|
28
|
|
|
23
|
|
|
|
|
7944
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
CGI::Application::Plugin::Authentication::Store - Base module for building storage classes |
9
|
|
|
|
|
|
|
for the CGI::Application::Plugin::Authentication plugin |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package CGI::Application::Plugin::Authentication::Store::MyStore; |
14
|
|
|
|
|
|
|
use base qw(CGI::Application::Plugin::Authentication::Store); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub fetch { |
17
|
|
|
|
|
|
|
my $self = shift; |
18
|
|
|
|
|
|
|
my @params = @_; |
19
|
|
|
|
|
|
|
... |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub save { |
23
|
|
|
|
|
|
|
my $self = shift; |
24
|
|
|
|
|
|
|
my %params = @_; |
25
|
|
|
|
|
|
|
... |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub delete { |
29
|
|
|
|
|
|
|
my $self = shift; |
30
|
|
|
|
|
|
|
my @params = @_; |
31
|
|
|
|
|
|
|
... |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 DESCRIPTION |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
This module is a base class for all storage classes for the L |
37
|
|
|
|
|
|
|
plugin. Each storage class is required to provide three methods that fetch, save and delete data from |
38
|
|
|
|
|
|
|
the store. The information that is saved will be text based, so there is no need to flatten any of the |
39
|
|
|
|
|
|
|
data that is to be stored. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 METHODS TO OVERRIDE |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
The following three (and one optional) methods should be provided by the subclass. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 fetch |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
This method accepts a list of parameters and will return a list of values from the store |
50
|
|
|
|
|
|
|
matching those parameters. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub fetch { |
55
|
1
|
|
|
1
|
1
|
54
|
my $self = shift; |
56
|
1
|
|
|
|
|
2
|
my $class = ref $self; |
57
|
1
|
|
|
|
|
9
|
die "fetch must be implemented in the $class subclass"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 save |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This method accepts a hash of parameters and values and will save those parameters in the store. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub save { |
67
|
1
|
|
|
1
|
1
|
324
|
my $self = shift; |
68
|
1
|
|
|
|
|
2
|
my $class = ref $self; |
69
|
1
|
|
|
|
|
9
|
die "save must be implemented in the $class subclass"; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 delete |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This method accepts a list of parameters and will delete those parameters from the store. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub delete { |
79
|
1
|
|
|
1
|
1
|
320
|
my $self = shift; |
80
|
1
|
|
|
|
|
2
|
my $class = ref $self; |
81
|
1
|
|
|
|
|
9
|
die "delete must be implemented in the $class subclass"; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 clear |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
A call to this method will remove all information about the current user out of the store (should |
87
|
|
|
|
|
|
|
be provided by the subclass, but is not required to be). |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub clear { |
92
|
5
|
|
|
5
|
1
|
9
|
my $self = shift; |
93
|
5
|
|
|
|
|
16
|
$self->delete('username', 'login_attempts', 'last_access', 'last_login'); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 OTHER METHODS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
The following methods are also provided by the L |
100
|
|
|
|
|
|
|
base class. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 new |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This is a constructor that can create a new Store object. It requires an Authentication object as its |
105
|
|
|
|
|
|
|
first parameter, and any number of other parameters that will be used as options depending on which |
106
|
|
|
|
|
|
|
Store object is being created. You shouldn't need to call this as the Authentication plugin takes care |
107
|
|
|
|
|
|
|
of creating Store objects. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub new { |
112
|
115
|
|
|
115
|
1
|
167
|
my $class = shift; |
113
|
115
|
|
|
|
|
167
|
my $self = {}; |
114
|
115
|
|
|
|
|
150
|
my $authen = shift; |
115
|
115
|
|
|
|
|
222
|
my @options = @_; |
116
|
|
|
|
|
|
|
|
117
|
115
|
|
|
|
|
169
|
bless $self, $class; |
118
|
115
|
|
|
|
|
335
|
$self->{authen} = $authen; |
119
|
115
|
|
|
|
|
342
|
Scalar::Util::weaken( $self->{authen} ); # weaken circular reference |
120
|
115
|
|
|
|
|
262
|
$self->{options} = \@options; |
121
|
115
|
|
|
|
|
345
|
$self->initialize; |
122
|
114
|
|
|
|
|
619
|
return $self; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 initialize |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This method will be called right after a new Store object is created. So any startup customizations |
128
|
|
|
|
|
|
|
can be dealt with here. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub initialize { |
133
|
6
|
|
|
6
|
1
|
7
|
my $self = shift; |
134
|
|
|
|
|
|
|
# override this in the subclass if you need it |
135
|
6
|
|
|
|
|
6
|
return; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 options |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This will return a list of options that were provided when this store was configured by the user. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub options { |
145
|
109
|
|
|
109
|
1
|
258
|
my $self = shift; |
146
|
109
|
|
|
|
|
104
|
my @options = @{$self->{options}}; |
|
109
|
|
|
|
|
243
|
|
147
|
109
|
|
|
|
|
430
|
return @options[0..$#options]; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 authen |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This will return the underlying L object. In most cases it will |
153
|
|
|
|
|
|
|
not be necessary to access this. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub authen { |
158
|
70
|
|
|
70
|
1
|
79
|
my $self = shift; |
159
|
70
|
|
|
|
|
194
|
$self->{authen}; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 SEE ALSO |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
L, L, perl(1) |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 AUTHOR |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Cees Hek |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 LICENCE AND COPYRIGHT |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Copyright (c) 2005, SiteSuite. All rights reserved. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTY |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=cut |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
1; |