Credential/x509.pm

filter: Statementstmt 94.1% 48 / 51 Branchbran 50.0% 8 / 16 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 87.5% 7 / 8 Podpod n/a totaltotal 80.0% 64 / 80 CC 14 SCAR 24.3
CC
14
Cov
81%
__ANON__
17.6
__ANON__
2.0
__ANON__
2.0
CRAP 11.4
↑ Summary Credential.pm »
1 #+##############################################################################
2 # #
3 # File: Authen/Credential/x509.pm #
4 # #
5 # Description: abstraction of an X.509 credential #
6 # #
7 #-##############################################################################
8  
9 #
10 # module definition
11 #
12  
13 package Authen::Credential::x509;
14 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 our $VERSION = "1.2";
17 2 our $REVISION = sprintf("%d.%02d", q$Revision: 1.10 $ =~ /(\d+)\.(\d+)/);
18  
19 #
20 # inheritance
21 #
22  
23 2 our @ISA = qw(Authen::Credential);
24  
25 #
26 # used modules
27 #
28  
29 2 ▶use Authen::Credential qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
30 2 ▶use Params::Validate qw(validate_pos :types);
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 #
33 # Params::Validate specification
34 #
35  
36 $Authen::Credential::ValidationSpec{x509} = {
37 2 cert => { type => SCALAR, optional => 1 },
38 key => { type => SCALAR, optional => 1 },
39 ca => { type => SCALAR, optional => 1 },
40 ca_file => { type => SCALAR, optional => 1 },
41 pass => { type => SCALAR, optional => 1 },
42 };
43  
44 #
45 # accessors
46 #
47  
48 2 foreach my $name (qw(cert key ca ca_file pass)) {
49 2 ▶ no strict "refs";
Subroutine BEGIN: called CC=1 SCAR=0.0
50 10 ▶ *{ $name } = sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
51 5 my($self);
52 5 $self = shift(@_);
53 5 ▶ validate_pos(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 5 5
54 5 return($self->{$name});
55 10 };
56 }
57  
58 #
59 # preparators
60 #
61  
62 1 ▶$Authen::Credential::Preparator{x509}{"IO::Socket::SSL"} = sub {
Subroutine __ANON__: called CC=13 SCAR=28.7
63 1 my($self, %data);
64 1 $self = shift(@_);
65 1 ▶ validate_pos(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 1 1
66 1 foreach my $tmp ($self->cert(), $ENV{X509_USER_CERT}) {
67 1 ▶ next unless defined($tmp);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tmp 0 1 1
68 1 $data{SSL_cert_file} = $tmp;
69 1 last;
70 }
71 1 foreach my $tmp ($self->key(), $ENV{X509_USER_KEY}) {
72 1 ▶ next unless defined($tmp);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tmp 0 1 1
73 1 $data{SSL_key_file} = $tmp;
74 1 last;
75 }
76 1 foreach my $tmp ($self->ca(), $ENV{X509_CERT_DIR}) {
77 1 ▶ next unless defined($tmp);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tmp 0 1 1
78 1 $data{SSL_ca_path} = $tmp;
79 1 last;
80 }
81 1 foreach my $tmp ($self->ca_file(), $ENV{X509_CERT_FILE}) {
82 2 ▶ next unless defined($tmp);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tmp 2 0 2
83 0 $data{SSL_ca_file} = $tmp;
84 0 last;
85 }
86 0 ▶ $data{SSL_passwd_cb} = sub { return($self->pass()) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
87 1 ▶ if defined($self->pass());
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->pass 0 1 1
88 1 ▶ $data{SSL_use_cert} = 1 if $data{SSL_cert_file} and $data{SSL_key_file};
Branch: 1 branch
BranchTrueFalseTotal
if $data{"SSL_cert_file"} and $data{"SSL_key_file"} 1 0 1
Condition33%1/3
$data{"SSL_cert_file"} and $data{"SSL_key_file"}
!ll&&!rl&&r
001
MC/DC0%0/2
$data{"SSL_cert_file"} and $data{"SSL_key_file"}
$data{"SSL_cert_file"} $data{"SSL_key_file"}
Truth table33%1/3
A and B
A= $data{"SSL_cert_file"}B= $data{"SSL_key_file"}
ABresult
0X0
100
111
89 1 return(\%data);
90 2 };
91  
92 2 1;
93  
94 __DATA__
↑ Summary Credential.pm »