File Coverage

blib/lib/Authen/Passphrase/AcceptAll.pm
Criterion Covered Total %
statement 24 24 100.0
branch 2 2 100.0
condition n/a
subroutine 11 11 100.0
pod 5 5 100.0
total 42 42 100.0


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             Authen::Passphrase::AcceptAll - accept any passphrase
4              
5             =head1 SYNOPSIS
6              
7             use Authen::Passphrase::AcceptAll;
8              
9             $ppr = Authen::Passphrase::AcceptAll->new;
10              
11             $ppr = Authen::Passphrase::AcceptAll
12             ->from_crypt("");
13              
14             $ppr = Authen::Passphrase::AcceptAll
15             ->from_rfc2307("{CRYPT}");
16              
17             if($ppr->match($passphrase)) { ...
18              
19             $passphrase = $ppr->passphrase;
20              
21             $passwd = $ppr->as_crypt;
22             $userPassword = $ppr->as_rfc2307;
23              
24             =head1 DESCRIPTION
25              
26             An object of this class is a passphrase recogniser that accepts any
27             passphrase whatsoever. This is a subclass of L, and
28             this document assumes that the reader is familiar with the documentation
29             for that class.
30              
31             This type of passphrase recogniser is obviously of no use at all in
32             controlling access to any resource. Its use is to permit a resource to
33             be public in a system that expects some type of passphrase access control.
34              
35             =cut
36              
37             package Authen::Passphrase::AcceptAll;
38              
39 2     2   80761 { use 5.006; }
  2         7  
40 2     2   10 use warnings;
  2         6  
  2         117  
41 2     2   10 use strict;
  2         4  
  2         57  
42              
43 2     2   440 use Authen::Passphrase 0.003;
  2         39  
  2         62  
44 2     2   11 use Carp qw(croak);
  2         4  
  2         220  
45              
46             our $VERSION = "0.009";
47              
48 2     2   369 use parent "Authen::Passphrase";
  2         251  
  2         14  
49              
50             # There is only one object of this class, and its content is
51             # insignificant.
52              
53             =head1 CONSTRUCTORS
54              
55             =over
56              
57             =item Authen::Passphrase::AcceptAll->new
58              
59             Returns an accept-all passphrase recogniser object. The same object is
60             returned from each call.
61              
62             =cut
63              
64             {
65             my $singleton = bless({});
66 3     3 1 160660 sub new { $singleton }
67             }
68              
69             =item Authen::Passphrase::AcceptAll->from_crypt("")
70              
71             Returns an accept-all passphrase recogniser object. The same object is
72             returned from each call. The argument must be the empty string.
73              
74             =cut
75              
76             sub from_crypt {
77 4     4 1 980 my($class, $passwd) = @_;
78 4 100       12 return $class->new if $passwd eq "";
79 2         9 return $class->SUPER::from_crypt($passwd);
80             }
81              
82             =item Authen::Passphrase::AcceptAll->from_rfc2307(USERPASSWORD)
83              
84             Generates a new accept-all passphrase recogniser object from an RFC
85             2307 string. The string must consist of "B<{CRYPT}>" (case insensitive)
86             followed by an acceptable crypt string.
87              
88             =back
89              
90             =head1 METHODS
91              
92             =over
93              
94             =item $ppr->match(PASSPHRASE)
95              
96             =item $ppr->passphrase
97              
98             =item $ppr->as_crypt
99              
100             =item $ppr->as_rfc2307
101              
102             These methods are part of the standard L interface.
103             The L method always returns true, and the L method
104             returns the empty string (the shortest of the infinite number of correct
105             passphrases).
106              
107             =cut
108              
109 5     5 1 1256 sub match { 1 }
110              
111 1     1 1 167 sub passphrase { "" }
112              
113 2     2 1 8 sub as_crypt { "" }
114              
115             =back
116              
117             =head1 SEE ALSO
118              
119             L
120              
121             =head1 AUTHOR
122              
123             Andrew Main (Zefram)
124              
125             =head1 COPYRIGHT
126              
127             Copyright (C) 2006, 2007, 2009, 2010, 2012
128             Andrew Main (Zefram)
129              
130             =head1 LICENSE
131              
132             This module is free software; you can redistribute it and/or modify it
133             under the same terms as Perl itself.
134              
135             =cut
136              
137             1;