DRI/Protocol/EPP/Extensions/ICANN/MarkSignedMark.pm

filter: Statementstmt 7.1% 24 / 334 Branchbran 0.0% 0 / 214 Conditioncond 0.0% 0 / 72 MC/DCmcdc 0.0% 0 / 45 Subroutinesub 24.1% 7 / 29 Podpod 0.0% 0 / 10 totaltotal 4.4% 31 / 704 CC 150 SCAR 53.4
CC
150
Cov
4%
_build_contact
600.0
parse_mark
462.0
_build_addr
240.0
CRAP 207.6
« DRI/Protocol/EPP/Extensions/TCI/Domain.pm ↑ Summary DRI/Protocol/EPP/Extensions/Nomulus/Allocate.pm »
1 ## Domain Registry Interface, Mark & Signed Mark for EPP (RFC7848)
2 ##
3 ## Copyright (c) 2013-2016,2018 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4 ##
5 ## This file is part of Net::DRI
6 ##
7 ## Net::DRI is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## See the LICENSE file that comes with this distribution for more details.
13 ####################################################################################################
14  
15 package Net::DRI::Protocol::EPP::Extensions::ICANN::MarkSignedMark;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Net::DRI::Protocol::EPP::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 ▶use XML::LibXML ();
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 1 my $NS_XMLDSIG = 'http://www.w3.org/2000/09/xmldsig#';
28  
29 ####################################################################################################
30  
31 sub setup
32 0 ▶{
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
33 0 my ($class,$po,$version)=@_;
34 0 $po->ns({ 'mark' => 'urn:ietf:params:xml:ns:mark-1.0',
35 'signedMark' => 'urn:ietf:params:xml:ns:signedMark-1.0' });
36 0 return;
37 }
38  
39 0 ▶sub implements { return 'https://tools.ietf.org/html/rfc7848'; }
Subroutine implements: not called CC=1 SCAR=6.9
Pod undocumented
40  
41 1 my %xml2perl = ( trademark => 'trademark',
42 treatyOrStatute => 'treaty_statute',
43 court => 'court',
44 markName => 'mark_name',
45 goodsAndServices=> 'goods_services',
46 apId => 'application_id',
47 apDate => 'application_date',
48 regNum => 'registration_number',
49 regDate => 'registration_date',
50 exDate => 'expiration_date',
51 refNum => 'reference_number',
52 proDate => 'protection_date',
53 execDate => 'execution_date',
54 courtName => 'court_name',
55 );
56  
57 ####################################################################################################
58  
59 sub build_marks
60 0 ▶{
Subroutine build_marks: not called CC=6 SCAR=37.4
Pod undocumented
61 0 my ($po,$rd)=@_;
62 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('A ref array must be passed for marks, or a standalone ref hash for only one mark') unless defined $rd && (ref $rd eq 'ARRAY' || ref $rd eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rd and ref $rd eq "ARRAY" || ref $rd eq "HASH" 0 0 0
Condition0%0/6
defined $rd and ref $rd eq "ARRAY" || ref $rd eq "HASH"
!ll&&!rl&&r
000
ref $rd eq "ARRAY" or ref $rd eq "HASH"
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $rd and ref $rd eq "ARRAY" || ref $rd eq "HASH"
defined $rd ref $rd eq "ARRAY" ref $rd eq "HASH"
Truth table0%0/4
A and B or C
A= defined $rdB= ref $rd eq "ARRAY"C= ref $rd eq "HASH"
ABCresult
0XX0
1000
11X1
1011
63 0 my @r;
64 0 ▶ foreach my $m (ref $rd eq 'ARRAY' ? @$rd : $rd)
Branch: 1 branch
BranchTrueFalseTotal
ref $rd eq 'ARRAY' ? : 0 0 0
65 {
66 0 push @r,['mark:mark', { 'xmlns:mark' => $po->ns()->{'mark'}}, build_mark($m)];
67 }
68 0 return @r;
69 }
70  
71 sub build_mark
72 0 ▶{
Subroutine build_mark: not called CC=10 SCAR=47.0
Pod undocumented
73 0 my ($rd)=@_;
74 0 my @r;
75  
76 0 ▶ Net::DRI::Exception::usererr_invalid_parameters() unless defined $rd && ref $rd eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rd and ref $rd eq "HASH" 0 0 0
Condition0%0/3
defined $rd and ref $rd eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $rd and ref $rd eq "HASH"
defined $rd ref $rd eq "HASH"
Truth table0%0/3
A and B
A= defined $rdB= ref $rd eq "HASH"
ABresult
0X0
100
111
77 0 my $type=$rd->{type};
78 0 ▶ $type='' unless defined $type;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 0 0 0
79  
80 0 ▶ if ($type eq 'trademark' || exists $rd->{jurisdiction})
Branch: 3 branches
BranchTrueFalseTotal
if ($type eq 'trademark' or exists $rd->{'jurisdiction'}) { } 0 0 0
elsif ($type eq 'treaty_statute' or exists $rd->{'protection'}) { } 0 0 0
elsif ($type eq 'court' or exists $rd->{'court_name'}) { } 0 0 0
Condition0%0/3
$type eq "trademark" or exists $rd->{"jurisdiction"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$type eq "trademark" or exists $rd->{"jurisdiction"}
$type eq "trademark" exists $rd->{"jurisdiction"}
Truth table0%0/3
A or B
A= $type eq "trademark"B= exists $rd->{"jurisdiction"}
ABresult
1X1
011
000
81 {
82 0 return _build_trademark($rd);
83 ▶ } elsif ($type eq 'treaty_statute' || exists $rd->{protection})
Condition0%0/3
$type eq "treaty_statute" or exists $rd->{"protection"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$type eq "treaty_statute" or exists $rd->{"protection"}
$type eq "treaty_statute" exists $rd->{"protection"}
Truth table0%0/3
A or B
A= $type eq "treaty_statute"B= exists $rd->{"protection"}
ABresult
1X1
011
000
84 {
85 0 return _build_treaty($rd);
86 ▶ } elsif ($type eq 'court' || exists $rd->{court_name})
Condition0%0/3
$type eq "court" or exists $rd->{"court_name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$type eq "court" or exists $rd->{"court_name"}
$type eq "court" exists $rd->{"court_name"}
Truth table0%0/3
A or B
A= $type eq "court"B= exists $rd->{"court_name"}
ABresult
1X1
011
000
87 {
88 0 return _build_court($rd);
89 } else
90 {
91 0 Net::DRI::Exception::usererr_invalid_parameters(qq{Unrecognized type "$type" of mark, and no "jurisdiction", "protection" or "court_name" element});
92 }
93 0 return;
94 }
95  
96 sub _build_addr
97 0 ▶{
Subroutine _build_addr: not called CC=15 SCAR=54.8
98 0 my ($contact)=@_;
99 0 my (@r,$v);
100  
101 0 $v=scalar $contact->street();
102 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Contact address must have from 1 to 3 street elements') unless defined $v && ref $v eq 'ARRAY' && @$v >=1 && @$v <= 3;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v and ref $v eq "ARRAY" and @$v >= 1 and @$v <= 3 0 0 0
Condition0%0/9
defined $v and ref $v eq "ARRAY" and @$v >= 1 and @$v <= 3
!ll&&!rl&&r
000
defined $v and ref $v eq "ARRAY" and @$v >= 1
!ll&&!rl&&r
000
defined $v and ref $v eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/4
defined $v and ref $v eq "ARRAY" and @$v >= 1 and @$v <= 3
defined $v ref $v eq "ARRAY" @$v >= 1 @$v <= 3
Truth table0%0/5
A and B and C and D
A= defined $vB= ref $v eq "ARRAY"C= @$v >= 1D= @$v <= 3
ABCDresult
0XXX0
10XX0
110X0
11100
11111
103 0 push @r,map { ['mark:street',$_] } @$v;
104  
105 0 $v=scalar $contact->city();
106 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Contact address must have a city') unless defined $v;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 0 0 0
107 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Contact address city must be an XML token string') unless Net::DRI::Util::xml_is_token($v);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($v) 0 0 0
108 0 push @r,['mark:city',$v];
109  
110 0 $v=scalar $contact->sp();
111 0 ▶ if (defined $v && length $v)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $v and length $v) 0 0 0
Condition0%0/3
defined $v and length $v
!ll&&!rl&&r
000
MC/DC0%0/2
defined $v and length $v
defined $v length $v
Truth table0%0/3
A and B
A= defined $vB= length $v
ABresult
0X0
100
111
112 {
113 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Contact address sp must be an XML token string') unless Net::DRI::Util::xml_is_token($v);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($v) 0 0 0
114 0 push @r,['mark:sp',$v];
115 }
116  
117 0 $v=scalar $contact->pc();
118 0 ▶ if (defined $v && length $v)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $v and length $v) 0 0 0
Condition0%0/3
defined $v and length $v
!ll&&!rl&&r
000
MC/DC0%0/2
defined $v and length $v
defined $v length $v
Truth table0%0/3
A and B
A= defined $vB= length $v
ABresult
0X0
100
111
119 {
120 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Contact address pc must be an XML token string with 16 characters or less') unless Net::DRI::Util::xml_is_token($v,0,16);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($v, 0, 16) 0 0 0
121 0 push @r,['mark:pc',$v];
122 }
123  
124 0 $v=scalar $contact->cc();
125 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Contact address must have a cc') unless defined $v;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 0 0 0
126 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Contact address cc must be an XML token string of 2 characters') unless Net::DRI::Util::xml_is_token($v,2,2);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($v, 2, 2) 0 0 0
127 0 push @r,['mark:cc',$v];
128  
129 0 return @r;
130 }
131  
132 sub _build_contact
133 0 ▶{
Subroutine _build_contact: not called CC=24 SCAR=64.0
134 0 my ($type,$contact)=@_;
135  
136 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Element must be contact object, not: '.$contact) unless Net::DRI::Util::isa_contact($contact);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::isa_contact($contact) 0 0 0
137  
138 0 my (@r,$v);
139  
140 0 $v=scalar $contact->name();
141 0 ▶ if (defined $v && length $v)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $v and length $v) { } 0 0 0
Condition0%0/3
defined $v and length $v
!ll&&!rl&&r
000
MC/DC0%0/2
defined $v and length $v
defined $v length $v
Truth table0%0/3
A and B
A= defined $vB= length $v
ABresult
0X0
100
111
142 {
143 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Name of contact must be an XML token string, not: '.$v) unless Net::DRI::Util::xml_is_token($v);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($v) 0 0 0
144 0 push @r,['mark:name',$v];
145 } else
146 {
147 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Name is mandatory for a contact') if ($type eq 'contact');
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "contact" 0 0 0
148 }
149  
150 0 $v=scalar $contact->org();
151 0 ▶ if (defined $v && length $v)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $v and length $v) 0 0 0
Condition0%0/3
defined $v and length $v
!ll&&!rl&&r
000
MC/DC0%0/2
defined $v and length $v
defined $v length $v
Truth table0%0/3
A and B
A= defined $vB= length $v
ABresult
0X0
100
111
152 {
153 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Org of contact must be an XML token string, not: '.$v) unless Net::DRI::Util::xml_is_token($v);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($v) 0 0 0
154 0 push @r,['mark:org',$v];
155 }
156  
157 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('holder must have a name or org') if $type eq 'holder' && ! @r;
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "holder" and not @r 0 0 0
Condition0%0/3
$type eq "holder" and not @r
!ll&&!rl&&r
000
MC/DC0%0/2
$type eq "holder" and not @r
$type eq "holder" not @r
Truth table0%0/3
A and not(B)
A= $type eq "holder"B= not @r
ABresult
0X0
100
111
158  
159 0 push @r,['mark:addr',_build_addr($contact)];
160  
161 0 $v=$contact->voice();
162 0 ▶ if (defined $v && length $v)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $v and length $v) { } 0 0 0
Condition0%0/3
defined $v and length $v
!ll&&!rl&&r
000
MC/DC0%0/2
defined $v and length $v
defined $v length $v
Truth table0%0/3
A and B
A= defined $vB= length $v
ABresult
0X0
100
111
163 {
164 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Voice of contact must be an XML token string verifying pattern "(\+[0-9]{1,3}\.[0-9]{1,14})?"') unless Net::DRI::Util::xml_is_token($v,0,17) && $v=~m/^\+[0-9]{1,3}\.[0-9]{1,14}$/;
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($v, 0, 17) and $v =~ /^\+[0-9]{1,3}\.[0-9]{1,14}$/ 0 0 0
Condition0%0/3
Net::DRI::Util::xml_is_token($v, 0, 17) and $v =~ /^\+[0-9]{1,3}\.[0-9]{1,14}$/
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::xml_is_token($v, 0, 17) and $v =~ /^\+[0-9]{1,3}\.[0-9]{1,14}$/
Net::DRI::Util::xml_is_token($v, 0, 17) $v =~ /^\+[0-9]{1,3}\.[0-9]{1,14}$/
Truth table0%0/3
A and B
A= Net::DRI::Util::xml_is_token($v, 0, 17)B= $v =~ /^\+[0-9]{1,3}\.[0-9]{1,14}$/
ABresult
0X0
100
111
165 0 push @r,Net::DRI::Protocol::EPP::Util::build_tel('mark:voice',$v);
166 } else
167 {
168 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Voice is mandatory for a contact') if ($type eq 'contact');
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "contact" 0 0 0
169 }
170  
171 0 $v=$contact->fax();
172 0 ▶ if (defined $v && length $v)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $v and length $v) 0 0 0
Condition0%0/3
defined $v and length $v
!ll&&!rl&&r
000
MC/DC0%0/2
defined $v and length $v
defined $v length $v
Truth table0%0/3
A and B
A= defined $vB= length $v
ABresult
0X0
100
111
173 {
174 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Fax of contact must be an XML token string verifying pattern "(\+[0-9]{1,3}\.[0-9]{1,14})?"') unless Net::DRI::Util::xml_is_token($v,0,17) && $v=~m/^\+[0-9]{1,3}\.[0-9]{1,14}$/;
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($v, 0, 17) and $v =~ /^\+[0-9]{1,3}\.[0-9]{1,14}$/ 0 0 0
Condition0%0/3
Net::DRI::Util::xml_is_token($v, 0, 17) and $v =~ /^\+[0-9]{1,3}\.[0-9]{1,14}$/
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::xml_is_token($v, 0, 17) and $v =~ /^\+[0-9]{1,3}\.[0-9]{1,14}$/
Net::DRI::Util::xml_is_token($v, 0, 17) $v =~ /^\+[0-9]{1,3}\.[0-9]{1,14}$/
Truth table0%0/3
A and B
A= Net::DRI::Util::xml_is_token($v, 0, 17)B= $v =~ /^\+[0-9]{1,3}\.[0-9]{1,14}$/
ABresult
0X0
100
111
175 0 push @r,Net::DRI::Protocol::EPP::Util::build_tel('mark:fax',$v);
176 }
177  
178 0 $v=$contact->email();
179 0 ▶ if (defined $v && length $v)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $v and length $v) { } 0 0 0
Condition0%0/3
defined $v and length $v
!ll&&!rl&&r
000
MC/DC0%0/2
defined $v and length $v
defined $v length $v
Truth table0%0/3
A and B
A= defined $vB= length $v
ABresult
0X0
100
111
180 {
181 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Email of contact must be an XML token string with at least 1 character, not: '.$v) unless Net::DRI::Util::xml_is_token($v,1);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($v, 1) 0 0 0
182 0 push @r,['mark:email',$v];
183 } else
184 {
185 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Email is mandatory for a contact') if ($type eq 'contact');
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "contact" 0 0 0
186 }
187  
188 0 return @r;
189 }
190  
191 sub _add_token
192 0 ▶{
Subroutine _add_token: not called CC=6 SCAR=37.4
193 0 my ($rd,$key,$optional)=@_;
194 0 ▶ my $pkey=exists $xml2perl{$key} ? $xml2perl{$key} : $key;
Branch: 1 branch
BranchTrueFalseTotal
exists $xml2perl{$key} ? : 0 0 0
195 0 ▶ if (Net::DRI::Util::has_key($rd,$pkey))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_key($rd, $pkey)) { } 0 0 0
196 {
197 0 ▶ Net::DRI::Exception::usererr_invalid_parameters(qq{Value for "$pkey" key must be an XML token string}) unless Net::DRI::Util::xml_is_token($rd->{$pkey});
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($rd->{$pkey}) 0 0 0
198 0 return ['mark:'.$key,$rd->{$pkey}];
199 } else
200 {
201 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters(qq{"$pkey" key must exist}) unless (defined $optional && $optional);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $optional and $optional 0 0 0
Condition0%0/3
defined $optional and $optional
!ll&&!rl&&r
000
MC/DC0%0/2
defined $optional and $optional
defined $optional $optional
Truth table0%0/3
A and B
A= defined $optionalB= $optional
ABresult
0X0
100
111
202 0 return;
203 }
204 }
205  
206 sub _add_datetime
207 0 ▶{
Subroutine _add_datetime: not called CC=6 SCAR=37.4
208 0 my ($rd,$key,$optional)=@_;
209 0 ▶ my $pkey=exists $xml2perl{$key} ? $xml2perl{$key} : $key;
Branch: 1 branch
BranchTrueFalseTotal
exists $xml2perl{$key} ? : 0 0 0
210 0 ▶ if (Net::DRI::Util::has_key($rd,$pkey))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_key($rd, $pkey)) { } 0 0 0
211 {
212 0 ▶ Net::DRI::Exception::usererr_invalid_parameters(qq{Value for "$pkey" key must be a DateTime object}) unless Net::DRI::Util::is_class($rd->{$pkey},'DateTime');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::is_class($rd->{$pkey}, "DateTime") 0 0 0
213 0 return ['mark:'.$key,Net::DRI::Util::dto2zstring($rd->{$pkey})];
214 } else
215 {
216 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters(qq{"$pkey" key must exist}) unless (defined $optional && $optional);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $optional and $optional 0 0 0
Condition0%0/3
defined $optional and $optional
!ll&&!rl&&r
000
MC/DC0%0/2
defined $optional and $optional
defined $optional $optional
Truth table0%0/3
A and B
A= defined $optionalB= $optional
ABresult
0X0
100
111
217 0 return;
218 }
219 }
220  
221 sub _build_common1
222 0 ▶{
Subroutine _build_common1: not called CC=11 SCAR=48.8
223 0 my ($rd)=@_;
224 0 my @r;
225  
226 0 push @r,_add_token($rd,'id');
227 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Value for "id" key must match pattern "\d+-\d+"') unless $rd->{id}=~m/^\d+-\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $rd->{"id"} =~ /^\d+-\d+$/ 0 0 0
228  
229 0 push @r,_add_token($rd,'markName');
230  
231 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('"contact" key must exist') unless Net::DRI::Util::has_key($rd,'contact');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "contact") 0 0 0
232 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Value for "contact" key must be a ContactSet object') unless Net::DRI::Util::isa_contactset($rd->{contact});
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::isa_contactset($rd->{"contact"}) 0 0 0
233 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Value for "contact" key must have at least one contact of type holder_owner, holder_assignee or holder_licensee') unless grep { /^(?:holder_owner|holder_assignee|holder_licensee)$/ } $rd->{contact}->types();
Branch: 1 branch
BranchTrueFalseTotal
unless grep {/^(?:holder_owner|holder_assignee|holder_licensee)$/;} $rd->{"contact"}->types 0 0 0
234 0 foreach my $type (qw/owner assignee licensee/)
235 {
236 0 my @o=$rd->{contact}->get('holder_'.$type);
237 0 ▶ next unless @o;
Branch: 1 branch
BranchTrueFalseTotal
unless @o 0 0 0
238 0 foreach my $c (@o)
239 {
240 0 push @r,['mark:holder',{ entitlement => $type },_build_contact('holder',$c)];
241 }
242 }
243 0 foreach my $type (qw/owner agent thirdparty/)
244 {
245 0 my @o=$rd->{contact}->get('contact_'.$type);
246 0 ▶ next unless @o;
Branch: 1 branch
BranchTrueFalseTotal
unless @o 0 0 0
247 0 foreach my $c (@o)
248 {
249 0 push @r,['mark:contact',{ type => $type },_build_contact('contact',$c)];
250 }
251 }
252  
253 0 return @r;
254 }
255  
256 sub _build_common2
257 0 ▶{
Subroutine _build_common2: not called CC=6 SCAR=37.4
258 0 my ($rd)=@_;
259 0 my @r;
260  
261 0 ▶ if (Net::DRI::Util::has_key($rd,'label'))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_key($rd, "label")) 0 0 0
262 {
263 0 ▶ foreach my $label (ref $rd->{label} eq 'ARRAY' ? @{$rd->{label}} : ($rd->{label}))
Branch: 1 branch
BranchTrueFalseTotal
ref $rd->{'label'} eq 'ARRAY' ? : 0 0 0
264 {
265 0 ▶ Net::DRI::Exception::usererr_invalid_parameters(qq{Label "$label" must be an XML token string from 1 to 63 characters}) unless Net::DRI::Util::xml_is_token($label,1,63);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($label, 1, 63) 0 0 0
266 0 ▶ Net::DRI::Exception::usererr_invalid_parameters(qq{Label "$label" must pass regex "[a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?"}) unless $label=~m/^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $label =~ /^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/ 0 0 0
267 0 push @r,['mark:label',$label];
268 }
269 }
270  
271 0 push @r,_add_token($rd,'goodsAndServices');
272  
273 0 return @r;
274 }
275  
276 sub _build_common3
277 0 ▶{
Subroutine _build_common3: not called CC=1 SCAR=6.9
278 0 my ($rd)=@_;
279 0 my @r;
280  
281 0 push @r,_add_token($rd,'refNum');
282 0 push @r,_add_datetime($rd,'proDate');
283  
284 0 return @r;
285 }
286  
287 sub _build_trademark
288 0 ▶{
Subroutine _build_trademark: not called CC=6 SCAR=37.4
289 0 my ($rd)=@_;
290 0 my @r;
291  
292 0 push @r,_build_common1($rd); ## id/markName/holder/contact
293  
294 0 push @r,_add_token($rd,'jurisdiction');
295 0 ▶ Net::DRI::Exception::usererr_invalid_parameters(qq{Value for "jurisdiction" key must be an XML token string of 2 characters}) unless Net::DRI::Util::xml_is_token($rd->{jurisdiction},2,2);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($rd->{"jurisdiction"}, 2, 2) 0 0 0
296  
297 0 ▶ if (Net::DRI::Util::has_key($rd,'class'))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_key($rd, "class")) 0 0 0
298 {
299 0 ▶ foreach my $class (ref $rd->{class} eq 'ARRAY' ? @{$rd->{class}} : ($rd->{class}))
Branch: 1 branch
BranchTrueFalseTotal
ref $rd->{'class'} eq 'ARRAY' ? : 0 0 0
300 {
301 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Class must be an integer, not: '.$class) unless $class=~m/^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $class =~ /^\d+$/ 0 0 0
302 0 push @r,['mark:class',$class];
303 }
304 }
305  
306 0 push @r,_build_common2($rd); ## label/goodsAndServices
307  
308 0 push @r,_add_token($rd,'apId',1);
309 0 push @r,_add_datetime($rd,'apDate',1);
310 0 push @r,_add_token($rd,'regNum');
311 0 push @r,_add_datetime($rd,'regDate');
312 0 push @r,_add_datetime($rd,'exDate',1);
313  
314 0 return ['mark:trademark',@r];
315 }
316  
317 sub _build_treaty
318 0 ▶{
Subroutine _build_treaty: not called CC=10 SCAR=47.0
319 0 my ($rd)=@_;
320 0 my @r;
321  
322 0 push @r,_build_common1($rd); ## id/markName/holder/contact
323  
324 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Key "protection" must exist') unless Net::DRI::Util::has_key($rd,'protection');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "protection") 0 0 0
325 0 ▶ foreach my $rprot (ref $rd->{protection} eq 'ARRAY' ? @{$rd->{protection}} : ($rd->{protection}))
Branch: 1 branch
BranchTrueFalseTotal
ref $rd->{'protection'} eq 'ARRAY' ? : 0 0 0
326 {
327 0 my @pro;
328 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Each protection item must be a ref hash, not: '.$rprot) unless ref $rprot eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $rprot eq "HASH" 0 0 0
329  
330 0 push @r,_add_token($rprot,'cc');
331 0 ▶ Net::DRI::Exception::usererr_invalid_parameters(qq{Value for "cc" key must be an XML token string of 2 characters}) unless Net::DRI::Util::xml_is_token($rprot->{cc},2,2);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($rprot->{"cc"}, 2, 2) 0 0 0
332  
333 0 push @r,_add_token($rprot,'region',1);
334  
335 0 ▶ if (Net::DRI::Util::has_key($rprot,'ruling'))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_key($rprot, "ruling")) 0 0 0
336 {
337 0 ▶ foreach my $ruling (ref $rprot->{ruling} eq 'ARRAY' ? @{$rprot->{ruling}} : ($rprot->{ruling}))
Branch: 1 branch
BranchTrueFalseTotal
ref $rprot->{'ruling'} eq 'ARRAY' ? : 0 0 0
338 {
339 0 push @r,_add_token({ ruling => $ruling },'ruling');
340 0 ▶ Net::DRI::Exception::usererr_invalid_parameters(qq{Each "ruling" item must be an XML token string of 2 characters}) unless Net::DRI::Util::xml_is_token($ruling,2,2);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($ruling, 2, 2) 0 0 0
341 }
342 }
343  
344 0 push @r,['mark:protection',@pro];
345 }
346  
347 0 push @r,_build_common2($rd); ## label/goodsAndServices
348 0 push @r,_build_common3($rd); ## refNum/proDate
349  
350 0 push @r,_add_token($rd,'title');
351 0 push @r,_add_datetime($rd,'execDate');
352  
353 0 return ['mark:treatyOrStatute',@r];
354 }
355  
356 sub _build_court
357 0 ▶{
Subroutine _build_court: not called CC=5 SCAR=34.0
358 0 my ($rd)=@_;
359 0 my @r;
360  
361 0 push @r,_build_common1($rd); ## id/markName/holder/contact
362 0 push @r,_build_common2($rd); ## label/goodsAndServices
363 0 push @r,_build_common3($rd); ## refNum/proDate
364  
365 0 push @r,_add_token($rd,'cc');
366 0 ▶ Net::DRI::Exception::usererr_invalid_parameters(qq{Value for "cc" key must be an XML token string of 2 characters}) unless Net::DRI::Util::xml_is_token($rd->{cc},2,2);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($rd->{"cc"}, 2, 2) 0 0 0
367  
368 0 ▶ if (Net::DRI::Util::has_key($rd,'region'))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_key($rd, "region")) 0 0 0
369 {
370 0 ▶ foreach my $region (ref $rd->{region} eq 'ARRAY' ? @{$rd->{region}} : ($rd->{region}))
Branch: 1 branch
BranchTrueFalseTotal
ref $rd->{'region'} eq 'ARRAY' ? : 0 0 0
371 {
372 0 push @r,_add_token({ region => $region },'region');
373 }
374 }
375  
376 0 push @r,_add_token($rd,'courtName');
377  
378 0 return ['mark:court',@r];
379 }
380  
381 ####################################################################################################
382  
383 sub parse_tel
384 0 ▶{
Subroutine parse_tel: not called CC=2 SCAR=17.9
Pod undocumented
385 0 my ($node)=@_;
386 0 my $r=$node->textContent();
387 0 ▶ $r.='x'.$node->getAttribute('x') if $node->hasAttribute('x');
Branch: 1 branch
BranchTrueFalseTotal
if $node->hasAttribute("x") 0 0 0
388 0 return $r;
389 }
390  
391 sub parse_contact
392 0 ▶{
Subroutine parse_contact: not called CC=9 SCAR=45.0
Pod undocumented
393 0 my ($po,$start)=@_;
394 0 my $contact=$po->create_local_object('contact');
395  
396 0 foreach my $el (Net::DRI::Util::xml_list_children($start))
397 {
398 0 my ($name,$node)=@$el;
399 0 ▶ if ($name=~m/^(?:name|org|email)$/)
Branch: 4 branches
BranchTrueFalseTotal
if ($name =~ /^(?:name|org|email)$/) { } 0 0 0
elsif ($name =~ /^(?:voice|fax)$/) { } 0 0 0
elsif ($name eq 'addr') { } 0 0 0
elsif ($name =~ /^(?:voice|fax)$/) { } 0 0 0
400 {
401 0 $contact->$name($node->textContent());
402 } elsif ($name=~m/^(?:voice|fax)$/)
403 {
404 0 $contact->$name(parse_tel($node));
405 } elsif ($name eq 'addr')
406 {
407 0 my @street;
408 0 foreach my $subel (Net::DRI::Util::xml_list_children($node))
409 {
410 0 my ($addrname,$addrnode)=@$subel;
411 0 ▶ if ($addrname eq 'street')
Branch: 2 branches
BranchTrueFalseTotal
if ($addrname eq 'street') { } 0 0 0
elsif ($addrname =~ /^(?:city|sp|pc|cc)$/) { } 0 0 0
412 {
413 0 push @street,$addrnode->textContent();
414 } elsif ($addrname=~m/^(?:city|sp|pc|cc)$/)
415 {
416 0 $contact->$addrname($addrnode->textContent());
417 }
418 }
419 0 $contact->street(\@street);
420 } elsif ($name=~m/^(?:voice|fax)$/)
421 {
422 0 $contact->$name(Net::DRI::Protocol::EPP::Util::parse_tel($node));
423 }
424 }
425  
426 0 return $contact;
427 }
428  
429 sub parse_mark
430 0 ▶{
Subroutine parse_mark: not called CC=21 SCAR=61.4
Pod undocumented
431 0 my ($po,$start)=@_;
432 0 my @marks;
433  
434 0 foreach my $el (Net::DRI::Util::xml_list_children($start))
435 {
436 0 my ($name,$node)=@$el;
437 0 ▶ if ($name=~m/^(?:trademark|treatyOrStatute|court)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^(?:trademark|treatyOrStatute|court)$/) 0 0 0
438 {
439 0 my %m=(type => $xml2perl{$name});
440 0 my (@class,@label,@protection,@region);
441 0 my $cs=$po->create_local_object('contactset');
442 0 foreach my $subel (Net::DRI::Util::xml_list_children($node))
443 {
444 0 my ($mname,$mnode)=@$subel;
445 0 ▶ if ($mname=~m/^(id|markName|jurisdiction|goodsAndServices|apId|regNum|refNum|title|cc|courtName)$/)
Branch: 8 branches
BranchTrueFalseTotal
if ($mname =~ /^(id|markName|jurisdiction|goodsAndServices|apId|regNum|refNum|title|cc|courtName)$/) { } 0 0 0
elsif ($mname eq 'holder') { } 0 0 0
elsif ($mname eq 'contact') { } 0 0 0
elsif ($mname eq 'class') { } 0 0 0
elsif ($mname eq 'label') { } 0 0 0
elsif ($mname =~ /^(?:apDate|regDate|exDate|proDate|execDate)$/) { } 0 0 0
elsif ($mname eq 'protection') { } 0 0 0
elsif ($mname eq 'region') { } 0 0 0
446 {
447 0 ▶ $m{exists $xml2perl{$mname} ? $xml2perl{$mname} : $mname}=$mnode->textContent();
Branch: 1 branch
BranchTrueFalseTotal
exists $xml2perl{$mname} ? : 0 0 0
448 } elsif ($mname eq 'holder')
449 {
450 0 my $type='holder_'.$mnode->getAttribute('entitlement'); ## owner, assignee, licensee
451 0 $cs->add(parse_contact($po,$mnode),$type);
452 } elsif ($mname eq 'contact')
453 {
454 0 my $type='contact_'.$mnode->getAttribute('type'); ## owner, agent, thirdparty
455 0 $cs->add(parse_contact($po,$mnode),$type);
456 } elsif ($mname eq 'class')
457 {
458 0 push @class,$mnode->textContent();
459 } elsif ($mname eq 'label')
460 {
461 0 push @label,$mnode->textContent();
462 } elsif ($mname=~m/^(?:apDate|regDate|exDate|proDate|execDate)$/)
463 {
464 0 $m{$xml2perl{$mname}}=$po->parse_iso8601($mnode->textContent());
465 } elsif ($mname eq 'protection')
466 {
467 0 my %p;
468 0 foreach my $pel (Net::DRI::Util::xml_list_children($mnode))
469 {
470 0 my ($pname,$pnode)=@$pel;
471 0 ▶ if ($pname=~m/^(cc|region)$/)
Branch: 2 branches
BranchTrueFalseTotal
if ($pname =~ /^(cc|region)$/) { } 0 0 0
elsif ($pname eq 'ruling') { } 0 0 0
472 {
473 0 $p{$pname}=$pnode->textContent();
474 } elsif ($pname eq 'ruling')
475 {
476 0 push @{$p{ruling}},$pnode->textContent();
477 }
478 }
479 0 push @protection,\%p;
480 } elsif ($mname eq 'region')
481 {
482 0 push @region,$mnode->textContent();
483 }
484 }
485 0 $m{contact}=$cs;
486 0 ▶ $m{class}=\@class if @class;
Branch: 1 branch
BranchTrueFalseTotal
if @class 0 0 0
487 0 ▶ $m{label}=\@label if @label;
Branch: 1 branch
BranchTrueFalseTotal
if @label 0 0 0
488 0 ▶ $m{protection}=\@protection if @protection;
Branch: 1 branch
BranchTrueFalseTotal
if @protection 0 0 0
489 0 ▶ $m{region}=\@region if @region;
Branch: 1 branch
BranchTrueFalseTotal
if @region 0 0 0
490 0 ▶ if (exists $m{goods_services})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $m{"goods_services"}) 0 0 0
491 {
492 0 $m{goods_services}=~s/\n +/ /g;
493 0 $m{goods_services}=~s/ +$//s;
494 }
495 0 push @marks,\%m;
496 }
497 }
498  
499 0 return \@marks;
500 }
501  
502 sub lined_content
503 0 ▶{
Subroutine lined_content: not called CC=2 SCAR=17.9
Pod undocumented
504 0 my ($node,$signs,@keys)=@_;
505 0 my $r=Net::DRI::Util::xml_traverse($node,$signs,@keys);
506 0 ▶ return unless defined $r;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $r 0 0 0
507 0 $r=$r->textContent();
508 0 $r=~s/\s+//g;
509 0 return $r;
510 }
511  
512 sub parse_signed_mark
513 0 ▶{
Subroutine parse_signed_mark: not called CC=13 SCAR=52.0
Pod undocumented
514 0 my ($po,$start,$xmlsec)=@_;
515 0 my %smark;
516  
517 0 foreach my $el (Net::DRI::Util::xml_list_children($start))
518 {
519 0 my ($name,$node)=@$el;
520 0 ▶ if ($name eq 'id')
Branch: 6 branches
BranchTrueFalseTotal
if ($name eq 'id') { } 0 0 0
elsif ($name eq 'issuerInfo') { } 0 0 0
elsif ($name eq 'notBefore') { } 0 0 0
elsif ($name eq 'notAfter') { } 0 0 0
elsif ($name eq 'mark') { } 0 0 0
elsif ($name eq 'Signature') { } 0 0 0
521 {
522 0 $smark{id}=$node->textContent();
523 } elsif ($name eq 'issuerInfo')
524 {
525 0 my %issuer=(id => $node->getAttribute('issuerID'));
526 0 foreach my $iel (Net::DRI::Util::xml_list_children($node))
527 {
528 0 my ($iname,$inode)=@$iel;
529 0 ▶ if ($iname=~m/^(?:org|email|url)$/)
Branch: 2 branches
BranchTrueFalseTotal
if ($iname =~ /^(?:org|email|url)$/) { } 0 0 0
elsif ($iname eq 'voice') { } 0 0 0
530 {
531 0 $issuer{$iname}=$inode->textContent();
532 } elsif ($iname eq 'voice')
533 {
534 0 $issuer{$iname}=parse_tel($inode);
535 }
536 }
537 0 $smark{issuer}=\%issuer;
538 } elsif ($name eq 'notBefore')
539 {
540 0 $smark{'creation_date'}=$po->parse_iso8601($node->textContent());
541 } elsif ($name eq 'notAfter')
542 {
543 0 $smark{'expiration_date'}=$po->parse_iso8601($node->textContent());
544 } elsif ($name eq 'mark')
545 {
546 0 $smark{mark}=parse_mark($po,$node);
547 } elsif ($name eq 'Signature')
548 {
549 0 my %s=(id => $start->getAttribute('id'));
550 0 $s{'value'}=lined_content($node,$NS_XMLDSIG,qw/SignatureValue/);
551 ## TODO: handle other algorithms
552 0 $s{'key'}={ algorithm => 'rsa',
553 x509_certificate => lined_content($node,$NS_XMLDSIG,qw/KeyInfo X509Data X509Certificate/),
554 };
555 0 ▶ $s{'validated'}=(defined $xmlsec && $xmlsec) ? _validate_xmldsig($start) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $xmlsec && $xmlsec ? : 0 0 0
Condition0%0/3
defined $xmlsec and $xmlsec
!ll&&!rl&&r
000
MC/DC0%0/2
defined $xmlsec and $xmlsec
defined $xmlsec $xmlsec
Truth table0%0/3
A and B
A= defined $xmlsecB= $xmlsec
ABresult
0X0
100
111
556 0 $smark{'signature'}=\%s;
557 }
558 }
559 0 return \%smark;
560 }
561  
562 sub _validate_xmldsig
563 0 ▶{
Subroutine _validate_xmldsig: not called CC=9 SCAR=45.0
564 0 my ($xml,$rs)=@_;
565  
566 0 require XML::LibXML::XPathContext;
567 0 require Digest::SHA;
568 0 require Crypt::OpenSSL::X509;
569 0 require Crypt::OpenSSL::RSA;
570 0 require MIME::Base64;
571  
572 0 my $xpc=XML::LibXML::XPathContext->new();
573 0 $xpc->registerNs('ds', $NS_XMLDSIG);
574  
575 0 foreach my $node ($xpc->findnodes('//ds:Reference',$xml))
576 {
577 0 my $for=$node->getAttribute('URI');
578 0 $for=~s/^#//;
579 0 my $cnode=$xpc->findnodes("//*[\@id='${for}' or \@Id='${for}']",$xml);
580 0 ▶ return 0 unless $cnode->size() == 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $cnode->size == 1 0 0 0
581  
582 0 $cnode=$cnode->get_node(1); ## node on which we perform the digest operation
583  
584 0 my %algos=map { $_->getAttribute('Algorithm') => 1 } $xpc->findnodes('ds:Transforms/ds:Transform',$node);
585 0 ▶ return 0 unless exists $algos{'http://www.w3.org/2001/10/xml-exc-c14n#'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $algos{"http://www.w3.org/2001/10/xml-exc-c14n#"} 0 0 0
586  
587 0 ▶ my $xmlstring=$cnode->toStringEC14N(0,exists $algos{$NS_XMLDSIG.'enveloped-signature'} ? q{(. | .//node() | .//@* | .//namespace::*)[not(self::comment() or ancestor-or-self::ds:Signature)]} : undef,$xpc);
Branch: 1 branch
BranchTrueFalseTotal
exists $algos{$NS_XMLDSIG . 'enveloped-signature'} ? : 0 0 0
588  
589 0 ▶ return 0 unless defined $xmlstring && $xpc->findnodes('ds:DigestValue',$node)->get_node(1)->textContent() eq _sha256b64padded($xmlstring);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $xmlstring and $xpc->findnodes("ds:DigestValue", $node)->get_node(1)->textContent eq _sha256b64padded($xmlstring) 0 0 0
Condition0%0/3
defined $xmlstring and $xpc->findnodes("ds:DigestValue", $node)->get_node(1)->textContent eq _sha256b64padded($xmlstring)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $xmlstring and $xpc->findnodes("ds:DigestValue", $node)->get_node(1)->textContent eq _sha256b64padded($xmlstring)
defined $xmlstring $xpc->findnodes("ds:DigestValue", $node)->get_node(1)->textContent eq _sha256b64padded($xmlstring)
Truth table0%0/3
A and B
A= defined $xmlstringB= $xpc->findnodes("ds:DigestValue", $node)->get_node(1)->textContent eq _sha256b64padded($xmlstring)
ABresult
0X0
100
111
590 }
591  
592 0 my $cert=$xpc->findnodes('//ds:X509Certificate',$xml)->get_node(1)->textContent();
593 0 $cert=~s/ /\n/g;
594 0 my $certobj=Crypt::OpenSSL::X509->new_from_string("-----BEGIN CERTIFICATE-----\n".$cert."\n-----END CERTIFICATE-----", Crypt::OpenSSL::X509::FORMAT_PEM());
595 0 my $key=Crypt::OpenSSL::RSA->new_public_key($certobj->pubkey());
596 0 $key->use_sha256_hash();
597  
598 0 my $xmlsi=$xpc->find('//ds:SignedInfo',$xml)->get_node(1);
599 0 $xmlsi->setNamespace($NS_XMLDSIG,'ds',0);
600 0 my $sigval=$xpc->findnodes('//ds:SignatureValue',$xmlsi)->get_node(1)->textContent();
601 0 $sigval=~s!\s+!!g;
602 0 my $verify=$key->verify($xmlsi->toStringEC14N(0), MIME::Base64::decode_base64($sigval));
603 0 ▶ return (defined $verify && $verify) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $verify && $verify ? : 0 0 0
Condition0%0/3
defined $verify and $verify
!ll&&!rl&&r
000
MC/DC0%0/2
defined $verify and $verify
defined $verify $verify
Truth table0%0/3
A and B
A= defined $verifyB= $verify
ABresult
0X0
100
111
604 }
605  
606 sub _sha256b64padded
607 0 ▶{
Subroutine _sha256b64padded: not called CC=2 SCAR=17.9
608 0 my ($in)=@_;
609 0 my $out = Digest::SHA::sha256_base64($in);
610 0 ▶ while (length($out) % 4) { $out .= '='; }
Branch: 1 branch
BranchTrueFalseTotal
if (length($out) % 4) 0 0 0
611 0 return $out;
612 }
613  
614 sub parse_encoded_signed_mark
615 0 ▶{
Subroutine parse_encoded_signed_mark: not called CC=5 SCAR=34.0
Pod undocumented
616 0 my ($po,$start,$xmlsec)=@_;
617 0 my $content;
618  
619 0 ▶ if (ref $start)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $start) { } 0 0 0
620 {
621 0 ▶ my $encoding=$start->hasAttribute('encoding') ? $start->getAttribute('encoding') : 'base64';
Branch: 1 branch
BranchTrueFalseTotal
$start->hasAttribute('encoding') ? : 0 0 0
622 0 ▶ Net::DRI::Exception::err_invalid_parameter('For encoded signed mark, only base64 encoding is supported') unless $encoding eq 'base64';
Branch: 1 branch
BranchTrueFalseTotal
unless $encoding eq "base64" 0 0 0
623 0 $content=$start->textContent();
624 } else
625 {
626 0 my @a=grep { /-----BEGIN ENCODED SMD-----/ .. /-----END ENCODED SMD-----/ } split(/\n/,$start);
627 0 $content=join("\n",@a[1..($#a-1)]);
628 }
629  
630 0 require MIME::Base64;
631 0 my $xml=MIME::Base64::decode_base64($content);
632 0 $xml=Encode::decode('UTF-8',$xml,Encode::FB_CROAK | Encode::LEAVE_SRC);
633 0 my $root=XML::LibXML->load_xml(no_cdata => 1, no_blanks => 1, no_network => 1, string => $xml)->documentElement();
634 0 ▶ Net::DRI::Exception::err_invalid_parameter('Decoding should give a signedMark root element') unless $root->localname() eq 'signedMark';
Branch: 1 branch
BranchTrueFalseTotal
unless $root->localname eq "signedMark" 0 0 0
635  
636 0 return parse_signed_mark($po,$root,$xmlsec);
637 }
638  
639 ####################################################################################################
640 1 1;
641  
642 __END__
« DRI/Protocol/EPP/Extensions/TCI/Domain.pm ↑ Summary DRI/Protocol/EPP/Extensions/Nomulus/Allocate.pm »