Lite/RelyingParty/IDResHandler/Verifier.pm

filter: Statementstmt 22.6% 56 / 247 Branchbran 0.0% 0 / 126 Conditioncond 0.0% 0 / 22 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 42.4% 14 / 33 Podpod 0.0% 0 / 1 totaltotal 15.8% 70 / 443 CC 80 SCAR 41.1
CC
80
Cov
14%
_verify_discovery_single
156.0
_verify_discovery_results_openid2
156.0
_check_for_fields
72.0
CRAP 61.1
« Lite/Provider/Response.pm ↑ Summary Lite/Provider/Handler/CheckID.pm »
1 package OpenID::Lite::RelyingParty::IDResHandler::Verifier;
2 1 ▶use Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use List::MoreUtils qw(any);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use OpenID::Lite::Nonce;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use OpenID::Lite::Util::URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use OpenID::Lite::Util::XRI;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use OpenID::Lite::SignatureMethods;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use OpenID::Lite::Identifier;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use OpenID::Lite::RelyingParty::DirectCommunication;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use OpenID::Lite::RelyingParty::Discover;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use OpenID::Lite::RelyingParty::Discover::Service;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 use OpenID::Lite::Constants::Namespace
15 1 ▶ qw(SPEC_1_0 SPEC_2_0 SIGNON_1_1 SIGNON_1_0 SIGNON_2_0 SERVER_2_0);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use OpenID::Lite::Constants::ModeType qw(CHECK_AUTHENTICATION);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 has 'params' => (
19 is => 'ro',
20 isa => 'OpenID::Lite::Message',
21 required => 1,
22 );
23  
24 1 has 'current_url' => (
25 is => 'ro',
26 isa => 'Str',
27 required => 1,
28 );
29  
30 1 has 'service' => (
31 is => 'rw',
32 isa => 'OpenID::Lite::RelyingParty::Discover::Service',
33 predicate => 'has_service',
34 );
35  
36 1 has 'store' => (
37 is => 'ro',
38  
39 #does => 'OpenID::Lite::Role::Storable',
40 );
41  
42 1 has '_discoverer' => (
43 is => 'ro',
44 lazy_build => 1,
45 );
46  
47 1 has '_direct_communication' => (
48 is => 'ro',
49 isa => 'OpenID::Lite::RelyingParty::DirectCommunication',
50 lazy_build => 1,
51 );
52  
53 1 with 'OpenID::Lite::Role::AgentHandler';
54 1 with 'OpenID::Lite::Role::ErrorHandler';
55  
56 1 my @OP1_FIELDS = qw(return_to assoc_handle sig signed identity);
57 1 my @OP1_SIG_FIELDS = qw(return_to identity);
58  
59 1 my @OP2_FIELDS = qw(return_to assoc_handle sig signed op_endpoint);
60 1 my @OP2_SIG_FIELDS = qw(return_to response_nonce assoc_handle);
61  
62 0 ▶sub verify {
Subroutine verify: not called CC=6 SCAR=37.4
Pod undocumented
63 0 my $self = shift;
64 0 ▶ $self->_check_for_fields() or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_check_for_fields or return 0 0 0
65 0 ▶ $self->_verify_return_to() or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_verify_return_to or return 0 0 0
66  
67 0 ▶ $self->_verify_discovery_results() or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_verify_discovery_results or return 0 0 0
68 0 ▶ $self->_check_nonce() or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_check_nonce or return 0 0 0
69 0 ▶ $self->_check_signature() or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_check_signature or return 0 0 0
70  
71 0 return 1;
72 }
73  
74 0 ▶sub _check_for_fields {
Subroutine _check_for_fields: not called CC=8 SCAR=42.8
75 0 my $self = shift;
76  
77 0 my ( @fields, @signed_fields );
78 0 ▶ if ( $self->params->is_openid1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->params->is_openid1) { } 0 0 0
79 0 @fields = @OP1_FIELDS;
80 0 @signed_fields = @OP1_SIG_FIELDS;
81 }
82 else {
83 0 @fields = @OP2_FIELDS;
84 0 @signed_fields = @OP2_SIG_FIELDS;
85 }
86  
87 0 ▶ my $signed = $self->params->get('signed')
Branch: 1 branch
BranchTrueFalseTotal
my $signed = $self->params->get("signed") or $self->ERROR("signed key not found.") 0 0 0
88 or $self->ERROR(q{signed key not found.});
89 0 my @signed = split /,/, $signed;
90  
91 0 for my $field (@fields) {
92 0 ▶ unless ( $self->params->has_key($field) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->params->has_key($field)) 0 0 0
93 0 return $self->ERROR( sprintf q{"%s" key not found}, $field );
94 }
95 }
96 0 for my $field (@signed_fields) {
97 0 ▶ unless ( $self->params->has_key($field)
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->params->has_key($field) and &any(sub { $field eq $_; } , @signed)) 0 0 0
Condition0%0/3
$self->params->has_key($field) and &any(sub { $field eq $_; } , @signed)
!ll&&!rl&&r
000
MC/DC0%0/2
$self->params->has_key($field) and &any(sub { $field eq $_; } , @signed)
$self->params->has_key($field) &any(sub { $field eq $_; } , @signed)
Truth table0%0/3
A and B
A= $self->params->has_key($field)B= &any(sub { $field eq $_; } , @signed)
ABresult
0X0
100
111
98 0 ▶ && ( any { $field eq $_ } @signed ) )
Subroutine __ANON__: not called CC=1 SCAR=6.9
99 {
100 0 return $self->ERROR( sprintf q{"%s" key not found}, $field );
101 }
102 }
103 0 return 1;
104 }
105  
106 0 ▶sub _verify_return_to {
Subroutine _verify_return_to: not called CC=6 SCAR=37.4
107 0 my $self = shift;
108  
109 0 my $url = $self->params->get('return_to');
110 0 ▶ return unless $url;
Branch: 1 branch
BranchTrueFalseTotal
unless $url 0 0 0
111 0 $url = OpenID::Lite::Util::URI->normalize($url);
112 0 ▶ return unless $url;
Branch: 1 branch
BranchTrueFalseTotal
unless $url 0 0 0
113 0 ▶ return unless OpenID::Lite::Util::URI->is_uri($url);
Branch: 1 branch
BranchTrueFalseTotal
unless "OpenID::Lite::Util::URI"->is_uri($url) 0 0 0
114  
115 0 ▶ $self->_verify_return_to_args($url)
Branch: 1 branch
BranchTrueFalseTotal
$self->_verify_return_to_args($url) or return 0 0 0
116 or return;
117 0 ▶ $self->_verify_return_to_base($url)
Branch: 1 branch
BranchTrueFalseTotal
$self->_verify_return_to_base($url) or return 0 0 0
118 or return;
119 0 return 1;
120 }
121  
122 0 ▶sub _verify_return_to_args {
Subroutine _verify_return_to_args: not called CC=7 SCAR=40.3
123 0 my ( $self, $return_to ) = @_;
124 0 $return_to = URI->new($return_to);
125 0 my %parsed = $return_to->query_form();
126  
127 0 for my $key ( keys %parsed ) {
128 0 my $msg_val = $self->params->get_extra($key);
129 0 ▶ return $self->ERROR(
Branch: 1 branch
BranchTrueFalseTotal
unless $msg_val 0 0 0
130 sprintf q{Message missing return_to argument, "%s"}, $key )
131 unless $msg_val;
132 return $self->ERROR(
133 sprintf
134 q{Parameter [%s]s value [%s] doesn't match return_to's value [%s]},
135 $key, $msg_val, $parsed{$key} )
136 0 ▶ if ( $msg_val ne $parsed{$key} );
Branch: 1 branch
BranchTrueFalseTotal
if $msg_val ne $parsed{$key} 0 0 0
137 }
138  
139 0 for my $key ( @{ $self->params->get_extra_keys() } ) {
140 0 my $msg_val = $self->params->get_extra($key);
141 return $self->ERROR(
142 q{Unexpected parameter (not on return_to), [%s = %s]},
143 $key, $msg_val )
144 0 ▶ if not exists $parsed{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $parsed{$key} 0 0 0
145 0 ▶ if ( $msg_val ne $parsed{$key} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($msg_val ne $parsed{$key}) 0 0 0
146 return $self->ERROR(
147 sprintf
148 q{Parameter [%s]s value [%s] doesn't match return_to's value [%s]},
149 0 $key, $msg_val, $parsed{$key} );
150 }
151 }
152  
153 0 return 1;
154 }
155  
156 0 ▶sub _verify_return_to_base {
Subroutine _verify_return_to_base: not called CC=3 SCAR=24.8
157 0 my ( $self, $return_to ) = @_;
158 0 $return_to = URI->new($return_to);
159 0 my $current_url = URI->new( $self->current_url );
160 0 for my $meth (qw(scheme host port path)) {
161 0 ▶ return $self->ERROR(
Branch: 1 branch
BranchTrueFalseTotal
unless $current_url->$meth eq $return_to->$meth 0 0 0
162 sprintf q{"%s" in response parameter wasn't match to "%s"},
163 $return_to->as_string, $current_url->as_string )
164 unless $current_url->$meth eq $return_to->$meth;
165 }
166 0 return 1;
167 }
168  
169 0 ▶sub _verify_discovery_single {
Subroutine _verify_discovery_single: not called CC=12 SCAR=50.5
170 0 my ( $self, $endpoint, $to_match ) = @_;
171 0 for my $type_uri ( @{ $to_match->types } ) {
172 0 ▶ return $self->ERROR(q{Type uri mismatch.})
Branch: 1 branch
BranchTrueFalseTotal
unless $endpoint->has_type($type_uri) 0 0 0
173 unless $endpoint->has_type($type_uri);
174 }
175  
176 0 my $defragged_claimed_id;
177 0 my $scheme = OpenID::Lite::Util::XRI->identifier_scheme(
178 $to_match->claimed_identifier );
179 0 ▶ if ( $scheme eq 'xri' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($scheme eq 'xri') { } 0 0 0
elsif ($scheme eq 'uri') { } 0 0 0
180 0 $defragged_claimed_id = $to_match->claimed_identifier;
181 }
182 elsif ( $scheme eq 'uri' ) {
183 0 ▶ if (OpenID::Lite::Util::URI->is_uri( $to_match->claimed_identifier ) )
Branch: 1 branch
BranchTrueFalseTotal
if ('OpenID::Lite::Util::URI'->is_uri($to_match->claimed_identifier)) { } 0 0 0
184 {
185 0 my $parsed = URI->new( $to_match->claimed_identifier );
186 0 $parsed->fragment(undef);
187 0 $defragged_claimed_id = $parsed->as_string;
188 }
189 else {
190 0 $defragged_claimed_id = $to_match->claimed_identifier;
191 }
192 }
193 else {
194 0 ▶ return $self->ERROR(
Condition0%0/2
$to_match->claimed_identifier || ''
l!l
00
MC/DC0%0/1
$to_match->claimed_identifier || ''
$to_match->claimed_identifier
Truth table0%0/2
A
A= $to_match->claimed_identifier
Aresult
11
00
195 sprintf q{Invalid claimed_id, "%s"},
196 $to_match->claimed_identifier || ''
197 );
198 }
199  
200 0 ▶ if ( $defragged_claimed_id ne $endpoint->claimed_identifier ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($defragged_claimed_id ne $endpoint->claimed_identifier) 0 0 0
201 0 return $self->ERROR(
202 sprintf q{Claimed IDs don't match, "%s" and "%s" },
203 $defragged_claimed_id, $endpoint->claimed_identifier );
204 }
205  
206 0 ▶ if ($endpoint->find_local_identifier ne $to_match->find_local_identifier )
Branch: 1 branch
BranchTrueFalseTotal
if ($endpoint->find_local_identifier ne $to_match->find_local_identifier) 0 0 0
207 {
208 0 return $self->ERROR(
209 sprintf q{Local IDs don't match, "%s" and "%s" },
210 $to_match->find_local_identifier,
211 $endpoint->find_local_identifier
212 );
213 }
214  
215 0 ▶ if ( !$to_match->url ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $to_match->url) { } 0 0 0
elsif ($endpoint->url ne $to_match->url) { } 0 0 0
216 0 ▶ if ( $to_match->preferred_namespace ne SPEC_1_0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($to_match->preferred_namespace ne "http://openid.net/xmlns/1.0") 0 0 0
217 0 return $self->ERROR(
218 q{ensure that endpoint is openid2.0 without openid.op_endpoint?}
219 );
220 }
221 }
222 elsif ( $endpoint->url ne $to_match->url ) {
223 0 return $self->ERROR( sprintf q{OP endpoint mismatch, "%s" and "%s"},
224 $endpoint->url, $to_match->url );
225 }
226 0 return 1;
227 }
228  
229 0 ▶sub _verify_discovered_services {
Subroutine _verify_discovered_services: not called CC=4 SCAR=30.0
230 0 my ( $self, $claimed_id, $services, $to_match_endpoints ) = @_;
231  
232 0 my @failure_messages;
233 0 for my $service ( @$services ) {
234 0 for my $to_match ( @$to_match_endpoints ) {
235 0 ▶ if ( $self->_verify_discovery_single($service, $to_match) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_verify_discovery_single($service, $to_match)) { } 0 0 0
236 0 $self->service($service);
237 0 return 1;
238 } else {
239 0 push(@failure_messages, $self->errstr);
240 0 $self->ERROR(undef);
241 }
242 }
243 }
244 0 return $self->ERROR(
245 sprintf q{No matching endpoint found for claimed_id "%s".}, $claimed_id);
246 }
247  
248 0 ▶sub _discover_and_verify {
Subroutine _discover_and_verify: not called CC=3 SCAR=24.8
249 0 my ( $self, $claimed_id, $to_match_endpoints ) = @_;
250 0 $claimed_id = OpenID::Lite::Identifier->normalize($claimed_id);
251 0 ▶ my $services = $self->_discoverer->discover($claimed_id)
Branch: 1 branch
BranchTrueFalseTotal
my $services = $self->_discoverer->discover($claimed_id) or return $self->ERROR($self->_discoverer->errstr) 0 0 0
252 or return $self->ERROR( $self->_discoverer->errstr );
253 0 ▶ unless ( @$services > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$services > 0) 0 0 0
254 0 return $self->ERROR( sprintf q{No OpenID information found at %s},
255 $claimed_id );
256 }
257 0 return $self->_verify_discovered_services( $claimed_id, $services,
258 $to_match_endpoints );
259 }
260  
261 0 ▶sub _verify_discovery_results_openid1 {
Subroutine _verify_discovery_results_openid1: not called CC=7 SCAR=40.3
262 0 my $self = shift;
263  
264 0 my $claimed_id = $self->params->get_extra('openid1_claimed_id');
265  
266 0 ▶ unless ($claimed_id) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($claimed_id) 0 0 0
267 0 ▶ if ( $self->has_service && $self->service->claimed_identifier ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_service and $self->service->claimed_identifier) { } 0 0 0
Condition0%0/3
$self->has_service and $self->service->claimed_identifier
!ll&&!rl&&r
000
MC/DC0%0/2
$self->has_service and $self->service->claimed_identifier
$self->has_service $self->service->claimed_identifier
Truth table0%0/3
A and B
A= $self->has_serviceB= $self->service->claimed_identifier
ABresult
0X0
100
111
268 0 $claimed_id = $self->service->claimed_identifier;
269 }
270 else {
271 0 return $self->ERROR(q{When using OpenID 1, the claimed id must be supplied,
272 either by passing it through as a return_to parameter or by using a
273 session, and supplied to the IDResHandler when it is constructed.});
274 }
275 }
276  
277 0 my $to_match = OpenID::Lite::RelyingParty::Discover::Service->new;
278 0 $to_match->op_local_identifier( $self->params->get('identity') );
279 0 $to_match->claimed_identifier($claimed_id);
280  
281 0 my $to_match_1_0 = $to_match->copy();
282 0 $to_match->add_type(SIGNON_1_1);
283 0 $to_match_1_0->add_type(SIGNON_1_0);
284  
285 0 ▶ if ( $self->has_service ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_service) 0 0 0
286 0 ▶ my $verified = $self->_verify_discovery_single( $self->service, $to_match )
Condition0%0/3
$self->_verify_discovery_single($self->service, $to_match) || $self->_verify_discovery_single($self->service, $to_match_1_0)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->_verify_discovery_single($self->service, $to_match) || $self->_verify_discovery_single($self->service, $to_match_1_0)
$self->_verify_discovery_single($self->service, $to_match) $self->_verify_discovery_single($self->service, $to_match_1_0)
Truth table0%0/3
A || B
A= $self->_verify_discovery_single($self->service, $to_match)B= $self->_verify_discovery_single($self->service, $to_match_1_0)
ABresult
1X1
011
000
287 || $self->_verify_discovery_single( $self->service, $to_match_1_0 );
288 0 ▶ return 1 if $verified;
Branch: 1 branch
BranchTrueFalseTotal
if $verified 0 0 0
289 }
290  
291 0 return $self->_discover_and_verify(
292 $to_match->claimed_identifier,
293 [$to_match, $to_match_1_0]
294 );
295 }
296  
297 0 ▶sub _verify_discovery_results_openid2 {
Subroutine _verify_discovery_results_openid2: not called CC=12 SCAR=50.5
298 0 my $self = shift;
299 0 my $to_match = OpenID::Lite::RelyingParty::Discover::Service->new;
300 0 $to_match->add_type(SIGNON_2_0);
301 0 $to_match->add_uri( $self->params->get('op_endpoint') );
302  
303 # claimed_id && identity both or none?
304 0 my $claimed_id = $self->params->get('claimed_id');
305 0 my $identity = $self->params->get('identity');
306  
307 0 $to_match->claimed_identifier($claimed_id);
308 0 $to_match->op_local_identifier($identity);
309  
310 0 ▶ if ( $claimed_id && !$identity ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($claimed_id and not $identity) { } 0 0 0
elsif (not $claimed_id and $identity) { } 0 0 0
elsif (not $claimed_id) { } 0 0 0
Condition0%0/3
$claimed_id and not $identity
!ll&&!rl&&r
000
MC/DC0%0/2
$claimed_id and not $identity
$claimed_id not $identity
Truth table0%0/3
A and not(B)
A= $claimed_idB= not $identity
ABresult
0X0
100
111
311 0 return $self->ERROR(
312 q{openid.claimed_id is present without openid.identity});
313 }
314 ▶ elsif ( !$claimed_id && $identity ) {
Condition0%0/3
not $claimed_id and $identity
!ll&&!rl&&r
000
MC/DC0%0/2
not $claimed_id and $identity
not $claimed_id $identity
Truth table0%0/3
not(A) and B
A= not $claimed_idB= $identity
ABresult
0X0
100
111
315 0 return $self->ERROR(
316 q{openid.identity is present without openid.claimed_id});
317 }
318 elsif ( !$claimed_id ) {
319  
320 0 my $service = OpenID::Lite::RelyingParty::Discover::Service->new;
321 0 $service->add_type(SERVER_2_0);
322 0 $service->add_uri( $self->params->get('op_endpoint') );
323 0 $self->service($service);
324 0 return 1;
325 }
326  
327 0 ▶ if ( $self->has_service ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_service) { } 0 0 0
328 0 ▶ unless ( $self->_verify_discovery_single( $self->service, $to_match ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_verify_discovery_single($self->service, $to_match)) 0 0 0
329 0 ▶ return unless $claimed_id;
Branch: 1 branch
BranchTrueFalseTotal
unless $claimed_id 0 0 0
330 0 ▶ return unless $self->_discover_and_verify( $claimed_id, [$to_match] )
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_discover_and_verify($claimed_id, [$to_match]) 0 0 0
331 }
332 }
333 else {
334 0 ▶ $self->_discover_and_verify( $claimed_id, [$to_match] )
Branch: 1 branch
BranchTrueFalseTotal
$self->_discover_and_verify($claimed_id, [$to_match]) or return 0 0 0
335 or return;
336 }
337  
338 0 ▶ if ( $self->service->claimed_identifier ne $to_match->claimed_identifier )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->service->claimed_identifier ne $to_match->claimed_identifier) 0 0 0
339 {
340 0 my $copied = $self->service->copy();
341 0 $copied->claimed_identifier( $to_match->claimed_identifier );
342 0 $self->service($copied);
343 }
344  
345 0 return 1;
346 }
347  
348 0 ▶sub _verify_discovery_results {
Subroutine _verify_discovery_results: not called CC=5 SCAR=34.0
349 0 my $self = shift;
350 0 ▶ if ( $self->params->is_openid1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->params->is_openid1) { } 0 0 0
elsif ($self->params->is_openid2) { } 0 0 0
351 0 ▶ $self->_verify_discovery_results_openid1()
Branch: 1 branch
BranchTrueFalseTotal
$self->_verify_discovery_results_openid1 or return 0 0 0
352 or return;
353 }
354 elsif ( $self->params->is_openid2 ) {
355 0 ▶ $self->_verify_discovery_results_openid2()
Branch: 1 branch
BranchTrueFalseTotal
$self->_verify_discovery_results_openid2 or return 0 0 0
356 or return;
357 }
358 else {
359 0 return $self->ERROR(q{No reached});
360 }
361 }
362  
363 0 ▶sub _check_nonce {
Subroutine _check_nonce: not called CC=8 SCAR=42.8
364 0 my $self = shift;
365 0 my ( $nonce, $server_url );
366 0 ▶ if ( $self->params->is_openid1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->params->is_openid1) { } 0 0 0
elsif ($self->params->is_openid2) { } 0 0 0
367 0 $nonce
368 = $self->params->get_extra('rp_nonce'); # TODO: get extra params
369 0 $server_url = '';
370 }
371 elsif ( $self->params->is_openid2 ) {
372 0 $nonce = $self->params->get('response_nonce');
373 0 ▶ $server_url = $self->has_service ? $self->service->url : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->has_service ? : 0 0 0
374 }
375 else {
376 0 return $self->ERROR(q{IdRes Response doesn't have proper ns value.});
377 }
378  
379 0 ▶ unless ($nonce) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($nonce) 0 0 0
380 0 return $self->ERROR(q{No proper nonce found.});
381 }
382  
383 0 ▶ my ( $timestamp, $unique ) = OpenID::Lite::Nonce->split_nonce($nonce)
Branch: 1 branch
BranchTrueFalseTotal
() = "OpenID::Lite::Nonce"->split_nonce($nonce) or return $self->ERROR(sprintf('Invalid response_nonce format. "%s"', $nonce)) 0 0 0
384 or
385 return $self->ERROR( sprintf q{Invalid response_nonce format. "%s"},
386 $nonce );
387  
388 0 ▶ if ( $self->store
Branch: 1 branch
BranchTrueFalseTotal
if ($self->store and not $self->store->use_nonce($server_url, $timestamp, $unique)) 0 0 0
Condition0%0/3
$self->store and not $self->store->use_nonce($server_url, $timestamp, $unique)
!ll&&!rl&&r
000
MC/DC0%0/2
$self->store and not $self->store->use_nonce($server_url, $timestamp, $unique)
$self->store not $self->store->use_nonce($server_url, $timestamp, $unique)
Truth table0%0/3
A and not(B)
A= $self->storeB= not $self->store->use_nonce($server_url, $timestamp, $unique)
ABresult
0X0
100
111
389 && !$self->store->use_nonce( $server_url, $timestamp, $unique ) )
390 {
391 0 return $self->ERROR(
392 sprintf q{Nonce already used or out of range: "%s"}, $nonce );
393 }
394  
395 0 return 1;
396 }
397  
398 0 ▶sub _check_signature {
Subroutine _check_signature: not called CC=5 SCAR=34.0
399  
400 0 my $self = shift;
401  
402 0 my $assoc;
403 0 my $server_url = $self->service->url;
404  
405 0 ▶ if ( $self->store ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->store) 0 0 0
406 0 my $assoc_handle = $self->params->get('assoc_handle');
407 0 $assoc = $self->store->get_association( $server_url, $assoc_handle );
408 }
409  
410 0 ▶ if ( !$assoc ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $assoc) { } 0 0 0
411 0 return $self->_check_auth();
412 }
413 else {
414 0 ▶ if ( $assoc->is_expired ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($assoc->is_expired) { } 0 0 0
415 0 return $self->ERROR(q{Association expired});
416 }
417 else {
418 0 my $secret = $assoc->secret;
419 0 my $assoc_type = $assoc->type;
420 0 my $method
421 = OpenID::Lite::SignatureMethods->select_method($assoc_type);
422 0 ▶ return $self->ERROR( sprintf q{Bad signature in response from %s},
Branch: 1 branch
BranchTrueFalseTotal
unless $method->verify($secret, $self->params) 0 0 0
423 $server_url )
424 unless $method->verify( $secret, $self->params );
425 }
426 0 return 1;
427 }
428 }
429  
430 0 ▶sub _check_auth {
Subroutine _check_auth: not called CC=3 SCAR=24.8
431 0 my $self = shift;
432 0 ▶ my $params = $self->_create_check_auth_request()
Branch: 1 branch
BranchTrueFalseTotal
my $params = $self->_create_check_auth_request or return 0 0 0
433 or return;
434 0 my $server_url = $self->service->url;
435 0 ▶ my $res_params
Branch: 1 branch
BranchTrueFalseTotal
my $res_params = $self->_direct_communication->send_request($server_url, $params) or return $self->ERROR("Failed direct-communication, 'checkauth' request") 0 0 0
436 = $self->_direct_communication->send_request( $server_url, $params )
437 or return $self->ERROR(q{Failed direct-communication, 'checkauth' request});
438 0 return $self->_process_check_auth_response($res_params);
439 }
440  
441 0 ▶sub _process_check_auth_response {
Subroutine _process_check_auth_response: not called CC=5 SCAR=34.0
442 0 my ( $self, $res_params ) = @_;
443 0 ▶ my $is_valid = $res_params->get('is_valid') || 'false';
Condition0%0/2
$res_params->get('is_valid') || 'false'
l!l
00
MC/DC0%0/1
$res_params->get('is_valid') || 'false'
$res_params->get('is_valid')
Truth table0%0/2
A
A= $res_params->get('is_valid')
Aresult
11
00
444 0 my $invalidate_handle = $res_params->get('invalidate_handle');
445 0 my $server_url = $self->service->url;
446 0 ▶ if ($invalidate_handle) {
Branch: 1 branch
BranchTrueFalseTotal
if ($invalidate_handle) 0 0 0
447 0 ▶ if ( $self->store ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->store) 0 0 0
448 0 $self->store->remove_association( $server_url,
449 $invalidate_handle );
450 }
451 }
452  
453 0 ▶ if ( $is_valid ne 'true' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_valid ne "true") 0 0 0
454 0 return $self->ERROR(
455 sprintf
456 q{Server %s responds that check_authentication call is not valid.},
457 $server_url,
458 );
459 }
460 0 return 1;
461 }
462  
463 0 ▶sub _create_check_auth_request {
Subroutine _create_check_auth_request: not called CC=1 SCAR=6.9
464 0 my $self = shift;
465 0 my $ca_message = $self->params->copy();
466 0 $ca_message->set( mode => CHECK_AUTHENTICATION );
467 0 return $ca_message;
468  
469 }
470  
471 0 ▶sub _build__discoverer {
Subroutine _build__discoverer: not called CC=1 SCAR=6.9
472 0 my $self = shift;
473 0 return OpenID::Lite::RelyingParty::Discover->new(
474 agent => $self->agent, );
475 }
476  
477 0 ▶sub _build__direct_communication {
Subroutine _build__direct_communication: not called CC=1 SCAR=6.9
478 0 my $self = shift;
479 0 return OpenID::Lite::RelyingParty::DirectCommunication->new(
480 agent => $self->agent, );
481 }
482  
483 1 ▶no Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
484 1 __PACKAGE__->meta->make_immutable;
485 1 1;
486  
« Lite/Provider/Response.pm ↑ Summary Lite/Provider/Handler/CheckID.pm »