File Coverage

blib/lib/Authen/Passphrase/AcceptAll.pm
Criterion Covered Total %
statement 25 25 100.0
branch 2 2 100.0
condition n/a
subroutine 11 11 100.0
pod 5 5 100.0
total 43 43 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 1     1   52942 { use 5.006; }
  1         4  
  1         159  
40 1     1   24 use warnings;
  1         12  
  1         61  
41 1     1   6 use strict;
  1         13  
  1         37  
42              
43 1     1   2950 use Authen::Passphrase 0.003;
  1         173  
  1         121  
44 1     1   14 use Carp qw(croak);
  1         2  
  1         132  
45              
46             our $VERSION = "0.008";
47              
48 1     1   1634 use parent "Authen::Passphrase";
  1         1060  
  1         9  
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 23 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 2301 my($class, $passwd) = @_;
78 4 100       26 return $class->new if $passwd eq "";
79 2         26 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 2666 sub match { 1 }
110              
111 1     1 1 420 sub passphrase { "" }
112              
113 2     2 1 12 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;