line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## Domain Registry Interface, EPP E.164 Validation (RFC5076) |
2
|
|
|
|
|
|
|
## |
3
|
|
|
|
|
|
|
## Copyright (c) 2008,2009,2013 Patrick Mevzek . 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::E164Validation; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
654
|
use utf8; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
18
|
1
|
|
|
1
|
|
23
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
14
|
|
19
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
21
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
3
|
use Net::DRI::Util; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
16
|
|
22
|
1
|
|
|
1
|
|
3
|
use Net::DRI::Exception; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
1013
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $NS='urn:ietf:params:xml:ns:e164val-1.0'; |
25
|
|
|
|
|
|
|
our @VALIDATION_MODULES=qw/RFC5076/; ## modules to handle validation information, override this variable to use other validation modules |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=pod |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 NAME |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Net::DRI::Protocol::EPP::Extensions::E164Validation - EPP E.164 Validation (RFC5076) for Net::DRI |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Please see the README file for details. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SUPPORT |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
For now, support questions should be sent to: |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Enetdri@dotandco.comE |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Please also see the SUPPORT file in the distribution. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SEE ALSO |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Ehttp://www.dotandco.com/services/software/Net-DRI/E |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 AUTHOR |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Patrick Mevzek, Enetdri@dotandco.comE |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 COPYRIGHT |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Copyright (c) 2008,2009,2013 Patrick Mevzek . |
56
|
|
|
|
|
|
|
All rights reserved. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
59
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
60
|
|
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or |
61
|
|
|
|
|
|
|
(at your option) any later version. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
See the LICENSE file that comes with this distribution for more details. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#################################################################################################### |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub register_commands |
70
|
|
|
|
|
|
|
{ |
71
|
0
|
|
|
0
|
0
|
|
my ($class,$version)=@_; |
72
|
0
|
|
|
|
|
|
my %tmp=( |
73
|
|
|
|
|
|
|
info => [ undef, \&info_parse ], |
74
|
|
|
|
|
|
|
create => [ \&create, undef ], |
75
|
|
|
|
|
|
|
renew => [ \&renew, undef ], |
76
|
|
|
|
|
|
|
transfer_request => [ \&transfer_request, undef ], |
77
|
|
|
|
|
|
|
update => [ \&update, undef ], |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
load_validation_modules(); |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
return { 'domain' => \%tmp }; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
0
|
0
|
|
sub capabilities_add { return ('domain_update','e164_validation_information',['add','del','set']); } |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
our %VAL; |
88
|
|
|
|
|
|
|
sub load_validation_modules ## §4.4 §4.5 |
89
|
|
|
|
|
|
|
{ |
90
|
0
|
|
|
0
|
0
|
|
foreach my $mod (@VALIDATION_MODULES) |
91
|
|
|
|
|
|
|
{ |
92
|
0
|
0
|
|
|
|
|
my $class=($mod=~m/::/)? $mod : 'Net::DRI::Protocol::EPP::Extensions::E164Validation::'.$mod; |
93
|
0
|
|
|
|
|
|
Net::DRI::Util::load_module($class,'protocol/epp_e164validation'); |
94
|
0
|
|
|
|
|
|
my ($uri)=$class->load(); |
95
|
0
|
|
|
|
|
|
$VAL{$uri}=$class; |
96
|
|
|
|
|
|
|
} |
97
|
0
|
|
|
|
|
|
return; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
#################################################################################################### |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub format_validation |
103
|
|
|
|
|
|
|
{ |
104
|
0
|
|
|
0
|
0
|
|
my ($e,$what,$top)=@_; |
105
|
|
|
|
|
|
|
|
106
|
0
|
0
|
0
|
|
|
|
Net::DRI::Exception::usererr_insufficient_parameters('Each validation information must be a reference to an array with 3 elements : 2 strings (id & uri) and a reference of an hash') unless (ref($e) eq 'ARRAY' && @$e==3 && !ref($e->[0]) && length $e->[0] && !ref($e->[1]) && length $e->[1] && (ref($e->[2]) eq 'HASH') && keys(%{$e->[2]})); |
|
0
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
107
|
0
|
0
|
|
|
|
|
Net::DRI::Exception::usererr_invalid_parameters('Id is syntaxically invalid: '.$e->[0]) unless Net::DRI::Util::xml_is_ncname($e->[0]); |
108
|
0
|
0
|
|
|
|
|
Net::DRI::Exception::usererr_insufficient_parameters('No validation information module found for URI='.$e->[1]) unless exists($VAL{$e->[1]}); |
109
|
0
|
0
|
|
|
|
|
Net::DRI::Exception::usererr_invalid_parameters(sprintf('Validation module %s for URI %s must a have a %s method',$VAL{$e->[1]},$e->[1],$what)) unless $VAL{$e->[1]}->can($what); |
110
|
0
|
|
|
|
|
|
my @c=$VAL{$e->[1]}->$what($e->[2]); |
111
|
0
|
|
|
|
|
|
return [$top,{id=>$e->[0]},['e164val:validationInfo',@c]]; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub add_validation_information |
115
|
|
|
|
|
|
|
{ |
116
|
0
|
|
|
0
|
0
|
|
my ($epp,$domain,$rd,$action,$top)=@_; |
117
|
0
|
0
|
0
|
|
|
|
return unless (defined($rd) && (ref($rd) eq 'HASH') && exists($rd->{e164_validation_information}) && (ref($rd->{e164_validation_information}) eq 'ARRAY') && @{$rd->{e164_validation_information}}); |
|
0
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
my $mes=$epp->message(); |
120
|
0
|
|
|
|
|
|
my $eid=$mes->command_extension_register('e164val:'.$action,'xmlns:e164val="'.$NS.'"'); |
121
|
0
|
|
|
|
|
|
my @n=map { format_validation($_,$action,$top) } as_array($rd->{e164_validation_information}); |
|
0
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
$mes->command_extension($eid,\@n); |
123
|
0
|
|
|
|
|
|
return; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub as_array |
127
|
|
|
|
|
|
|
{ |
128
|
0
|
|
|
0
|
0
|
|
my $ra=shift; |
129
|
0
|
0
|
|
|
|
|
if (grep { !ref($_) } @$ra) |
|
0
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
{ |
131
|
0
|
|
|
|
|
|
return ($ra); |
132
|
|
|
|
|
|
|
} else |
133
|
|
|
|
|
|
|
{ |
134
|
0
|
|
|
|
|
|
return @$ra; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
#################################################################################################### |
139
|
|
|
|
|
|
|
########### Query commands |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub info_parse ## §5.1.2 |
142
|
|
|
|
|
|
|
{ |
143
|
0
|
|
|
0
|
0
|
|
my ($po,$otype,$oaction,$oname,$rinfo)=@_; |
144
|
0
|
|
|
|
|
|
my $mes=$po->message(); |
145
|
0
|
0
|
|
|
|
|
return unless $mes->is_success(); |
146
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
my $infdata=$mes->get_extension($NS,'infData'); |
148
|
0
|
0
|
|
|
|
|
return unless defined $infdata; |
149
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
my @val; |
151
|
0
|
|
|
|
|
|
foreach my $el ($infdata->getChildrenByTagNameNS($NS,'inf')) |
152
|
|
|
|
|
|
|
{ |
153
|
0
|
|
|
|
|
|
my $id=$el->getAttribute('id'); |
154
|
0
|
|
|
|
|
|
my $r=($el->getChildrenByTagNameNS($NS,'validationInfo'))[0]; |
155
|
0
|
|
|
|
|
|
$r=$r->getFirstChild(); |
156
|
0
|
|
|
|
|
|
while( $r->nodeType()!=1) { $r=$r->getNextSibling(); } |
|
0
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
my $uri=$r->namespaceURI(); |
158
|
0
|
0
|
|
|
|
|
Net::DRI::Exception::usererr_insufficient_parameters('No validation information module found for URI='.$uri) unless exists($VAL{$uri}); |
159
|
0
|
|
|
|
|
|
push @val,[$id,$uri,$VAL{$uri}->info_parse($po,$r)]; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
$rinfo->{domain}->{$oname}->{e164_validation_information}=\@val; |
163
|
0
|
|
|
|
|
|
return; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
#################################################################################################### |
167
|
|
|
|
|
|
|
############ Transform commands |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub create ## §5.2.1 |
170
|
|
|
|
|
|
|
{ |
171
|
0
|
|
|
0
|
0
|
|
my ($epp,$domain,$rd)=@_; |
172
|
0
|
|
|
|
|
|
add_validation_information($epp,$domain,$rd,'create','e164val:add'); |
173
|
0
|
|
|
|
|
|
return; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub renew ## §5.2.3 |
177
|
|
|
|
|
|
|
{ |
178
|
0
|
|
|
0
|
0
|
|
my ($epp,$domain,$rd)=@_; |
179
|
0
|
|
|
|
|
|
add_validation_information($epp,$domain,$rd,'renew','e164val:add'); |
180
|
0
|
|
|
|
|
|
return; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub transfer_request ## §5.2.4 |
184
|
|
|
|
|
|
|
{ |
185
|
0
|
|
|
0
|
0
|
|
my ($epp,$domain,$rd)=@_; |
186
|
0
|
|
|
|
|
|
add_validation_information($epp,$domain,$rd,'transfer','e164val:add'); |
187
|
0
|
|
|
|
|
|
return; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub update ## §5.2.5 |
191
|
|
|
|
|
|
|
{ |
192
|
0
|
|
|
0
|
0
|
|
my ($epp,$domain,$todo)=@_; |
193
|
0
|
|
|
|
|
|
my $mes=$epp->message(); |
194
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
my $toadd=$todo->add('e164_validation_information'); |
196
|
0
|
|
|
|
|
|
my $todel=$todo->del('e164_validation_information'); |
197
|
0
|
|
|
|
|
|
my $toset=$todo->set('e164_validation_information'); |
198
|
0
|
0
|
0
|
|
|
|
return unless (defined($toadd) || defined($todel) || defined($toset)); |
|
|
|
0
|
|
|
|
|
199
|
|
|
|
|
|
|
|
200
|
0
|
|
|
|
|
|
my @n; |
201
|
0
|
0
|
0
|
|
|
|
push @n,map { format_validation($_,'update','e164val:add') } as_array($toadd) if (defined($toadd) && (ref($toadd) eq 'ARRAY')); |
|
0
|
|
|
|
|
|
|
202
|
0
|
0
|
0
|
|
|
|
push @n,map { ['e164val:rem',{id=>(ref($_) eq 'ARRAY')? $_->[0] : $_->[0]}] } as_array($todel) if (defined($todel) && (ref($todel) eq 'ARRAY')); |
|
0
|
0
|
|
|
|
|
|
203
|
0
|
0
|
|
|
|
|
push @n,map { format_validation($_,'update','e164val:chg') } (ref($toset) eq 'ARRAY')? @$toset : ($toset) if (defined($toset)); |
|
0
|
0
|
|
|
|
|
|
204
|
0
|
0
|
|
|
|
|
return unless @n; |
205
|
|
|
|
|
|
|
|
206
|
0
|
|
|
|
|
|
my $eid=$mes->command_extension_register('e164val:update','xmlns:e164val="'.$NS.'"'); |
207
|
0
|
|
|
|
|
|
$mes->command_extension($eid,\@n); |
208
|
0
|
|
|
|
|
|
return; |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
#################################################################################################### |
212
|
|
|
|
|
|
|
1; |