Session/blib/lib/CGI/Session/Authorizor/Allowed_User_File.pm

filter: Statementstmt 12.5% 5 / 40 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 12.5% 1 / 8 Podpod 0.0% 0 / 6 totaltotal 8.5% 6 / 70 CC 9 SCAR 29.7
CC
9
Cov
9%
_param
30.0
authorized
30.0
set
2.0
CRAP 19.4
« blib/lib/CGI/Session/Authenticator/NetLDAP.pm ↑ Summary blib/lib/CGI/Session/Authorizor/LDAP.pm »
1 #!/usr/local/bin/perl5
2 #
3  
4 package CGI::Session::Authorizor::Allowed_User_File;
5  
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 my %_params = ( -file => '-file' );
9  
10 sub _param
11 0 ▶ {
Subroutine _param: not called CC=5 SCAR=34.0
12 0 my $self = shift;
13 0 ▶ if ( scalar @_ == 1 )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ == 1) { } 0 0 0
14 {
15 0 my $field = shift;
16  
17 #
18 0 my $slot = $_params{$field};
19 0 ▶ croak "Programmer Error: $field is not a known parameter" unless defined $slot;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $slot 0 0 0
20 0 return $self->{$slot};
21 }
22 else
23 {
24 0 ▶ while( my $field = shift )
Branch: 1 branch
BranchTrueFalseTotal
if (my $field = shift()) 0 0 0
25 {
26 0 my $slot = $_params{$field};
27  
28 #
29 0 ▶ croak "Programmer Error: $field is not a known parameter" unless defined $slot;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $slot 0 0 0
30 0 $self->{$slot} = shift;
31 }
32 }
33 }
34  
35 0 ▶sub set { _param(shift,@_); }
Subroutine set: not called CC=1 SCAR=6.9
Pod undocumented
36  
37 sub new
38 0 ▶ {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
39 0 my $type = shift;
40 0 my $self = {};
41 0 bless $self, $type;
42 0 $self->set( @_ );
43 0 return $self;
44 }
45  
46 0 ▶sub file { set( shift(), '-file', @_ ); }
Subroutine file: not called CC=1 SCAR=6.9
Pod undocumented
47 0 ▶sub port { set( shift(), '-port', @_ ); }
Subroutine port: not called CC=1 SCAR=6.9
Pod undocumented
48 0 ▶sub bind { set( shift(), '-bind', @_ ); }
Subroutine bind: not called CC=1 SCAR=6.9
Pod undocumented
49  
50 # Check restricted access file if the restricted access
51 # switch has been set.
52 #
53 sub authorized
54 0 ▶ {
Subroutine authorized: not called CC=5 SCAR=34.0
Pod undocumented
55 0 my ( $self, $params ) = @_;
56 0 my $username = $params->{-username};
57 0 my $found_flag = 0;
58  
59 0 my $result = CORE::open(RA_FD, $self->file);
60 0 ▶ if(!defined($result))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $result) { } 0 0 0
61 {
62 0 carp "Could not open allowed access file\n";
63 0 return 0;
64 }
65 else
66 {
67 0 ▶ while(my $line = <RA_FD>)
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline RA_FD)) 0 0 0
68 {
69 0 chomp $line;
70 0 ▶ if($line eq $username) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line eq $username) 0 0 0
71 0 $found_flag++;
72 0 last;
73 }
74 }
75 }
76 0 ▶ if(!$found_flag)
Branch: 1 branch
BranchTrueFalseTotal
unless ($found_flag) 0 0 0
77 {
78 0 close(RA_FD);
79 0 return 0;
80 }
81 0 return 1;
82 }
83  
84  
85  
86 =item CGI::Session::Authenticator::LDAP
87  
88 An LDAP authenticator. Use Mozilla::LDAP.
89  
90 $auth = new CGI::Session::Authenticator( -host => $host,
91 -port => $port,
92 -bind => 'uid=$username,ou=People,dc=mycorp,dc=com' );
93  
94 if ( $auth->authenticated( $param ) ) { ...success... }
95 else { ...failure... }
96  
97 =item CGI::Session::Authenticator::authenticated
98  
99 It accepts on argument which is a reference to a hash. This hash contains
100 variables which are used to attempt authentication.
101  
102 The standard values which are used for comparison. The basic ones are
103 '-username' and '-password'.
104  
105 It returns a true value if the user was successfully authenticated, and a
106 false value if the user was not successfully authenticated.
107  
108 =cut
109  
110  
111 1 1;
« blib/lib/CGI/Session/Authenticator/NetLDAP.pm ↑ Summary blib/lib/CGI/Session/Authorizor/LDAP.pm »