Passphrase/RejectAll.pm

filter: Statementstmt 100% 30 / 30 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 4 / 4 totaltotal 97.9% 47 / 48 CC 3 SCAR 4.1
CC
3
Cov
97%
from_crypt
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« Passphrase/Clear.pm ↑ Summary Passphrase/AcceptAll.pm »
1 =head1 NAME
2  
3 Authen::Passphrase::RejectAll - reject all passphrases
4  
5 =head1 SYNOPSIS
6  
7 use Authen::Passphrase::RejectAll;
8  
9 $ppr = Authen::Passphrase::RejectAll->new;
10  
11 $ppr = Authen::Passphrase::RejectAll
12 ->from_crypt("*");
13  
14 $ppr = Authen::Passphrase::RejectAll
15 ->from_rfc2307("{CRYPT}*");
16  
17 if($ppr->match($passphrase)) { ...
18  
19 $passwd = $ppr->as_crypt;
20 $userPassword = $ppr->as_rfc2307;
21  
22 =head1 DESCRIPTION
23  
24 An object of this class is a passphrase recogniser that accepts no
25 passphrase whatsoever. This is a subclass of L<Authen::Passphrase>, and
26 this document assumes that the reader is familiar with the documentation
27 for that class.
28  
29 This type of passphrase recogniser is obviously of no use at all in
30 controlling access to any resource. Its use is to permit a resource
31 to be completely inaccessible in a system that expects some type of
32 passphrase access control.
33  
34 =cut
35  
36 package Authen::Passphrase::RejectAll;
37  
38 2 ▶{ use 5.006; }
Subroutine BEGIN: called CC=1 SCAR=0.0
39 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
41  
42 2 ▶use Authen::Passphrase 0.003;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 2 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 2 our $VERSION = "0.009";
46  
47 2 ▶use parent "Authen::Passphrase";
Subroutine BEGIN: called CC=1 SCAR=0.0
48  
49 # There is only one object of this class, and its content is
50 # insignificant.
51  
52 =head1 CONSTRUCTORS
53  
54 =over
55  
56 =item Authen::Passphrase::RejectAll->new
57  
58 Returns a reject-all passphrase recogniser object. The same object is
59 returned from each call.
60  
61 =cut
62  
63 {
64 2 my $singleton = bless({});
65 3 ▶ sub new { $singleton }
Subroutine new: called CC=1 SCAR=0.0
Pod documented
66 }
67  
68 =item Authen::Passphrase::RejectAll->from_crypt(PASSWD)
69  
70 Returns a reject-all passphrase recogniser object. The same object is
71 returned from each call. The argument, a crypt string, must be between
72 one and twelve (inclusive) characters long and must not start with "B<$>".
73  
74 =cut
75  
76 2 ▶sub from_crypt {
Subroutine from_crypt: called CC=3 SCAR=11.0
Pod documented
77 4 my($class, $passwd) = @_;
78 4 ▶ if($passwd =~ /\A[^\$].{0,11}\z/s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($passwd =~ /\A[^\$].{0,11}\z/s) 2 2 4
79 2 ▶ $passwd =~ /\A[!-#\%-9;-~][!-9;-~]{0,11}\z/
Branch: 1 branch
BranchTrueFalseTotal
$passwd =~ /\A[!-#\%-9;-~][!-9;-~]{0,11}\z/ or croak("malformed reject-all crypt data") 2 0 2
80 or croak "malformed reject-all crypt data";
81 2 return $class->new;
82 }
83 2 return $class->SUPER::from_crypt($passwd);
84 }
85  
86 =item Authen::Passphrase::RejectAll->from_rfc2307(USERPASSWORD)
87  
88 Generates a new reject-all passphrase recogniser object from an RFC
89 2307 string. The string must consist of "B<{CRYPT}>" (case insensitive)
90 followed by an acceptable crypt string.
91  
92 =back
93  
94 =head1 METHODS
95  
96 =over
97  
98 =item $ppr->match(PASSPHRASE)
99  
100 =item $ppr->as_crypt
101  
102 =item $ppr->as_rfc2307
103  
104 These methods are part of the standard L<Authen::Passphrase> interface.
105 The L</match> method always returns false.
106  
107 =cut
108  
109 5 ▶sub match { 0 }
Subroutine match: called CC=1 SCAR=0.0
Pod documented
110  
111 2 ▶sub as_crypt { "*" }
Subroutine as_crypt: called CC=1 SCAR=0.0
Pod documented
112  
113 =back
114  
115 =head1 SEE ALSO
116  
117 L<Authen::Passphrase>
118  
119 =head1 AUTHOR
120  
121 Andrew Main (Zefram) <zefram@fysh.org>
122  
123 =head1 COPYRIGHT
124  
125 Copyright (C) 2006, 2007, 2009, 2010, 2012
126 Andrew Main (Zefram) <zefram@fysh.org>
127  
128 =head1 LICENSE
129  
130 This module is free software; you can redistribute it and/or modify it
131 under the same terms as Perl itself.
132  
133 =cut
134  
135 2 1;
« Passphrase/Clear.pm ↑ Summary Passphrase/AcceptAll.pm »