| 1 | package Apache::Session::Browseable::Store::LDAP; | ||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Net::LDAP; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = '1.3.8'; | |||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||
| 8 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 9 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||
| 10 | 0 | return bless {}, $class; | |||||||||||||||||||||||||||||||||||||||
| 11 | } | ||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub insert { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 15 | 0 | my $session = shift; | |||||||||||||||||||||||||||||||||||||||
| 16 | 0 | $self->{args} = $session->{args}; | |||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapObjectClass"} ||= "applicationProcess"
MC/DC0%0/1
$self->{"args"}{"ldapObjectClass"} ||= "applicationProcess"
$self->{"args"}{"ldapObjectClass"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapObjectClass"}
| |||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | $self->{args}->{ldapAttributeId} ||= 'cn'; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeId"} ||= "cn"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeId"} ||= "cn"
$self->{"args"}{"ldapAttributeId"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeId"}
| |||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | $self->{args}->{ldapAttributeContent} ||= 'description'; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeContent"} ||= "description"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeContent"} ||= "description"
$self->{"args"}{"ldapAttributeContent"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeContent"}
| |||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | $self->{args}->{ldapAttributeIndex} ||= 'ou'; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeIndex"} ||= "ou"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeIndex"} ||= "ou"
$self->{"args"}{"ldapAttributeIndex"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeIndex"}
| |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||
| 22 | my $index = | ||||||||||||||||||||||||||||||||||||||||
| 23 | ref( $session->{args}->{Index} ) | ||||||||||||||||||||||||||||||||||||||||
| 24 | ? $session->{args}->{Index} | ||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | : [ split /\s+/, $session->{args}->{Index} ]; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my $id = $session->{data}->{_session_id}; | |||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my $attrIndex; | |||||||||||||||||||||||||||||||||||||||
| 29 | 0 | foreach my $i (@$index) { | |||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my $t; | |||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | next unless ( $t = $session->{data}->{$i} ); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | push @$attrIndex, "${i}_$t"; | |||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||
| 34 | my $attrs = [ | ||||||||||||||||||||||||||||||||||||||||
| 35 | objectClass => $self->{args}->{ldapObjectClass}, | ||||||||||||||||||||||||||||||||||||||||
| 36 | $self->{args}->{ldapAttributeId} => $session->{data}->{_session_id}, | ||||||||||||||||||||||||||||||||||||||||
| 37 | $self->{args}->{ldapAttributeContent} => $session->{serialized}, | ||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ]; | |||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | push @$attrs, ( $self->{args}->{ldapAttributeIndex} => $attrIndex ) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 40 | if ($attrIndex); | ||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||
| 42 | my $msg = $self->ldap->add( | ||||||||||||||||||||||||||||||||||||||||
| 43 | $self->{args}->{ldapAttributeId} . "=$id," | ||||||||||||||||||||||||||||||||||||||||
| 44 | . $self->{args}->{ldapConfBase}, | ||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | attrs => $attrs, | |||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | $self->ldap->unbind() && delete $self->{ldap}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | $self->logError($msg) if ( $msg->code ); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub update { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 54 | 0 | my $session = shift; | |||||||||||||||||||||||||||||||||||||||
| 55 | 0 | $self->{args} = $session->{args}; | |||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapObjectClass"} ||= "applicationProcess"
MC/DC0%0/1
$self->{"args"}{"ldapObjectClass"} ||= "applicationProcess"
$self->{"args"}{"ldapObjectClass"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapObjectClass"}
| |||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | $self->{args}->{ldapAttributeId} ||= 'cn'; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeId"} ||= "cn"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeId"} ||= "cn"
$self->{"args"}{"ldapAttributeId"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeId"}
| |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | $self->{args}->{ldapAttributeContent} ||= 'description'; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeContent"} ||= "description"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeContent"} ||= "description"
$self->{"args"}{"ldapAttributeContent"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeContent"}
| |||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | $self->{args}->{ldapAttributeIndex} ||= 'ou'; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeIndex"} ||= "ou"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeIndex"} ||= "ou"
$self->{"args"}{"ldapAttributeIndex"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeIndex"}
| |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||
| 61 | my $index = | ||||||||||||||||||||||||||||||||||||||||
| 62 | ref( $session->{args}->{Index} ) | ||||||||||||||||||||||||||||||||||||||||
| 63 | ? $session->{args}->{Index} | ||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | : [ split /\s+/, $session->{args}->{Index} ]; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my $id = $session->{data}->{_session_id}; | |||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $attrIndex; | |||||||||||||||||||||||||||||||||||||||
| 68 | 0 | foreach my $i (@$index) { | |||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $t; | |||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | next unless ( $t = $session->{data}->{$i} ); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | push @$attrIndex, "${i}_$t"; | |||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||
| 74 | my $attrs = | ||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | { $self->{args}->{ldapAttributeContent} => $session->{serialized} }; | |||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | $attrs->{ $self->{args}->{ldapAttributeIndex} } = $attrIndex | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 77 | if ($attrIndex); | ||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||
| 79 | my $msg = $self->ldap->modify( | ||||||||||||||||||||||||||||||||||||||||
| 80 | $self->{args}->{ldapAttributeId} . "=" | ||||||||||||||||||||||||||||||||||||||||
| 81 | . $session->{data}->{_session_id} . "," | ||||||||||||||||||||||||||||||||||||||||
| 82 | . $self->{args}->{ldapConfBase}, | ||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | replace => $attrs, | |||||||||||||||||||||||||||||||||||||||
| 84 | ); | ||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | $self->ldap->unbind() && delete $self->{ldap}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | $self->logError($msg) if ( $msg->code ); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | sub materialize { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
materialize: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my $session = shift; | |||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $self->{args} = $session->{args}; | |||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapObjectClass"} ||= "applicationProcess"
MC/DC0%0/1
$self->{"args"}{"ldapObjectClass"} ||= "applicationProcess"
$self->{"args"}{"ldapObjectClass"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapObjectClass"}
| |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | $self->{args}->{ldapAttributeId} ||= 'cn'; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeId"} ||= "cn"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeId"} ||= "cn"
$self->{"args"}{"ldapAttributeId"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeId"}
| |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | $self->{args}->{ldapAttributeContent} ||= 'description'; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeContent"} ||= "description"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeContent"} ||= "description"
$self->{"args"}{"ldapAttributeContent"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeContent"}
| |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | $self->{args}->{ldapAttributeIndex} ||= 'ou'; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeIndex"} ||= "ou"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeIndex"} ||= "ou"
$self->{"args"}{"ldapAttributeIndex"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeIndex"}
| |||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||
| 99 | my $msg = $self->ldap->search( | ||||||||||||||||||||||||||||||||||||||||
| 100 | base => $self->{args}->{ldapAttributeId} . "=" | ||||||||||||||||||||||||||||||||||||||||
| 101 | . $session->{data}->{_session_id} . "," | ||||||||||||||||||||||||||||||||||||||||
| 102 | . $self->{args}->{ldapConfBase}, | ||||||||||||||||||||||||||||||||||||||||
| 103 | filter => '(objectClass=' . $self->{args}->{ldapObjectClass} . ')', | ||||||||||||||||||||||||||||||||||||||||
| 104 | scope => 'base', | ||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | attrs => [ $self->{args}->{ldapAttributeContent} ], | |||||||||||||||||||||||||||||||||||||||
| 106 | ); | ||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | $self->ldap->unbind() && delete $self->{ldap}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | $self->logError($msg) if ( $msg->code ); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||
| 112 | $session->{serialized} = $msg->shift_entry() | ||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ->get_value( $self->{args}->{ldapAttributeContent} ); | |||||||||||||||||||||||||||||||||||||||
| 114 | }; | ||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | if ( !defined $session->{serialized} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | die "Object does not exist in data store"; | |||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub remove { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $session = shift; | |||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $self->{args} = $session->{args}; | |||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapObjectClass"} ||= "applicationProcess"
MC/DC0%0/1
$self->{"args"}{"ldapObjectClass"} ||= "applicationProcess"
$self->{"args"}{"ldapObjectClass"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapObjectClass"}
| |||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | $self->{args}->{ldapAttributeId} ||= 'cn'; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeId"} ||= "cn"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeId"} ||= "cn"
$self->{"args"}{"ldapAttributeId"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeId"}
| |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | $self->{args}->{ldapAttributeContent} ||= 'description'; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeContent"} ||= "description"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeContent"} ||= "description"
$self->{"args"}{"ldapAttributeContent"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeContent"}
| |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | $self->{args}->{ldapAttributeIndex} ||= 'ou'; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeIndex"} ||= "ou"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeIndex"} ||= "ou"
$self->{"args"}{"ldapAttributeIndex"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeIndex"}
| |||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||
| 130 | $self->ldap->delete( $self->{args}->{ldapAttributeId} . "=" | ||||||||||||||||||||||||||||||||||||||||
| 131 | . $session->{data}->{_session_id} . "," | ||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | . $self->{args}->{ldapConfBase} ); | |||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | $self->ldap->unbind() && delete $self->{ldap}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | sub ldap { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
ldap: not called CC=26 SCAR=65.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | return $self->{ldap} if ( $self->{ldap} ); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||
| 141 | # Parse servers configuration | ||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my $useTls = 0; | |||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my $tlsParam; | |||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my @servers = (); | |||||||||||||||||||||||||||||||||||||||
| 145 | 0 | foreach my $server ( split /[\s,]+/, $self->{args}->{ldapServer} ) { | |||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | if ( $server =~ m{^ldap\+tls://([^/]+)/?\??(.*)$} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $useTls = 1; | |||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $server = $1; | |||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | $tlsParam = $2 || ""; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$2 || ''
MC/DC0%0/1
$2 || ''
$2
Truth table0%0/2
A
A= $2
| |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||
| 151 | else { | ||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $useTls = 0; | |||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | push @servers, $server; | |||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||
| 157 | # Compatibility | ||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | my $caFile = $self->{args}->{ldapCAFile} || $self->{args}->{caFile}; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{'args'}{'ldapCAFile'} || $self->{'args'}{'caFile'}
MC/DC0%0/2
$self->{'args'}{'ldapCAFile'} || $self->{'args'}{'caFile'}
$self->{'args'}{'ldapCAFile'}
$self->{'args'}{'caFile'}
Truth table0%0/3
A || B
A= $self->{'args'}{'ldapCAFile'}B= $self->{'args'}{'caFile'}
| |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | my $caPath = $self->{args}->{ldapCAPath} || $self->{args}->{caPath}; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{'args'}{'ldapCAPath'} || $self->{'args'}{'caPath'}
MC/DC0%0/2
$self->{'args'}{'ldapCAPath'} || $self->{'args'}{'caPath'}
$self->{'args'}{'ldapCAPath'}
$self->{'args'}{'caPath'}
Truth table0%0/3
A || B
A= $self->{'args'}{'ldapCAPath'}B= $self->{'args'}{'caPath'}
| |||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||
| 161 | # Connect | ||||||||||||||||||||||||||||||||||||||||
| 162 | my $ldap = Net::LDAP->new( | ||||||||||||||||||||||||||||||||||||||||
| 163 | \@servers, | ||||||||||||||||||||||||||||||||||||||||
| 164 | onerror => undef, | ||||||||||||||||||||||||||||||||||||||||
| 165 | verify => $self->{args}->{ldapVerify} || "require", | ||||||||||||||||||||||||||||||||||||||||
| 166 | ( $caFile ? ( cafile => $caFile ) : () ), | ||||||||||||||||||||||||||||||||||||||||
| 167 | ( $caPath ? ( capath => $caPath ) : () ), | ||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||
| 169 | ( | ||||||||||||||||||||||||||||||||||||||||
| 170 | $self->{args}->{ldapRaw} ? ( raw => $self->{args}->{ldapRaw} ) | ||||||||||||||||||||||||||||||||||||||||
| 171 | : () | ||||||||||||||||||||||||||||||||||||||||
| 172 | ), | ||||||||||||||||||||||||||||||||||||||||
| 173 | ( | ||||||||||||||||||||||||||||||||||||||||
| 174 | $self->{args}->{ldapPort} ? ( port => $self->{args}->{ldapPort} ) | ||||||||||||||||||||||||||||||||||||||||
| 175 | : () | ||||||||||||||||||||||||||||||||||||||||
| 176 | ), | ||||||||||||||||||||||||||||||||||||||||
| 177 | ( | ||||||||||||||||||||||||||||||||||||||||
| 178 | $self->{args}->{ldapTimeout} | ||||||||||||||||||||||||||||||||||||||||
| 179 | ? ( timeout => $self->{args}->{ldapTimeout} ) | ||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | : () | ||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
Condition0%0/2
$self->{'args'}{'ldapVerify'} || 'require'
MC/DC0%0/1
$self->{'args'}{'ldapVerify'} || 'require'
$self->{'args'}{'ldapVerify'}
Truth table0%0/2
A
A= $self->{'args'}{'ldapVerify'}
| |||||||||||||||||||||||||||||||||||||||||
| 181 | ), | ||||||||||||||||||||||||||||||||||||||||
| 182 | ) or die( 'Unable to connect to ' . join( ' ', @servers ) . ": " . $@ ); | ||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||
| 184 | # Check SSL error for old Net::LDAP versions | ||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | if ( $Net::LDAP::VERSION < '0.64' ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||
| 187 | # CentOS7 has a bug in which IO::Socket::SSL will return a broken | ||||||||||||||||||||||||||||||||||||||||
| 188 | # socket when certificate validation fails. Net::LDAP does not catch | ||||||||||||||||||||||||||||||||||||||||
| 189 | # it, and the process ends up crashing. | ||||||||||||||||||||||||||||||||||||||||
| 190 | # As a precaution, make sure the underlying socket is doing fine: | ||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | if ( $ldap->socket->isa('IO::Socket::SSL') | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ldap->socket->isa("IO::Socket::SSL") and $ldap->socket->errstr < 0
MC/DC0%0/2
$ldap->socket->isa("IO::Socket::SSL") and $ldap->socket->errstr < 0
$ldap->socket->isa("IO::Socket::SSL")
$ldap->socket->errstr < 0
Truth table0%0/3
A and B
A= $ldap->socket->isa("IO::Socket::SSL")B= $ldap->socket->errstr < 0
| |||||||||||||||||||||||||||||||||||||||||
| 192 | and $ldap->socket->errstr < 0 ) | ||||||||||||||||||||||||||||||||||||||||
| 193 | { | ||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | die( "SSL connection error: " . $ldap->socket->errstr ); | |||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||
| 198 | # Start TLS if needed | ||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | if ($useTls) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my %h = split( /[&=]/, $tlsParam ); | |||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | $h{verify} ||= ( $self->{args}->{ldapVerify} || "require" ); | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$h{"verify"} ||= $self->{"args"}{"ldapVerify"} || "require"
$self->{'args'}{'ldapVerify'} || 'require'
MC/DC0%0/2
$h{"verify"} ||= $self->{"args"}{"ldapVerify"} || "require"
$h{"verify"}
$self->{'args'}{'ldapVerify'}
Truth table0%0/3
A ||= B
A= $h{"verify"}B= $self->{'args'}{'ldapVerify'}
| |||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | $h{cafile} ||= $caFile if ($caFile); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$h{"cafile"} ||= $caFile
MC/DC0%0/2
$h{"cafile"} ||= $caFile
$h{"cafile"}
$caFile
Truth table0%0/3
A ||= B
A= $h{"cafile"}B= $caFile
| |||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | $h{capath} ||= $caPath if ($caPath); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$h{"capath"} ||= $caPath
MC/DC0%0/2
$h{"capath"} ||= $caPath
$h{"capath"}
$caPath
Truth table0%0/3
A ||= B
A= $h{"capath"}B= $caPath
| |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $start_tls = $ldap->start_tls(%h); | |||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if ( $start_tls->code ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $self->logError($start_tls); | |||||||||||||||||||||||||||||||||||||||
| 207 | 0 | return; | |||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||
| 211 | # Bind with credentials | ||||||||||||||||||||||||||||||||||||||||
| 212 | my $bind = $ldap->bind( $self->{args}->{ldapBindDN}, | ||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | password => $self->{args}->{ldapBindPassword} ); | |||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if ( $bind->code ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $self->logError($bind); | |||||||||||||||||||||||||||||||||||||||
| 216 | 0 | return; | |||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $self->{ldap} = $ldap; | |||||||||||||||||||||||||||||||||||||||
| 220 | 0 | return $ldap; | |||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | sub logError { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
logError: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 225 | 0 | my $ldap_operation = shift; | |||||||||||||||||||||||||||||||||||||||
| 226 | 0 | die "LDAP error " . $ldap_operation->code . ": " . $ldap_operation->error; | |||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||
| 229 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||
| 231 | =pod | ||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||
| 233 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||
| 235 | Apache::Session::Browseable::Store::LDAP - Use LDAP to store persistent objects | ||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||
| 237 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||
| 239 | use Apache::Session::Browseable::Store::LDAP; | ||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||
| 241 | my $store = new Apache::Session::Browseable::Store::LDAP; | ||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||
| 243 | $store->insert($ref); | ||||||||||||||||||||||||||||||||||||||||
| 244 | $store->update($ref); | ||||||||||||||||||||||||||||||||||||||||
| 245 | $store->materialize($ref); | ||||||||||||||||||||||||||||||||||||||||
| 246 | $store->remove($ref); | ||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||
| 248 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||
| 250 | This module fulfills the storage interface of Apache::Session. The serialized | ||||||||||||||||||||||||||||||||||||||||
| 251 | objects are stored in an LDAP directory file using the Net::LDAP Perl module. | ||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||
| 253 | =head1 OPTIONS | ||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||
| 255 | This module requires one argument in the usual Apache::Session style. The | ||||||||||||||||||||||||||||||||||||||||
| 256 | keys ldapServer, ldapBase, ldapBindDN, ldapBindPassword are required. The key | ||||||||||||||||||||||||||||||||||||||||
| 257 | ldapPort, ldapObjectClass, ldapAttributeId, ldapAttributeContent, | ||||||||||||||||||||||||||||||||||||||||
| 258 | ldapAttributeIndex, and ldapRaw are optional. | ||||||||||||||||||||||||||||||||||||||||
| 259 | Example: | ||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||
| 261 | tie %s, 'Apache::Session::Browseable::LDAP', undef, | ||||||||||||||||||||||||||||||||||||||||
| 262 | { | ||||||||||||||||||||||||||||||||||||||||
| 263 | ldapServer => 'localhost', | ||||||||||||||||||||||||||||||||||||||||
| 264 | ldapBase => 'dc=example,dc=com', | ||||||||||||||||||||||||||||||||||||||||
| 265 | ldapBindDN => 'cn=admin,dc=example,dc=com', | ||||||||||||||||||||||||||||||||||||||||
| 266 | ldapBindPassword => 'pass', | ||||||||||||||||||||||||||||||||||||||||
| 267 | Index => 'uid ipAddr', | ||||||||||||||||||||||||||||||||||||||||
| 268 | ldapObjectClass => 'applicationProcess', | ||||||||||||||||||||||||||||||||||||||||
| 269 | ldapAttributeId => 'cn', | ||||||||||||||||||||||||||||||||||||||||
| 270 | ldapAttributeContent => 'description', | ||||||||||||||||||||||||||||||||||||||||
| 271 | ldapAttributeIndex => 'ou', | ||||||||||||||||||||||||||||||||||||||||
| 272 | ldapRaw => '(?i:^jpegPhoto|;binary)', | ||||||||||||||||||||||||||||||||||||||||
| 273 | }; | ||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||
| 275 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||
| 277 | =over | ||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||
| 279 | =item 2009-2025 by Xavier Guimard | ||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||
| 281 | =item 2013-2025 by Clément Oudot | ||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||
| 283 | =item 2019-2025 by Maxime Besson | ||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||
| 285 | =item 2013-2025 by Worteks | ||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||
| 287 | =item 2023-2025 by Linagora | ||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||
| 289 | =back | ||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||
| 291 | This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||
| 292 | it under the same terms as Perl itself, either Perl version 5.10.0 or, | ||||||||||||||||||||||||||||||||||||||||
| 293 | at your option, any later version of Perl 5 you may have available. | ||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||
| 295 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||
| 297 | L<Apache::Session> | ||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||
| 299 | =cut | ||||||||||||||||||||||||||||||||||||||||