File Coverage

blib/lib/CGI/Application/Plugin/Authentication/Store.pm
Criterion Covered Total %
statement 35 35 100.0
branch n/a
condition n/a
subroutine 10 10 100.0
pod 8 8 100.0
total 53 53 100.0


line stmt bran cond sub pod time code
1             package CGI::Application::Plugin::Authentication::Store;
2              
3 26     26   13893 use strict;
  26         185  
  26         1143  
4 26     26   139 use warnings;
  26         98  
  26         11988  
5             our $VERSION = '0.20';
6              
7             =head1 NAME
8              
9             CGI::Application::Plugin::Authentication::Store - Base module for building storage classes
10             for the CGI::Application::Plugin::Authentication plugin
11              
12             =head1 VERSION
13              
14             This document describes CGI::Application::Plugin::Authentication::Store version 0.20
15              
16             =head1 SYNOPSIS
17              
18             package CGI::Application::Plugin::Authentication::Store::MyStore;
19             use base qw(CGI::Application::Plugin::Authentication::Store);
20              
21             sub fetch {
22             my $self = shift;
23             my @params = @_;
24             ...
25             }
26              
27             sub save {
28             my $self = shift;
29             my %params = @_;
30             ...
31             }
32              
33             sub delete {
34             my $self = shift;
35             my @params = @_;
36             ...
37             }
38              
39             =head1 DESCRIPTION
40              
41             This module is a base class for all storage classes for the L
42             plugin. Each storage class is required to provide three methods that fetch, save and delete data from
43             the store. The information that is saved will be text based, so there is no need to flatten any of the
44             data that is to be stored.
45              
46              
47             =head1 METHODS TO OVERRIDE
48              
49             The following three (and one optional) methods should be provided by the subclass.
50              
51              
52             =head2 fetch
53              
54             This method accepts a list of parameters and will return a list of values from the store
55             matching those parameters.
56              
57             =cut
58              
59             sub fetch {
60 1     1 1 61 my $self = shift;
61 1         3 my $class = ref $self;
62 1         11 die "fetch must be implemented in the $class subclass";
63             }
64              
65             =head2 save
66              
67             This method accepts a hash of parameters and values and will save those parameters in the store.
68              
69             =cut
70              
71             sub save {
72 1     1 1 6969 my $self = shift;
73 1         5 my $class = ref $self;
74 1         23 die "save must be implemented in the $class subclass";
75             }
76              
77             =head2 delete
78              
79             This method accepts a list of parameters and will delete those parameters from the store.
80              
81             =cut
82              
83             sub delete {
84 1     1 1 1965 my $self = shift;
85 1         3 my $class = ref $self;
86 1         12 die "delete must be implemented in the $class subclass";
87             }
88              
89             =head2 clear
90              
91             A call to this method will remove all information about the current user out of the store (should
92             be provided by the subclass, but is not required to be).
93              
94             =cut
95              
96             sub clear {
97 5     5 1 9 my $self = shift;
98 5         26 $self->delete('username', 'login_attempts', 'last_access', 'last_login');
99             }
100              
101              
102             =head1 OTHER METHODS
103              
104             The following methods are also provided by the L
105             base class.
106              
107             =head2 new
108              
109             This is a constructor that can create a new Store object. It requires an Authentication object as its
110             first parameter, and any number of other parameters that will be used as options depending on which
111             Store object is being created. You shouldn't need to call this as the Authentication plugin takes care
112             of creating Store objects.
113              
114             =cut
115              
116             sub new {
117 164     164 1 406 my $class = shift;
118 164         407 my $self = {};
119 164         698 my $authen = shift;
120 164         490 my @options = @_;
121              
122 164         595 bless $self, $class;
123 164         753 $self->{authen} = $authen;
124 164         757 Scalar::Util::weaken( $self->{authen} ); # weaken circular reference
125 164         590 $self->{options} = \@options;
126 164         888 $self->initialize;
127 163         10917 return $self;
128             }
129              
130             =head2 initialize
131              
132             This method will be called right after a new Store object is created. So any startup customizations
133             can be dealt with here.
134              
135             =cut
136              
137             sub initialize {
138 6     6 1 14 my $self = shift;
139             # override this in the subclass if you need it
140 6         13 return;
141             }
142              
143             =head2 options
144              
145             This will return a list of options that were provided when this store was configured by the user.
146              
147             =cut
148              
149             sub options {
150 158     158 1 821 my $self = shift;
151 158         275 my @options = @{$self->{options}};
  158         514  
152 158         1169 return @options[0..$#options];
153             }
154              
155             =head2 authen
156              
157             This will return the underlying L object. In most cases it will
158             not be necessary to access this.
159              
160             =cut
161              
162             sub authen {
163 71     71 1 112 my $self = shift;
164 71         333 $self->{authen};
165             }
166              
167              
168             =head1 SEE ALSO
169              
170             L, L, perl(1)
171              
172              
173             =head1 AUTHOR
174              
175             Cees Hek
176              
177              
178             =head1 LICENCE AND COPYRIGHT
179              
180             Copyright (c) 2005, SiteSuite. All rights reserved.
181              
182             This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
183              
184              
185             =head1 DISCLAIMER OF WARRANTY
186              
187             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.
188              
189             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.
190              
191             =cut
192              
193             1;