blib/lib/CGI/Application/Plugin/Authentication/Store.pm

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