Authentication/Store.pm

filter: Statementstmt 100% 37 / 37 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 8 / 8 totaltotal 100% 55 / 55 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
fetch
1.0
CRAP 1.0
« Authentication/Driver/Dummy.pm ↑ Summary
1 package CGI::Application::Plugin::Authentication::Store;
2 23 $CGI::Application::Plugin::Authentication::Store::VERSION = '0.21';
3 23 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 23 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
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<CGI::Application::Plugin::Authentication>
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 ▶ my $self = shift;
Subroutine fetch: called CC=1 SCAR=0.0
Pod documented
56 1 my $class = ref $self;
57 1 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 ▶ my $self = shift;
Subroutine save: called CC=1 SCAR=0.0
Pod documented
68 1 my $class = ref $self;
69 1 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 ▶ my $self = shift;
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
80 1 my $class = ref $self;
81 1 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 ▶ my $self = shift;
Subroutine clear: called CC=1 SCAR=0.0
Pod documented
93 5 $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<CGI::Application::Plugin::Authentication::Store>
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 118 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
113 118 my $self = {};
114 118 my $authen = shift;
115 118 my @options = @_;
116  
117 118 bless $self, $class;
118 118 $self->{authen} = $authen;
119 118 Scalar::Util::weaken( $self->{authen} ); # weaken circular reference
120 118 $self->{options} = \@options;
121 118 $self->initialize;
122 117 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 9 ▶ my $self = shift;
Subroutine initialize: called CC=1 SCAR=0.0
Pod documented
134 # override this in the subclass if you need it
135 9 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 ▶ my $self = shift;
Subroutine options: called CC=1 SCAR=0.0
Pod documented
146 109 my @options = @{$self->{options}};
147 109 return @options[0..$#options];
148 }
149  
150 =head2 authen
151  
152 This will return the underlying L<CGI::Application::Plugin::Authentication> object. In most cases it will
153 not be necessary to access this.
154  
155 =cut
156  
157 sub authen {
158 90 ▶ my $self = shift;
Subroutine authen: called CC=1 SCAR=0.0
Pod documented
159 90 $self->{authen};
160 }
161  
162  
163 =head1 SEE ALSO
164  
165 L<CGI::Application::Plugin::Authentication::Store>, L<CGI::Application::Plugin::Authentication>, perl(1)
166  
167  
168 =head1 AUTHOR
169  
170 Cees Hek <ceeshek@gmail.com>
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 23 1;
« Authentication/Driver/Dummy.pm ↑ Summary