EPP/Simple.pm

filter: Statementstmt 5.3% 44 / 823 Branchbran 0.0% 0 / 390 Conditioncond 0.0% 0 / 179 MC/DCmcdc 0.0% 0 / 117 Subroutinesub 15.2% 13 / 85 Podpod 12.2% 5 / 41 totaltotal 3.7% 62 / 1635 CC 281 SCAR 55.7
CC
281
Cov
3%
_generate_update_domain_frame
930.0
_generate_update_host_frame
870.0
_generate_update_contact_frame
462.0
CRAP 261.8
↑ Summary EPP/Protocol.pm »
1 package Net::EPP::Simple;
2 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Digest::SHA qw(sha1_hex);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use List::Util qw(any);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Net::EPP;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Net::EPP::Frame;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Net::EPP::ResponseCodes;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Time::HiRes qw(time);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use base qw(Net::EPP::Client);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use constant EPP_XMLNS => 'urn:ietf:params:xml:ns:epp-1.0';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use vars qw($Error $Code $Message @Log);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 our $Error = '';
17 1 our $Code = OK;
18 1 our $Message = '';
19 1 our @Log = ();
20  
21 =pod
22  
23 =head1 NAME
24  
25 Net::EPP::Simple - a simple EPP client interface for the most common jobs.
26  
27 =head1 SYNOPSIS
28  
29 #!/usr/bin/perl
30 use Net::EPP::Simple;
31 use strict;
32  
33 my $epp = Net::EPP::Simple->new(
34 host => 'epp.nic.tld',
35 user => 'my-id',
36 pass => 'my-password',
37 );
38  
39 my $domain = 'example.tld';
40  
41 if ($epp->check_domain($domain) == 1) {
42 print "Domain is available\n" ;
43  
44 } else {
45 my $info = $epp->domain_info($domain);
46 printf("Domain was registered on %s by %s\n", $info->{crDate}, $info->{crID});
47  
48 }
49  
50 =head1 DESCRIPTION
51  
52 This module provides a high level interface to EPP. It hides all the boilerplate
53 of connecting, logging in, building request frames and parsing response frames
54 behind a simple, Perlish interface.
55  
56 It is based on the L<Net::EPP::Client> module and uses L<Net::EPP::Frame> to
57 build request frames.
58  
59 =head1 CONSTRUCTOR
60  
61 my $epp = Net::EPP::Simple->new(%PARAMS);
62  
63 The constructor accepts the following arguments:
64  
65 =over
66  
67 =item * C<host> identifies the EPP server to connect to.
68  
69 =item * C<port> specifies the port, which defaults to C<700>.
70  
71 =item * C<user> and C<pass> parameters specify authentication information.
72  
73 =item * C<newPW> specifies a new password that is set during login.
74  
75 =item * The C<login_security> parameter can be used to force the use of the
76 Login Security Extension (see L<RFC 8807|https://www.rfc-editor.org/rfc/rfc8807.html>).
77 C<Net::EPP::Simple> will automatically use this extension if the server supports
78 it, but clients may wish to force this behaviour to prevent downgrade attacks.
79  
80 =item * The C<appname> parameter can be used to specify the value of the
81 C<E<lt>appE<gt>> element in the Login Security extension (if used). Unless
82 specified, the name and current version of C<Net::EPP::Simple> will be used.
83  
84 =item * The C<timeout> parameter controls how long the client waits for a
85 response from the server before returning an error.
86  
87 =item * if C<debug> is set, C<Net::EPP::Simple> will output verbose debugging
88 information on C<STDERR>, including all frames sent to and received from the
89 server.
90  
91 =item * C<reconnect> can be used to disable automatic reconnection (it is
92 enabled by default). Before sending a frame to the server, C<Net::EPP::Simple>
93 will send a C<E<lt>helloE<gt>> to check that the connection is up, if not, it
94 will try to reconnect, aborting after the I<n>th time, where I<n> is the value
95 of C<reconnect> (the default is 3).
96  
97 =item * C<login> can be used to disable automatic logins. If you set it to C<0>,
98 you can manually log in using the C<$epp-E<gt>_login()> method.
99  
100 =item * C<objects> is a reference to an array of the EPP object namespace URIs
101 that the client requires.
102  
103 =item * C<stdobj> is a flag saying the client only requires the standard EPP
104 C<contact-1.0>, C<domain-1.0>, and C<host-1.0> namespaces.
105  
106 =item * If neither C<objects> nor C<stdobj> is specified then the client will
107 echo the server's object namespace list.
108  
109 =item * C<extensions> is a reference to an array of the EPP extension namespace
110 URIs that the client requires.
111  
112 =item * C<stdext> is a flag saying the client only requires the standard EPP
113 C<secDNS-1.1> DNSSEC extension namespace.
114  
115 =item * If neither C<extensions> nor C<stdext> is specified then the client will
116 echo the server's extension namespace list.
117  
118 =item * The C<lang> parameter can be used to specify the language. The default
119 is "C<en>".
120  
121 =back
122  
123 The constructor will establish a connection to the server and retrieve the
124 greeting (which is available via C<$epp-E<gt>greeting>) and then send a
125 C<E<lt>loginE<gt>> request.
126  
127 If the login fails, the constructor will return C<undef> and set
128 C<$Net::EPP::Simple::Error> and C<$Net::EPP::Simple::Code>.
129  
130 =head2 CLIENT AND SERVER SSL OPTIONS
131  
132 RFC 5730 requires that all EPP instances must be protected using "mutual,
133 strong client-server authentication". In practice, this means that both
134 client and server must present an SSL certificate, and that they must
135 both verify the certificate of their peer.
136  
137 =head3 SERVER CERTIFICATE VERIFICATION
138  
139 C<Net::EPP::Simple> will verify the certificate presented by a server if
140 the C<verify>, and either C<ca_file> or C<ca_path> are passed to the
141 constructor:
142  
143 my $epp = Net::EPP::Simple->new(
144 host => 'epp.nic.tld',
145 user => 'my-id',
146 pass => 'my-password',
147 verify => 1,
148 ca_file => '/etc/pki/tls/certs/ca-bundle.crt',
149 ca_path => '/etc/pki/tls/certs',
150 );
151  
152 C<Net::EPP::Simple> will fail to connect to the server if the
153 certificate is not valid.
154  
155 You can disable SSL certificate verification by omitting the C<verify>
156 argument or setting it to C<undef>. This is strongly discouraged,
157 particularly in production environments.
158  
159 You may wish to use L<Mozilla::CA> to provide a value for the C<ca_file>
160 parameter.
161  
162 =head3 SSL CIPHER SELECTION
163  
164 You can restrict the ciphers that you will use to connect to the server
165 by passing a C<ciphers> parameter to the constructor. This is a colon-
166 separated list of cipher names and aliases. See L<http://www.openssl.org/docs/apps/ciphers.html#CIPHER_STRINGS>
167 for further details. As an example, the following cipher list is
168 suggested for clients who wish to ensure high-security connections to
169 servers:
170  
171 HIGH:!ADH:!MEDIUM:!LOW:!SSLv2:!EXP
172  
173 =head3 CLIENT CERTIFICATES
174  
175 If you are connecting to an EPP server which requires a client
176 certificate, you can configure C<Net::EPP::Simple> to use one as
177 follows:
178  
179 my $epp = Net::EPP::Simple->new(
180 host => 'epp.nic.tld',
181 user => 'my-id',
182 pass => 'my-password',
183 key => '/path/to/my.key',
184 cert => '/path/to/my.crt',
185 passphrase => 'foobar123',
186 );
187  
188 C<key> is the filename of the private key, C<cert> is the filename of
189 the certificate. If the private key is encrypted, the C<passphrase>
190 parameter will be used to decrypt it.
191  
192 =cut
193  
194 0 ▶sub new {
Subroutine new: not called CC=15 SCAR=54.8
Pod documented
195 0 my ($package, %params) = @_;
196 0 $params{dom} = 1;
197  
198 0 my $load_config;
199 0 ▶ if (exists($params{load_config})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $params{"load_config"}) 0 0 0
200 0 confess('the load_config parameter is deprecated and may be removed in a future version');
201 0 $load_config = $params{load_config};
202 0 ▶ $package->_load_config(\%params) if ($load_config);
Branch: 1 branch
BranchTrueFalseTotal
if $load_config 0 0 0
203 }
204  
205 0 ▶ $params{port} = (defined($params{port}) && int($params{port}) > 0 ? $params{port} : 700);
Branch: 1 branch
BranchTrueFalseTotal
defined $params{'port'} && int $params{'port'} > 0 ? : 0 0 0
Condition0%0/3
defined $params{"port"} and int $params{"port"} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $params{"port"} and int $params{"port"} > 0
defined $params{"port"} int $params{"port"} > 0
Truth table0%0/3
A and B
A= defined $params{"port"}B= int $params{"port"} > 0
ABresult
0X0
100
111
206 0 ▶ $params{ssl} = ($params{no_ssl} ? undef : 1);
Branch: 1 branch
BranchTrueFalseTotal
$params{'no_ssl'} ? : 0 0 0
207  
208 0 my $self = $package->SUPER::new(%params);
209  
210 0 $self->{user} = $params{user};
211 0 $self->{pass} = $params{pass};
212 0 $self->{newPW} = $params{newPW};
213 0 ▶ $self->{debug} = (defined($params{debug}) ? int($params{debug}) : undef);
Branch: 1 branch
BranchTrueFalseTotal
defined $params{'debug'} ? : 0 0 0
214 0 ▶ $self->{timeout} = (defined($params{timeout}) && int($params{timeout}) > 0 ? $params{timeout} : 5);
Branch: 1 branch
BranchTrueFalseTotal
defined $params{'timeout'} && int $params{'timeout'} > 0 ? : 0 0 0
Condition0%0/3
defined $params{"timeout"} and int $params{"timeout"} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $params{"timeout"} and int $params{"timeout"} > 0
defined $params{"timeout"} int $params{"timeout"} > 0
Truth table0%0/3
A and B
A= defined $params{"timeout"}B= int $params{"timeout"} > 0
ABresult
0X0
100
111
215 0 ▶ $self->{reconnect} = (defined($params{reconnect}) ? int($params{reconnect}) : 3);
Branch: 1 branch
BranchTrueFalseTotal
defined $params{'reconnect'} ? : 0 0 0
216 0 $self->{'authenticated'} = undef;
217 0 ▶ $self->{connect} = (exists($params{connect}) ? $params{connect} : 1);
Branch: 1 branch
BranchTrueFalseTotal
exists $params{'connect'} ? : 0 0 0
218 0 ▶ $self->{login} = (exists($params{login}) ? $params{login} : 1);
Branch: 1 branch
BranchTrueFalseTotal
exists $params{'login'} ? : 0 0 0
219 0 $self->{key} = $params{key};
220 0 $self->{cert} = $params{cert};
221 0 $self->{passphrase} = $params{passphrase};
222 0 $self->{verify} = $params{verify};
223 0 $self->{ca_file} = $params{ca_file};
224 0 $self->{ca_path} = $params{ca_path};
225 0 $self->{ciphers} = $params{ciphers};
226 0 $self->{objects} = $params{objects};
227 0 $self->{stdobj} = $params{stdobj};
228 0 $self->{extensions} = $params{extensions};
229 0 $self->{stdext} = $params{stdext};
230 0 ▶ $self->{lang} = $params{lang} || 'en';
Condition0%0/2
$params{'lang'} || 'en'
l!l
00
MC/DC0%0/1
$params{'lang'} || 'en'
$params{'lang'}
Truth table0%0/2
A
A= $params{'lang'}
Aresult
11
00
231 0 $self->{login_security} = $params{login_security};
232 0 $self->{appname} = $params{appname};
233  
234 0 bless($self, $package);
235  
236 0 ▶ if ($self->{connect}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'connect'}) { } 0 0 0
237 0 ▶ return ($self->_connect($self->{login}) ? $self : undef);
Branch: 1 branch
BranchTrueFalseTotal
$self->_connect($self->{'login'}) ? : 0 0 0
238  
239 } else {
240 0 return $self;
241  
242 }
243 }
244  
245 #
246 # this functionality is now DEPRECATED
247 #
248 0 ▶sub _load_config {
Subroutine _load_config: not called CC=9 SCAR=45.0
249 0 my ($package, $params_ref) = @_;
250  
251 0 eval 'use Config::Simple';
252 0 ▶ if (!$@) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $@) 0 0 0
253  
254 # we have Config::Simple, so let's try to parse the RC file:
255 0 my $rcfile = $ENV{'HOME'} . '/.net-epp-simple-rc';
256 0 ▶ if (-e $rcfile) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $rcfile) 0 0 0
257 0 my $config = Config::Simple->new($rcfile);
258  
259 # if no host was defined in the constructor, use the default (if specified):
260 0 ▶ if (!defined($params_ref->{'host'}) && $config->param('default.default')) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $params_ref->{"host"} and $config->param("default.default")) 0 0 0
Condition0%0/3
not defined $params_ref->{"host"} and $config->param("default.default")
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $params_ref->{"host"} and $config->param("default.default")
not defined $params_ref->{"host"} $config->param("default.default")
Truth table0%0/3
not(A) and B
A= not defined $params_ref->{"host"}B= $config->param("default.default")
ABresult
0X0
100
111
261 0 $params_ref->{'host'} = $config->param('default.default');
262 }
263  
264 # if no debug level was defined in the constructor, use the default (if specified):
265 0 ▶ if (!defined($params_ref->{'debug'}) && $config->param('default.debug')) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $params_ref->{"debug"} and $config->param("default.debug")) 0 0 0
Condition0%0/3
not defined $params_ref->{"debug"} and $config->param("default.debug")
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $params_ref->{"debug"} and $config->param("default.debug")
not defined $params_ref->{"debug"} $config->param("default.debug")
Truth table0%0/3
not(A) and B
A= not defined $params_ref->{"debug"}B= $config->param("default.debug")
ABresult
0X0
100
111
266 0 $params_ref->{'debug'} = $config->param('default.debug');
267 }
268  
269 # grep through the file's values for settings for the selected host:
270 0 my %vars = $config->vars;
271 0 foreach my $key (grep { /^$params_ref->{'host'}\./ } keys(%vars)) {
272 0 my $value = $vars{$key};
273 0 $key =~ s/^$params_ref->{'host'}\.//;
274 0 ▶ $params_ref->{$key} = $value unless (defined($params_ref->{$key}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $params_ref->{$key} 0 0 0
275 }
276 }
277 }
278 }
279  
280 0 ▶sub _connect {
Subroutine _connect: not called CC=12 SCAR=50.5
281 0 my ($self, $login) = @_;
282  
283 0 my %params;
284  
285 0 ▶ $params{SSL_cipher_list} = $self->{ciphers} if (defined($self->{ssl}) && defined($self->{ciphers}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"ssl"} and defined $self->{"ciphers"} 0 0 0
Condition0%0/3
defined $self->{"ssl"} and defined $self->{"ciphers"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"ssl"} and defined $self->{"ciphers"}
defined $self->{"ssl"} defined $self->{"ciphers"}
Truth table0%0/3
A and B
A= defined $self->{"ssl"}B= defined $self->{"ciphers"}
ABresult
0X0
100
111
286  
287 0 ▶ if (defined($self->{key}) && defined($self->{cert}) && defined($self->{ssl})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"key"} and defined $self->{"cert"} and defined $self->{"ssl"}) 0 0 0
Condition0%0/6
defined $self->{"key"} and defined $self->{"cert"} and defined $self->{"ssl"}
!ll&&!rl&&r
000
defined $self->{"key"} and defined $self->{"cert"}
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->{"key"} and defined $self->{"cert"} and defined $self->{"ssl"}
defined $self->{"key"} defined $self->{"cert"} defined $self->{"ssl"}
Truth table0%0/4
A and B and C
A= defined $self->{"key"}B= defined $self->{"cert"}C= defined $self->{"ssl"}
ABCresult
0XX0
10X0
1100
1111
288 0 $self->debug('configuring client certificate parameters');
289 0 $params{SSL_key_file} = $self->{key};
290 0 $params{SSL_cert_file} = $self->{cert};
291 0 ▶ $params{SSL_passwd_cb} = sub { $self->{passphrase} };
Subroutine __ANON__: not called CC=1 SCAR=6.9
292 }
293  
294 0 ▶ if (defined($self->{ssl}) && defined($self->{verify})) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{'ssl'} and defined $self->{'verify'}) { } 0 0 0
elsif (defined $self->{'ssl'}) { } 0 0 0
Condition0%0/3
defined $self->{"ssl"} and defined $self->{"verify"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"ssl"} and defined $self->{"verify"}
defined $self->{"ssl"} defined $self->{"verify"}
Truth table0%0/3
A and B
A= defined $self->{"ssl"}B= defined $self->{"verify"}
ABresult
0X0
100
111
295 0 $self->debug('configuring server verification');
296 0 $params{SSL_verify_mode} = 1;
297 0 $params{SSL_ca_file} = $self->{ca_file};
298 0 $params{SSL_ca_path} = $self->{ca_path};
299  
300 } elsif (defined($self->{ssl})) {
301 0 $params{SSL_verify_mode} = 0;
302  
303 }
304  
305 0 $self->debug(sprintf('Attempting to connect to %s:%d', $self->{host}, $self->{port}));
306 0 eval {
307 0 $params{no_greeting} = 1;
308 0 $self->connect(%params);
309 };
310 0 ▶ if ($@ ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ ne '') { } 0 0 0
311 0 chomp($@);
312 0 $@ =~ s/ at .+ line .+$//;
313 0 $self->debug($@);
314 0 $Code = COMMAND_FAILED;
315 0 $Error = $Message = "Error connecting: " . $@;
316 0 return undef;
317  
318 } else {
319 0 $self->debug('Connected OK, retrieving greeting frame');
320 0 $self->{greeting} = $self->get_frame;
321 0 ▶ if (ref($self->{greeting}) ne 'Net::EPP::Frame::Response') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{'greeting'} ne 'Net::EPP::Frame::Response') { } 0 0 0
322 0 $Code = COMMAND_FAILED;
323 0 $Error = $Message = "Error retrieving greeting: " . $@;
324 0 return undef;
325  
326 } else {
327 0 $self->debug('greeting frame retrieved OK');
328  
329 }
330 }
331  
332 0 map { $self->debug('S: ' . $_) } split(/\n/, $self->{greeting}->toString(1));
333  
334 0 ▶ if ($login) {
Branch: 1 branch
BranchTrueFalseTotal
if ($login) { } 0 0 0
335 0 $self->debug('attempting login');
336 0 return $self->_login;
337  
338 } else {
339 0 return 1;
340  
341 }
342 }
343  
344 0 ▶sub _login {
Subroutine _login: not called CC=3 SCAR=24.8
345 0 my $self = shift;
346  
347 0 $self->debug(sprintf("Attempting to login as client ID '%s'", $self->{user}));
348 0 my $response = $self->request($self->_prepare_login_frame());
349  
350 0 ▶ if (!$response) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $response) { } 0 0 0
351 0 $Error = $Message = "Error getting response to login request: " . $Error;
352 0 return undef;
353  
354 } else {
355 0 $Code = $self->_get_response_code($response);
356 0 $Message = $self->_get_message($response);
357  
358 0 $self->debug(sprintf('%04d: %s', $Code, $Message));
359  
360 0 ▶ if ($Code > 1999) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Net::EPP::Simple::Code > 1999) { } 0 0 0
361 0 $Error = "Error logging in (response code $Code, message $Message)";
362 0 return undef;
363  
364 } else {
365 0 $self->{'authenticated'} = 1;
366 0 return 1;
367  
368 }
369 }
370 }
371  
372 0 ▶sub _get_uris_from_greeting {
Subroutine _get_uris_from_greeting: not called CC=2 SCAR=17.9
373 0 my $self = shift;
374 0 my $tag = shift;
375 0 my $list = [];
376 0 my $elems = $self->{greeting}->getElementsByTagNameNS(EPP_XMLNS, $tag);
377 0 ▶ while (my $elem = $elems->shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $elem = $elems->shift) 0 0 0
378 0 push @$list, $elem->firstChild->data;
379 }
380 0 return $list;
381 }
382  
383 0 ▶sub _prepare_login_frame {
Subroutine _prepare_login_frame: not called CC=14 SCAR=53.5
384 0 my $self = shift;
385  
386 0 $self->debug('preparing login frame');
387 0 my $login = Net::EPP::Frame::Command::Login->new;
388  
389 0 my @extensions;
390 0 ▶ if ($self->{'stdext'}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'stdext'}) { } 0 0 0
elsif ($self->{'extensions'}) { } 0 0 0
391 0 push(@extensions, Net::EPP::Frame::ObjectSpec->xmlns('secDNS'));
392  
393 } elsif ($self->{'extensions'}) {
394 0 @extensions = @{$self->{'extensions'}};
395  
396 } else {
397 0 @extensions = @{$self->_get_uris_from_greeting('extURI')};
398  
399 }
400  
401 0 $login->clID->appendText($self->{'user'});
402  
403 0 my $loginSecXMLNS = Net::EPP::Frame::ObjectSpec->xmlns('loginSec');
404  
405 0 ▶ if ($self->{'login_security'} || $self->server_has_extension($loginSecXMLNS)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'login_security'} or $self->server_has_extension($loginSecXMLNS)) { } 0 0 0
Condition0%0/3
$self->{"login_security"} or $self->server_has_extension($loginSecXMLNS)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"login_security"} or $self->server_has_extension($loginSecXMLNS)
$self->{"login_security"} $self->server_has_extension($loginSecXMLNS)
Truth table0%0/3
A or B
A= $self->{"login_security"}B= $self->server_has_extension($loginSecXMLNS)
ABresult
1X1
011
000
406 0 ▶ push(@extensions, $loginSecXMLNS) unless (any { $loginSecXMLNS eq $_ } @extensions);
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless &any(sub { $loginSecXMLNS eq $_; } , @extensions) 0 0 0
407  
408 0 $login->pw->appendText('[LOGIN-SECURITY]');
409  
410 0 my $loginSec = $login->createElementNS($loginSecXMLNS, 'loginSec');
411  
412 0 my $userAgent = $login->createElement('userAgent');
413 0 $loginSec->appendChild($userAgent);
414  
415 0 my $app = $login->createElement('app');
416 0 ▶ $app->appendText($self->{'appname'} || sprintf('%s %s', __PACKAGE__, $Net::EPP::VERSION));
Condition0%0/2
$self->{'appname'} || sprintf('%s %s', __PACKAGE__, $Net::EPP::VERSION)
l!l
00
MC/DC0%0/1
$self->{'appname'} || sprintf('%s %s', __PACKAGE__, $Net::EPP::VERSION)
$self->{'appname'}
Truth table0%0/2
A
A= $self->{'appname'}
Aresult
11
00
417 0 $userAgent->appendChild($app);
418  
419 0 my $tech = $login->createElement('tech');
420 0 $tech->appendText(sprintf('Perl %s', $Config{'version'}));
421 0 $userAgent->appendChild($tech);
422  
423 0 my $os = $login->createElement('os');
424 0 $os->appendText(sprintf('%s %s', ucfirst($Config{'osname'}), $Config{'osvers'}));
425 0 $userAgent->appendChild($os);
426  
427 0 my $pw = $login->createElement('pw');
428 0 $pw->appendText($self->{'pass'});
429 0 $loginSec->appendChild($pw);
430  
431 0 ▶ if ($self->{'newPW'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"newPW"}) 0 0 0
432 0 my $newPW = $login->createElement('newPW');
433 0 $newPW->appendText('[LOGIN-SECURITY]');
434 0 $login->getNode('login')->insertAfter($newPW, $login->pw);
435  
436 0 $newPW = $login->createElement('newPW');
437 0 $newPW->appendText($self->{'newPW'});
438 0 $loginSec->appendChild($newPW);
439 }
440  
441 0 $login->extension->appendChild($loginSec);
442  
443 } else {
444 0 $login->pw->appendText($self->{pass});
445  
446 0 ▶ if ($self->{newPW}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"newPW"}) 0 0 0
447 0 my $newPW = $login->createElement('newPW');
448 0 $newPW->appendText($self->{newPW});
449 0 $login->getNode('login')->insertAfter($newPW, $login->pw);
450 }
451 }
452  
453 0 $login->version->appendText($self->{greeting}->getElementsByTagNameNS(EPP_XMLNS, 'version')->shift->firstChild->data);
454 0 $login->lang->appendText($self->{lang});
455  
456 0 my $objects = $self->{objects};
457 0 ▶ $objects = [map { Net::EPP::Frame::ObjectSpec->xmlns($_) } qw(contact domain host)] if $self->{stdobj};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"stdobj"} 0 0 0
458 0 ▶ $objects = $self->_get_uris_from_greeting('objURI') if not $objects;
Branch: 1 branch
BranchTrueFalseTotal
unless $objects 0 0 0
459 0 $login->svcs->appendTextChild('objURI', $_) for @$objects;
460  
461 0 ▶ if (scalar(@extensions) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @extensions > 0) 0 0 0
462 0 my $svcext = $login->createElement('svcExtension');
463 0 $login->svcs->appendChild($svcext);
464 0 $svcext->appendTextChild('extURI', $_) for @extensions;
465 }
466  
467 0 return $login;
468 }
469  
470 =pod
471  
472 =head1 AVAILABILITY CHECKS
473  
474 You can do a simple C<E<lt>checkE<gt>> request for an object like so:
475  
476 my $result = $epp->check_domain($domain);
477  
478 my $result = $epp->check_host($host);
479  
480 my $result = $epp->check_contact($contact);
481  
482 Each of these methods has the same profile. They will return one of the
483 following:
484  
485 =over
486  
487 =item * C<undef> in the case of an error (check C<$Net::EPP::Simple::Error> and C<$Net::EPP::Simple::Code>).
488  
489 =item * C<0> if the object is already provisioned.
490  
491 =item * C<1> if the object is available.
492  
493 =back
494  
495 =cut
496  
497 0 ▶sub check_domain {
Subroutine check_domain: not called CC=1 SCAR=6.9
Pod undocumented
498 0 my ($self, $domain) = @_;
499 0 return $self->_check('domain', $domain);
500 }
501  
502 0 ▶sub check_host {
Subroutine check_host: not called CC=1 SCAR=6.9
Pod undocumented
503 0 my ($self, $host) = @_;
504 0 return $self->_check('host', $host);
505 }
506  
507 0 ▶sub check_contact {
Subroutine check_contact: not called CC=1 SCAR=6.9
Pod undocumented
508 0 my ($self, $contact) = @_;
509 0 return $self->_check('contact', $contact);
510 }
511  
512 0 ▶sub _check {
Subroutine _check: not called CC=9 SCAR=45.0
513 0 my ($self, $type, $identifier) = @_;
514 0 my $frame;
515 0 ▶ if ($type eq 'domain') {
Branch: 3 branches
BranchTrueFalseTotal
if ($type eq 'domain') { } 0 0 0
elsif ($type eq 'contact') { } 0 0 0
elsif ($type eq 'host') { } 0 0 0
516 0 $frame = Net::EPP::Frame::Command::Check::Domain->new;
517 0 $frame->addDomain($identifier);
518  
519 } elsif ($type eq 'contact') {
520 0 $frame = Net::EPP::Frame::Command::Check::Contact->new;
521 0 $frame->addContact($identifier);
522  
523 } elsif ($type eq 'host') {
524 0 $frame = Net::EPP::Frame::Command::Check::Host->new;
525 0 $frame->addHost($identifier);
526  
527 } else {
528 0 $Error = "Unknown object type '$type'";
529 0 return undef;
530 }
531  
532 0 my $response = $self->_request($frame);
533  
534 0 ▶ if (!$response) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $response) { } 0 0 0
535 0 return undef;
536  
537 } else {
538 0 $Code = $self->_get_response_code($response);
539 0 $Message = $self->_get_message($response);
540  
541 0 ▶ if ($Code > 1999) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Net::EPP::Simple::Code > 1999) { } 0 0 0
542 0 $Error = $self->_get_error_message($response);
543 0 return undef;
544  
545 } else {
546 0 my $xmlns = Net::EPP::Frame::ObjectSpec->xmlns($type);
547 0 my $key;
548 0 ▶ if ($type eq 'domain' || $type eq 'host') {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'domain' or $type eq 'host') { } 0 0 0
elsif ($type eq 'contact') { } 0 0 0
Condition0%0/3
$type eq "domain" or $type eq "host"
l!l&&r!l&&!r
000
MC/DC0%0/2
$type eq "domain" or $type eq "host"
$type eq "domain" $type eq "host"
Truth table0%0/3
A or B
A= $type eq "domain"B= $type eq "host"
ABresult
1X1
011
000
549 0 $key = 'name';
550  
551 } elsif ($type eq 'contact') {
552 0 $key = 'id';
553  
554 }
555 0 return $response->getNode($xmlns, $key)->getAttribute('avail');
556  
557 }
558 }
559 }
560  
561 =pod
562  
563 =head1 RETRIEVING OBJECT INFORMATION
564  
565 =head2 DOMAIN OBJECTS
566  
567 my $info = $epp->domain_info($domain, $authInfo, $follow);
568  
569 This method constructs an C<E<lt>infoE<gt>> frame and sends
570 it to the server, then parses the response into a simple hash ref. If
571 there is an error, this method will return C<undef>, and you can then
572 check C<$Net::EPP::Simple::Error> and C<$Net::EPP::Simple::Code>.
573  
574 If C<$authInfo> is defined, it will be sent to the server as per RFC
575 5731, Section 3.1.2.
576  
577 If the C<$follow> parameter is true, then C<Net::EPP::Simple> will also
578 retrieve the relevant host and contact details for a domain: instead of
579 returning an object name or ID for the domain's registrant, contact
580 associations, DNS servers or subordinate hosts, the values will be
581 replaced with the return value from the appropriate C<host_info()> or
582 C<contact_info()> command (unless there was an error, in which case the
583 original object ID will be used instead).
584  
585 =cut
586  
587 0 ▶sub domain_info {
Subroutine domain_info: not called CC=15 SCAR=54.8
Pod undocumented
588 0 my ($self, $domain, $authInfo, $follow, $hosts) = @_;
589 0 ▶ $hosts = $hosts || 'all';
Condition0%0/2
$hosts || 'all'
l!l
00
MC/DC0%0/1
$hosts || 'all'
$hosts
Truth table0%0/2
A
A= $hosts
Aresult
11
00
590  
591 0 my $result = $self->_info('domain', $domain, $authInfo, $hosts);
592 0 ▶ return $result if (ref($result) ne 'HASH' || !$follow);
Branch: 1 branch
BranchTrueFalseTotal
if ref $result ne "HASH" or not $follow 0 0 0
Condition0%0/3
ref $result ne "HASH" or not $follow
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $result ne "HASH" or not $follow
ref $result ne "HASH" not $follow
Truth table0%0/3
A or not(B)
A= ref $result ne "HASH"B= not $follow
ABresult
1X1
011
000
593  
594 0 ▶ if (defined($result->{'ns'}) && ref($result->{'ns'}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $result->{"ns"} and ref $result->{"ns"} eq "ARRAY") 0 0 0
Condition0%0/3
defined $result->{"ns"} and ref $result->{"ns"} eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $result->{"ns"} and ref $result->{"ns"} eq "ARRAY"
defined $result->{"ns"} ref $result->{"ns"} eq "ARRAY"
Truth table0%0/3
A and B
A= defined $result->{"ns"}B= ref $result->{"ns"} eq "ARRAY"
ABresult
0X0
100
111
595 0 ▶ for (my $i = 0 ; $i < scalar(@{$result->{'ns'}}) ; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$result->{"ns"};}) 0 0 0
596 0 my $info = $self->host_info($result->{'ns'}->[$i]);
597 0 ▶ $result->{'ns'}->[$i] = $info if (ref($info) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
if ref $info eq "HASH" 0 0 0
598 }
599 }
600  
601 0 ▶ if (defined($result->{'hosts'}) && ref($result->{'hosts'}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $result->{"hosts"} and ref $result->{"hosts"} eq "ARRAY") 0 0 0
Condition0%0/3
defined $result->{"hosts"} and ref $result->{"hosts"} eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $result->{"hosts"} and ref $result->{"hosts"} eq "ARRAY"
defined $result->{"hosts"} ref $result->{"hosts"} eq "ARRAY"
Truth table0%0/3
A and B
A= defined $result->{"hosts"}B= ref $result->{"hosts"} eq "ARRAY"
ABresult
0X0
100
111
602 0 ▶ for (my $i = 0 ; $i < scalar(@{$result->{'hosts'}}) ; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$result->{"hosts"};}) 0 0 0
603 0 my $info = $self->host_info($result->{'hosts'}->[$i]);
604 0 ▶ $result->{'hosts'}->[$i] = $info if (ref($info) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
if ref $info eq "HASH" 0 0 0
605 }
606 }
607  
608 0 my $info = $self->contact_info($result->{'registrant'});
609 0 ▶ $result->{'registrant'} = $info if (ref($info) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
if ref $info eq "HASH" 0 0 0
610  
611 0 foreach my $type (keys(%{$result->{'contacts'}})) {
612 0 my $info = $self->contact_info($result->{'contacts'}->{$type});
613 0 ▶ $result->{'contacts'}->{$type} = $info if (ref($info) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
if ref $info eq "HASH" 0 0 0
614 }
615  
616 0 return $result;
617 }
618  
619 =pod
620  
621 =head2 HOST OBJECTS
622  
623 my $info = $epp->host_info($host);
624  
625 This method constructs an C<E<lt>infoE<gt>> frame and sends
626 it to the server, then parses the response into a simple hash ref. If
627 there is an error, this method will return C<undef>, and you can then
628 check C<$Net::EPP::Simple::Error> and C<$Net::EPP::Simple::Code>.
629  
630 =cut
631  
632 0 ▶sub host_info {
Subroutine host_info: not called CC=1 SCAR=6.9
Pod undocumented
633 0 my ($self, $host) = @_;
634 0 return $self->_info('host', $host);
635 }
636  
637 =pod
638  
639 =head2 CONTACT OBJECTS
640  
641 my $info = $epp->contact_info($contact, $authInfo, $roid);
642  
643 This method constructs an C<E<lt>infoE<gt>> frame and sends
644 it to the server, then parses the response into a simple hash ref. If
645 there is an error, this method will return C<undef>, and you can then
646 check C<$Net::EPP::Simple::Error> and C<$Net::EPP::Simple::Code>.
647  
648 If C<$authInfo> is defined, it will be sent to the server as per RFC
649 RFC 5733, Section 3.1.2.
650  
651 If the C<$roid> parameter to C<host_info()> is set, then the C<roid>
652 attribute will be set on the C<E<lt>authInfoE<gt>> element.
653  
654 =cut
655  
656 0 ▶sub contact_info {
Subroutine contact_info: not called CC=1 SCAR=6.9
Pod undocumented
657 0 my ($self, $contact, $authInfo, $roid) = @_;
658 0 return $self->_info('contact', $contact, $authInfo, $roid);
659 }
660  
661 0 ▶sub _info {
Subroutine _info: not called CC=11 SCAR=48.8
662  
663 # $opt is the "hosts" attribute value for domains or the "roid"
664 # attribute for contacts
665 0 my ($self, $type, $identifier, $authInfo, $opt) = @_;
666 0 my $frame;
667 0 ▶ if ($type eq 'domain') {
Branch: 3 branches
BranchTrueFalseTotal
if ($type eq 'domain') { } 0 0 0
elsif ($type eq 'contact') { } 0 0 0
elsif ($type eq 'host') { } 0 0 0
668 0 $frame = Net::EPP::Frame::Command::Info::Domain->new;
669 0 ▶ $frame->setDomain($identifier, $opt || 'all');
Condition0%0/2
$opt || 'all'
l!l
00
MC/DC0%0/1
$opt || 'all'
$opt
Truth table0%0/2
A
A= $opt
Aresult
11
00
670  
671 } elsif ($type eq 'contact') {
672 0 $frame = Net::EPP::Frame::Command::Info::Contact->new;
673 0 $frame->setContact($identifier);
674  
675 } elsif ($type eq 'host') {
676 0 $frame = Net::EPP::Frame::Command::Info::Host->new;
677 0 $frame->setHost($identifier);
678  
679 } else {
680 0 $Error = "Unknown object type '$type'";
681 0 return undef;
682  
683 }
684  
685 0 ▶ if (defined($authInfo) && $authInfo ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $authInfo and $authInfo ne "") 0 0 0
Condition0%0/3
defined $authInfo and $authInfo ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $authInfo and $authInfo ne ""
defined $authInfo $authInfo ne ""
Truth table0%0/3
A and B
A= defined $authInfoB= $authInfo ne ""
ABresult
0X0
100
111
686 0 $self->debug('adding authInfo element to request frame');
687 0 my $el = $frame->createElementNS(Net::EPP::Frame::ObjectSpec->xmlns($type), 'authInfo');
688 0 my $pw = $frame->createElementNS(Net::EPP::Frame::ObjectSpec->xmlns($type), 'pw');
689 0 $pw->appendChild($frame->createTextNode($authInfo));
690 0 ▶ $pw->setAttribute('roid', $opt) if ($type eq 'contact' && $opt);
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "contact" and $opt 0 0 0
Condition0%0/3
$type eq "contact" and $opt
!ll&&!rl&&r
000
MC/DC0%0/2
$type eq "contact" and $opt
$type eq "contact" $opt
Truth table0%0/3
A and B
A= $type eq "contact"B= $opt
ABresult
0X0
100
111
691 0 $el->appendChild($pw);
692 0 $frame->getNode(Net::EPP::Frame::ObjectSpec->xmlns($type), 'info')->appendChild($el);
693 }
694  
695 0 my $response = $self->_request($frame);
696  
697 0 ▶ if (!$response) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $response) { } 0 0 0
698 0 return undef;
699  
700 } else {
701 0 $Code = $self->_get_response_code($response);
702 0 $Message = $self->_get_message($response);
703  
704 0 ▶ if ($Code > 1999) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Net::EPP::Simple::Code > 1999) { } 0 0 0
705 0 $Error = $self->_get_error_message($response);
706 0 return undef;
707  
708 } else {
709 0 return $self->parse_object_info($type, $response);
710 }
711 }
712 }
713  
714 # An easy-to-subclass method for parsing object info
715 0 ▶sub parse_object_info {
Subroutine parse_object_info: not called CC=4 SCAR=30.0
Pod undocumented
716 0 my ($self, $type, $response) = @_;
717  
718 0 my $infData = $response->getNode(Net::EPP::Frame::ObjectSpec->xmlns($type), 'infData');
719  
720 0 ▶ if ($type eq 'domain') {
Branch: 3 branches
BranchTrueFalseTotal
if ($type eq 'domain') { } 0 0 0
elsif ($type eq 'contact') { } 0 0 0
elsif ($type eq 'host') { } 0 0 0
721  
722 # secDNS extension only applies to domain objects
723 0 my $secinfo = $response->getNode(Net::EPP::Frame::ObjectSpec->xmlns('secDNS'), 'infData');
724 0 return $self->_domain_infData_to_hash($infData, $secinfo);
725  
726 } elsif ($type eq 'contact') {
727 0 return $self->_contact_infData_to_hash($infData);
728  
729 } elsif ($type eq 'host') {
730 0 return $self->_host_infData_to_hash($infData);
731  
732 } else {
733 0 $Error = "Unknown object type '$type'";
734 0 return undef;
735  
736 }
737 }
738  
739 0 ▶sub _get_common_properties_from_infData {
Subroutine _get_common_properties_from_infData: not called CC=4 SCAR=30.0
740 0 my ($self, $infData, @extra) = @_;
741 0 my $hash = {};
742  
743 0 my @default = qw(roid clID crID crDate upID upDate trDate);
744  
745 0 foreach my $name (@default, @extra) {
746 0 my $els = $infData->getElementsByLocalName($name);
747 0 ▶ $hash->{$name} = $els->shift->textContent if ($els->size > 0);
Branch: 1 branch
BranchTrueFalseTotal
if $els->size > 0 0 0 0
748 }
749  
750 0 my $codes = $infData->getElementsByLocalName('status');
751 0 ▶ while (my $code = $codes->shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $code = $codes->shift) 0 0 0
752 0 push(@{$hash->{status}}, $code->getAttribute('s'));
753 }
754  
755 0 return $hash;
756 }
757  
758 =pod
759  
760 =head2 DOMAIN INFORMATION
761  
762 The hash ref returned by C<domain_info()> will usually look something
763 like this:
764  
765 {
766 'contacts' => {
767 'admin' => 'contact-id' 'tech' => 'contact-id' 'billing' => 'contact-id'
768 },
769 'registrant' => 'contact-id',
770 'clID' => 'registrar-id',
771 'roid' => 'tld-12345',
772 'status' => ['ok'],
773 'authInfo' => 'abc-12345',
774 'name' => 'example.tld',
775 'trDate' => '2011-01-18T11:08:03.0Z',
776 'ns' => ['ns0.example.com', 'ns1.example.com',],
777 'crDate' => '2011-02-16T12:06:31.0Z',
778 'exDate' => '2011-02-16T12:06:31.0Z',
779 'crID' => 'registrar-id',
780 'upDate' => '2011-08-29T04:02:12.0Z',
781 hosts => ['ns0.example.tld', 'ns1.example.tld',],
782 }
783  
784 Members of the C<contacts> hash ref may be strings or, if there are
785 multiple associations of the same type, an anonymous array of strings.
786 If the server uses the Host Attribute model instead of the Host Object
787 model, then the C<ns> member will look like this:
788  
789 [
790 {
791 name => 'ns0.example.com',
792 addrs => [
793 version => 'v4',
794 addr => '10.0.0.1',
795 ],
796 },
797 {
798 name => 'ns1.example.com',
799 addrs => [
800 version => 'v4',
801 addr => '10.0.0.2',
802 ],
803 },
804 ]
805  
806  
807 Note that there may be multiple members in the C<addrs> section and that
808 the C<version> attribute is optional.
809  
810 =cut
811  
812 0 ▶sub _domain_infData_to_hash {
Subroutine _domain_infData_to_hash: not called CC=15 SCAR=54.8
813 0 my ($self, $infData, $secinfo) = @_;
814  
815 0 my $hash = $self->_get_common_properties_from_infData($infData, 'registrant', 'name', 'exDate');
816  
817 0 my $contacts = $infData->getElementsByLocalName('contact');
818 0 ▶ while (my $contact = $contacts->shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $contact = $contacts->shift) 0 0 0
819 0 my $type = $contact->getAttribute('type');
820 0 my $id = $contact->textContent;
821  
822 0 ▶ if (ref($hash->{contacts}->{$type}) eq 'STRING') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $hash->{'contacts'}{$type} eq 'STRING') { } 0 0 0
elsif (ref $hash->{'contacts'}{$type} eq 'ARRAY') { } 0 0 0
823 0 $hash->{contacts}->{$type} = [$hash->{contacts}->{$type}, $id];
824  
825 } elsif (ref($hash->{contacts}->{$type}) eq 'ARRAY') {
826 0 push(@{$hash->{contacts}->{$type}}, $id);
827  
828 } else {
829 0 $hash->{contacts}->{$type} = $id;
830  
831 }
832  
833 }
834  
835 0 my $ns = $infData->getElementsByLocalName('ns');
836 0 ▶ if ($ns->size == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ns->size == 1) 0 0 0
837 0 my $el = $ns->shift;
838 0 my $hostObjs = $el->getElementsByLocalName('hostObj');
839 0 ▶ while (my $hostObj = $hostObjs->shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $hostObj = $hostObjs->shift) 0 0 0
840 0 push(@{$hash->{ns}}, $hostObj->textContent);
841 }
842  
843 0 my $hostAttrs = $el->getElementsByLocalName('hostAttr');
844 0 ▶ while (my $hostAttr = $hostAttrs->shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $hostAttr = $hostAttrs->shift) 0 0 0
845 0 my $host = {};
846 0 $host->{name} = $hostAttr->getElementsByLocalName('hostName')->shift->textContent;
847 0 my $addrs = $hostAttr->getElementsByLocalName('hostAddr');
848 0 ▶ while (my $addr = $addrs->shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $addr = $addrs->shift) 0 0 0
849 0 push(@{$host->{addrs}}, {version => $addr->getAttribute('ip'), addr => $addr->textContent});
850 }
851 0 push(@{$hash->{ns}}, $host);
852 }
853 }
854  
855 0 my $hosts = $infData->getElementsByLocalName('host');
856 0 ▶ while (my $host = $hosts->shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $host = $hosts->shift) 0 0 0
857 0 push(@{$hash->{hosts}}, $host->textContent);
858 }
859  
860 0 my $auths = $infData->getElementsByLocalName('authInfo');
861 0 ▶ if ($auths->size == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($auths->size == 1) 0 0 0
862 0 my $authInfo = $auths->shift;
863 0 my $pw = $authInfo->getElementsByLocalName('pw');
864 0 ▶ $hash->{authInfo} = $pw->shift->textContent if ($pw->size == 1);
Branch: 1 branch
BranchTrueFalseTotal
if $pw->size == 1 0 0 0
865 }
866  
867 0 ▶ if (defined $secinfo) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $secinfo) 0 0 0
868 0 ▶ if (my $maxSigLife = $secinfo->getElementsByLocalName('maxSigLife')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $maxSigLife = $secinfo->getElementsByLocalName("maxSigLife")) 0 0 0
869 0 $hash->{maxSigLife} = $maxSigLife->shift->textContent;
870 }
871 0 my $dslist = $secinfo->getElementsByTagName('secDNS:dsData');
872 0 ▶ while (my $ds = $dslist->shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ds = $dslist->shift) 0 0 0
873 0 my @ds = map { $ds->getElementsByLocalName($_)->string_value() } qw(keyTag alg digestType digest);
874 0 push @{$hash->{DS}}, "@ds";
875 }
876 0 my $keylist = $secinfo->getElementsByLocalName('keyData');
877 0 ▶ while (my $key = $keylist->shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $key = $keylist->shift) 0 0 0
878 0 my @key = map { $key->getElementsByLocalName($_)->string_value() } qw(flags protocol alg pubKey);
879 0 push @{$hash->{DNSKEY}}, "@key";
880 }
881 }
882  
883 0 return $hash;
884 }
885  
886 =pod
887  
888 =head2 HOST INFORMATION
889  
890 The hash ref returned by C<host_info()> will usually look something like
891 this:
892  
893 {
894 'crDate' => '2011-09-17T15:38:56.0Z',
895 'clID' => 'registrar-id',
896 'crID' => 'registrar-id',
897 'roid' => 'tld-12345',
898 'status' => ['linked', 'serverDeleteProhibited',],
899 'name' => 'ns0.example.tld',
900 'addrs' => [
901 {
902 'version' => 'v4',
903 'addr' => '10.0.0.1'
904 }
905 ]
906 }
907  
908 Note that hosts may have multiple addresses, and that C<version> is
909 optional.
910  
911 =cut
912  
913 0 ▶sub _host_infData_to_hash {
Subroutine _host_infData_to_hash: not called CC=2 SCAR=17.9
914 0 my ($self, $infData) = @_;
915  
916 0 my $hash = $self->_get_common_properties_from_infData($infData, 'name');
917  
918 0 my $addrs = $infData->getElementsByLocalName('addr');
919 0 ▶ while (my $addr = $addrs->shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $addr = $addrs->shift) 0 0 0
920 0 push(@{$hash->{addrs}}, {version => $addr->getAttribute('ip'), addr => $addr->textContent});
921 }
922  
923 0 return $hash;
924 }
925  
926 =pod
927  
928 =head2 CONTACT INFORMATION
929  
930 The hash ref returned by C<contact_info()> will usually look something
931 like this:
932  
933 {
934 'id' => 'contact-id',
935 'postalInfo' => {
936 'int' => {
937 'name' => 'John Doe',
938 'org' => 'Example Inc.',
939 'addr' => {
940 'street' => ['123 Example Dr.', 'Suite 100'],
941 'city' => 'Dulles',
942 'sp' => 'VA',
943 'pc' => '20116-6503',
944 'cc' => 'US',
945 }}
946 },
947 'clID' => 'registrar-id',
948 'roid' => 'CNIC-HA321983',
949 'status' => ['linked', 'serverDeleteProhibited'],
950 'voice' => '+1.7035555555x1234',
951 'fax' => '+1.7035555556',
952 'email' => 'jdoe@example.com',
953 'crDate' => '2011-09-23T03:51:29.0Z',
954 'upDate' => '1999-11-30T00:00:00.0Z'
955 }
956  
957 There may be up to two members of the C<postalInfo> hash, corresponding
958 to the C<int> and C<loc> internationalised and localised types.
959  
960 =cut
961  
962 0 ▶sub _contact_infData_to_hash {
Subroutine _contact_infData_to_hash: not called CC=18 SCAR=58.3
963 0 my ($self, $infData) = @_;
964  
965 0 my $hash = $self->_get_common_properties_from_infData($infData, 'email', 'id');
966  
967 # remove this as it gets in the way:
968 0 my $els = $infData->getElementsByLocalName('disclose');
969 0 ▶ if ($els->size > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($els->size > 0) 0 0 0
970 0 ▶ while (my $el = $els->shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $el = $els->shift) 0 0 0
971 0 $el->parentNode->removeChild($el);
972 }
973 }
974  
975 0 foreach my $name ('voice', 'fax') {
976 0 my $els = $infData->getElementsByLocalName($name);
977 0 ▶ if (defined($els) && $els->size == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $els and $els->size == 1) 0 0 0
Condition0%0/3
defined $els and $els->size == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $els and $els->size == 1
defined $els $els->size == 1
Truth table0%0/3
A and B
A= defined $elsB= $els->size == 1
ABresult
0X0
100
111
978 0 my $el = $els->shift;
979 0 ▶ if (defined($el)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $el) 0 0 0
980 0 $hash->{$name} = $el->textContent;
981 0 ▶ $hash->{$name} .= 'x' . $el->getAttribute('x') if (defined($el->getAttribute('x')) && $el->getAttribute('x') ne '');
Branch: 1 branch
BranchTrueFalseTotal
if defined $el->getAttribute("x") and $el->getAttribute("x") ne "" 0 0 0
Condition0%0/3
defined $el->getAttribute("x") and $el->getAttribute("x") ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $el->getAttribute("x") and $el->getAttribute("x") ne ""
defined $el->getAttribute("x") $el->getAttribute("x") ne ""
Truth table0%0/3
A and B
A= defined $el->getAttribute("x")B= $el->getAttribute("x") ne ""
ABresult
0X0
100
111
982 }
983 }
984 }
985  
986 0 my $postalInfo = $infData->getElementsByLocalName('postalInfo');
987 0 ▶ while (my $info = $postalInfo->shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $info = $postalInfo->shift) 0 0 0
988 0 my $ref = {};
989  
990 0 foreach my $name (qw(name org)) {
991 0 my $els = $info->getElementsByLocalName($name);
992 0 ▶ $ref->{$name} = $els->shift->textContent if ($els->size == 1);
Branch: 1 branch
BranchTrueFalseTotal
if $els->size == 1 0 0 0
993 }
994  
995 0 my $addrs = $info->getElementsByLocalName('addr');
996 0 ▶ if ($addrs->size == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($addrs->size == 1) 0 0 0
997 0 my $addr = $addrs->shift;
998 0 foreach my $child ($addr->childNodes) {
999 0 ▶ next if (XML::LibXML::XML_ELEMENT_NODE != $child->nodeType);
Branch: 1 branch
BranchTrueFalseTotal
if 1 != $child->nodeType 0 0 0
1000 0 ▶ if ($child->localName eq 'street') {
Branch: 1 branch
BranchTrueFalseTotal
if ($child->localName eq 'street') { } 0 0 0
1001 0 push(@{$ref->{addr}->{$child->localName}}, $child->textContent);
1002  
1003 } else {
1004 0 $ref->{addr}->{$child->localName} = $child->textContent;
1005  
1006 }
1007 }
1008 }
1009  
1010 0 $hash->{postalInfo}->{$info->getAttribute('type')} = $ref;
1011 }
1012  
1013 0 my $auths = $infData->getElementsByLocalName('authInfo');
1014 0 ▶ if ($auths->size == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($auths->size == 1) 0 0 0
1015 0 my $authInfo = $auths->shift;
1016 0 my $pw = $authInfo->getElementsByLocalName('pw');
1017 0 ▶ $hash->{authInfo} = $pw->shift->textContent if ($pw->size == 1);
Branch: 1 branch
BranchTrueFalseTotal
if $pw->size == 1 0 0 0
1018 }
1019  
1020 0 return $hash;
1021 }
1022  
1023 =pod
1024  
1025 =head1 OBJECT TRANSFERS
1026  
1027 The EPP C<E<lt>transferE<gt>> command suppots five different operations:
1028 query, request, cancel, approve, and reject. C<Net::EPP::Simple> makes
1029 these available using the following methods:
1030  
1031 # For domain objects:
1032  
1033 $epp->domain_transfer_query($domain);
1034 $epp->domain_transfer_cancel($domain);
1035 $epp->domain_transfer_request($domain, $authInfo, $period);
1036 $epp->domain_transfer_approve($domain);
1037 $epp->domain_transfer_reject($domain);
1038  
1039 # For contact objects:
1040  
1041 $epp->contact_transfer_query($contact);
1042 $epp->contact_transfer_cancel($contact);
1043 $epp->contact_transfer_request($contact, $authInfo);
1044 $epp->contact_transfer_approve($contact);
1045 $epp->contact_transfer_reject($contact);
1046  
1047 Most of these methods will just set the value of C<$Net::EPP::Simple::Code>
1048 and return either true or false. However, the C<domain_transfer_request()>,
1049 C<domain_transfer_query()>, C<contact_transfer_request()> and C<contact_transfer_query()>
1050 methods will return a hash ref that looks like this:
1051  
1052 {
1053 'name' => 'example.tld',
1054 'reID' => 'losing-registrar',
1055 'acDate' => '2011-12-04T12:24:53.0Z',
1056 'acID' => 'gaining-registrar',
1057 'reDate' => '2011-11-29T12:24:53.0Z',
1058 'trStatus' => 'pending'
1059 }
1060  
1061 =cut
1062  
1063 0 ▶sub _transfer_request {
Subroutine _transfer_request: not called CC=14 SCAR=53.5
1064 0 my ($self, $op, $type, $identifier, $authInfo, $period) = @_;
1065  
1066 0 my $class = sprintf('Net::EPP::Frame::Command::Transfer::%s', ucfirst(lc($type)));
1067  
1068 0 my $frame;
1069 0 eval("\$frame = $class->new");
1070 0 ▶ if ($@ || ref($frame) ne $class) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or ref $frame ne $class) { } 0 0 0
Condition0%0/3
$@ or ref $frame ne $class
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ or ref $frame ne $class
$@ ref $frame ne $class
Truth table0%0/3
A or B
A= $@B= ref $frame ne $class
ABresult
1X1
011
000
1071 0 $Error = "Error building request frame: $@";
1072 0 $Code = COMMAND_FAILED;
1073 0 return undef;
1074  
1075 } else {
1076 0 $frame->setOp($op);
1077 0 ▶ if ($type eq 'domain') {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'domain') { } 0 0 0
elsif ($type eq 'contact') { } 0 0 0
1078 0 $frame->setDomain($identifier);
1079 0 ▶ $frame->setPeriod(int($period)) if ($op eq 'request');
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "request" 0 0 0
1080  
1081 } elsif ($type eq 'contact') {
1082 0 $frame->setContact($identifier);
1083  
1084 }
1085  
1086 0 ▶ if ($op eq 'request' || $op eq 'query') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq "request" or $op eq "query") 0 0 0
Condition0%0/3
$op eq "request" or $op eq "query"
l!l&&r!l&&!r
000
MC/DC0%0/2
$op eq "request" or $op eq "query"
$op eq "request" $op eq "query"
Truth table0%0/3
A or B
A= $op eq "request"B= $op eq "query"
ABresult
1X1
011
000
1087 0 ▶ $frame->setAuthInfo($authInfo) if ($authInfo ne '');
Branch: 1 branch
BranchTrueFalseTotal
if $authInfo ne "" 0 0 0
1088 }
1089  
1090 }
1091  
1092 0 my $response = $self->_request($frame);
1093  
1094 0 ▶ if (!$response) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $response) { } 0 0 0
1095 0 return undef;
1096  
1097 } else {
1098 0 $Code = $self->_get_response_code($response);
1099 0 $Message = $self->_get_message($response);
1100  
1101 0 ▶ if ($Code > 1999) {
Branch: 2 branches
BranchTrueFalseTotal
if ($Net::EPP::Simple::Code > 1999) { } 0 0 0
elsif ($op eq 'query' or $op eq 'request') { } 0 0 0
1102 0 $Error = $response->msg;
1103 0 return undef;
1104  
1105 ▶ } elsif ($op eq 'query' || $op eq 'request') {
Condition0%0/3
$op eq "query" or $op eq "request"
l!l&&r!l&&!r
000
MC/DC0%0/2
$op eq "query" or $op eq "request"
$op eq "query" $op eq "request"
Truth table0%0/3
A or B
A= $op eq "query"B= $op eq "request"
ABresult
1X1
011
000
1106 0 my $trnData = $response->getElementsByLocalName('trnData')->shift;
1107 0 my $hash = {};
1108 0 foreach my $child ($trnData->childNodes) {
1109 0 $hash->{$child->localName} = $child->textContent;
1110 }
1111  
1112 0 return $hash;
1113  
1114 } else {
1115 0 return 1;
1116  
1117 }
1118 }
1119 }
1120  
1121 0 ▶sub domain_transfer_query {
Subroutine domain_transfer_query: not called CC=1 SCAR=6.9
Pod undocumented
1122 0 return $_[0]->_transfer_request('query', 'domain', $_[1]);
1123 }
1124  
1125 0 ▶sub domain_transfer_cancel {
Subroutine domain_transfer_cancel: not called CC=1 SCAR=6.9
Pod undocumented
1126 0 return $_[0]->_transfer_request('cancel', 'domain', $_[1]);
1127 }
1128  
1129 0 ▶sub domain_transfer_request {
Subroutine domain_transfer_request: not called CC=1 SCAR=6.9
Pod undocumented
1130 0 return $_[0]->_transfer_request('request', 'domain', $_[1], $_[2], $_[3]);
1131 }
1132  
1133 0 ▶sub domain_transfer_approve {
Subroutine domain_transfer_approve: not called CC=1 SCAR=6.9
Pod undocumented
1134 0 return $_[0]->_transfer_request('approve', 'domain', $_[1]);
1135 }
1136  
1137 0 ▶sub domain_transfer_reject {
Subroutine domain_transfer_reject: not called CC=1 SCAR=6.9
Pod undocumented
1138 0 return $_[0]->_transfer_request('reject', 'domain', $_[1]);
1139 }
1140  
1141 0 ▶sub contact_transfer_query {
Subroutine contact_transfer_query: not called CC=1 SCAR=6.9
Pod undocumented
1142 0 return $_[0]->_transfer_request('query', 'contact', $_[1]);
1143 }
1144  
1145 0 ▶sub contact_transfer_cancel {
Subroutine contact_transfer_cancel: not called CC=1 SCAR=6.9
Pod undocumented
1146 0 return $_[0]->_transfer_request('cancel', 'contact', $_[1]);
1147 }
1148  
1149 0 ▶sub contact_transfer_request {
Subroutine contact_transfer_request: not called CC=1 SCAR=6.9
Pod undocumented
1150 0 return $_[0]->_transfer_request('request', 'contact', $_[1], $_[2]);
1151 }
1152  
1153 0 ▶sub contact_transfer_approve {
Subroutine contact_transfer_approve: not called CC=1 SCAR=6.9
Pod undocumented
1154 0 return $_[0]->_transfer_request('approve', 'contact', $_[1]);
1155 }
1156  
1157 0 ▶sub contact_transfer_reject {
Subroutine contact_transfer_reject: not called CC=1 SCAR=6.9
Pod undocumented
1158 0 return $_[0]->_transfer_request('reject', 'contact', $_[1]);
1159 }
1160  
1161 =pod
1162  
1163 =head1 CREATING OBJECTS
1164  
1165 The following methods can be used to create a new object at the server:
1166  
1167 $epp->create_domain($domain);
1168 $epp->create_host($host);
1169 $epp->create_contact($contact);
1170  
1171 The argument for these methods is a hash ref of the same format as that
1172 returned by the info methods above. As a result, cloning an existing
1173 object is as simple as the following:
1174  
1175 my $info = $epp->contact_info($contact);
1176  
1177 # set a new contact ID to avoid clashing with the existing object
1178 $info->{id} = $new_contact;
1179  
1180 # randomize authInfo:
1181 $info->{authInfo} = $random_string;
1182  
1183 $epp->create_contact($info);
1184  
1185 C<Net::EPP::Simple> will ignore object properties that it does not recognise,
1186 and those properties (such as server-managed status codes) that clients are
1187 not permitted to set.
1188  
1189 =head2 CREATING NEW DOMAINS
1190  
1191 When creating a new domain object, you may also specify a C<period> key, like
1192 so:
1193  
1194 $epp->create_domain({
1195 'name' => 'example.tld',
1196 'period' => 2,
1197 'registrant' => 'contact-id',
1198 'contacts' => {
1199 'tech' => 'contact-id',
1200 'admin' => 'contact-id',
1201 'billing' => 'contact-id',
1202 },
1203 'status' => ['clientTransferProhibited',],
1204 'ns' => {'ns0.example.com', 'ns1.example.com',},
1205  
1206 # this will be ignored if the server does not support the TTL extension
1207 'ttl' => {'NS' => 3600, 'DS' => 60},
1208 });
1209  
1210 The C<period> key is assumed to be in years rather than months.
1211 C<Net::EPP::Simple> assumes the registry uses the host object model rather than
1212 the host attribute model.
1213  
1214 =cut
1215  
1216 0 ▶sub create_domain {
Subroutine create_domain: not called CC=1 SCAR=6.9
Pod undocumented
1217 0 my ($self, $domain) = @_;
1218  
1219 0 return $self->_get_response_result($self->_request($self->_prepare_create_domain_frame($domain)));
1220 }
1221  
1222 0 ▶sub _prepare_create_domain_frame {
Subroutine _prepare_create_domain_frame: not called CC=11 SCAR=48.8
1223 0 my ($self, $domain) = @_;
1224  
1225 0 my $frame = Net::EPP::Frame::Command::Create::Domain->new;
1226  
1227 0 $frame->setDomain($domain->{'name'});
1228 0 ▶ $frame->setPeriod($domain->{'period'}) if (defined($domain->{period}) && $domain->{period} > 0);
Branch: 1 branch
BranchTrueFalseTotal
if defined $domain->{"period"} and $domain->{"period"} > 0 0 0 0
Condition0%0/3
defined $domain->{"period"} and $domain->{"period"} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $domain->{"period"} and $domain->{"period"} > 0
defined $domain->{"period"} $domain->{"period"} > 0
Truth table0%0/3
A and B
A= defined $domain->{"period"}B= $domain->{"period"} > 0
ABresult
0X0
100
111
1229 0 ▶ $frame->setNS(@{$domain->{'ns'}}) if $domain->{'ns'} and @{$domain->{'ns'}};
Branch: 1 branch
BranchTrueFalseTotal
if $domain->{"ns"} and @{$domain->{"ns"};} 0 0 0
Condition0%0/3
$domain->{"ns"} and @{$domain->{"ns"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$domain->{"ns"} and @{$domain->{"ns"};}
$domain->{"ns"} @{$domain->{"ns"};}
Truth table0%0/3
A and B
A= $domain->{"ns"}B= @{$domain->{"ns"};}
ABresult
0X0
100
111
1230 0 ▶ $frame->setRegistrant($domain->{'registrant'}) if (defined($domain->{registrant}) && $domain->{registrant} ne '');
Branch: 1 branch
BranchTrueFalseTotal
if defined $domain->{"registrant"} and $domain->{"registrant"} ne "" 0 0 0
Condition0%0/3
defined $domain->{"registrant"} and $domain->{"registrant"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $domain->{"registrant"} and $domain->{"registrant"} ne ""
defined $domain->{"registrant"} $domain->{"registrant"} ne ""
Truth table0%0/3
A and B
A= defined $domain->{"registrant"}B= $domain->{"registrant"} ne ""
ABresult
0X0
100
111
1231 0 $frame->setContacts($domain->{'contacts'});
1232 0 ▶ $frame->setAuthInfo($domain->{authInfo}) if (defined($domain->{authInfo}) && $domain->{authInfo} ne '');
Branch: 1 branch
BranchTrueFalseTotal
if defined $domain->{"authInfo"} and $domain->{"authInfo"} ne "" 0 0 0
Condition0%0/3
defined $domain->{"authInfo"} and $domain->{"authInfo"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $domain->{"authInfo"} and $domain->{"authInfo"} ne ""
defined $domain->{"authInfo"} $domain->{"authInfo"} ne ""
Truth table0%0/3
A and B
A= defined $domain->{"authInfo"}B= $domain->{"authInfo"} ne ""
ABresult
0X0
100
111
1233  
1234 0 ▶ if ($domain->{'ttl'} && $self->server_has_extension(Net::EPP::Frame::ObjectSpec->xmlns('ttl'))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($domain->{"ttl"} and $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))) 0 0 0
Condition0%0/3
$domain->{"ttl"} and $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))
!ll&&!rl&&r
000
MC/DC0%0/2
$domain->{"ttl"} and $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))
$domain->{"ttl"} $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))
Truth table0%0/3
A and B
A= $domain->{"ttl"}B= $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))
ABresult
0X0
100
111
1235 0 $frame->setTTLs($domain->{'ttl'});
1236 }
1237  
1238 0 return $frame;
1239 }
1240  
1241 =head2 CREATING HOSTS
1242  
1243 $epp->create_host({
1244 name => 'ns1.example.tld',
1245 addrs => [
1246 {ip => '192.0.2.1', version => 'v4'},
1247 {ip => '192.0.2.2', version => 'v4'},
1248 ],
1249  
1250 # this will be ignored if the server does not support the TTL extension
1251 'ttl' => {
1252 'A' => 3600,
1253 'AAAA' => 900,
1254 }
1255 });
1256  
1257 =cut
1258  
1259 0 ▶sub create_host {
Subroutine create_host: not called CC=1 SCAR=6.9
Pod undocumented
1260 0 my ($self, $host) = @_;
1261  
1262 0 return $self->_get_response_result($self->_request($self->_prepare_create_host_frame($host)));
1263 }
1264  
1265 0 ▶sub _prepare_create_host_frame {
Subroutine _prepare_create_host_frame: not called CC=3 SCAR=24.8
1266 0 my ($self, $host) = @_;
1267  
1268 0 my $frame = Net::EPP::Frame::Command::Create::Host->new;
1269 0 $frame->setHost($host->{name});
1270 0 $frame->setAddr(@{$host->{addrs}});
1271  
1272 0 ▶ if ($host->{'ttl'} && $self->server_has_extension(Net::EPP::Frame::ObjectSpec->xmlns('ttl'))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($host->{"ttl"} and $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))) 0 0 0
Condition0%0/3
$host->{"ttl"} and $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))
!ll&&!rl&&r
000
MC/DC0%0/2
$host->{"ttl"} and $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))
$host->{"ttl"} $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))
Truth table0%0/3
A and B
A= $host->{"ttl"}B= $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))
ABresult
0X0
100
111
1273 0 $frame->setTTLs($host->{'ttl'});
1274 }
1275  
1276 0 return $frame;
1277 }
1278  
1279 0 ▶sub create_contact {
Subroutine create_contact: not called CC=1 SCAR=6.9
Pod undocumented
1280 0 my ($self, $contact) = @_;
1281  
1282 0 return $self->_get_response_result($self->_request($self->_prepare_create_contact_frame($contact)));
1283 }
1284  
1285 0 ▶sub _prepare_create_contact_frame {
Subroutine _prepare_create_contact_frame: not called CC=11 SCAR=48.8
1286 0 my ($self, $contact) = @_;
1287  
1288 0 my $frame = Net::EPP::Frame::Command::Create::Contact->new;
1289  
1290 0 $frame->setContact($contact->{id});
1291  
1292 0 ▶ if (ref($contact->{postalInfo}) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $contact->{"postalInfo"} eq "HASH") 0 0 0
1293 0 foreach my $type (keys(%{$contact->{postalInfo}})) {
1294 0 $frame->addPostalInfo($type, $contact->{postalInfo}->{$type}->{name}, $contact->{postalInfo}->{$type}->{org}, $contact->{postalInfo}->{$type}->{addr});
1295 }
1296 }
1297  
1298 0 ▶ $frame->setVoice($contact->{voice}) if (defined($contact->{voice}) && $contact->{voice} ne '');
Branch: 1 branch
BranchTrueFalseTotal
if defined $contact->{"voice"} and $contact->{"voice"} ne "" 0 0 0
Condition0%0/3
defined $contact->{"voice"} and $contact->{"voice"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $contact->{"voice"} and $contact->{"voice"} ne ""
defined $contact->{"voice"} $contact->{"voice"} ne ""
Truth table0%0/3
A and B
A= defined $contact->{"voice"}B= $contact->{"voice"} ne ""
ABresult
0X0
100
111
1299 0 ▶ $frame->setFax($contact->{fax}) if (defined($contact->{fax}) && $contact->{fax} ne '');
Branch: 1 branch
BranchTrueFalseTotal
if defined $contact->{"fax"} and $contact->{"fax"} ne "" 0 0 0
Condition0%0/3
defined $contact->{"fax"} and $contact->{"fax"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $contact->{"fax"} and $contact->{"fax"} ne ""
defined $contact->{"fax"} $contact->{"fax"} ne ""
Truth table0%0/3
A and B
A= defined $contact->{"fax"}B= $contact->{"fax"} ne ""
ABresult
0X0
100
111
1300 0 $frame->setEmail($contact->{email});
1301 0 ▶ $frame->setAuthInfo($contact->{authInfo}) if (defined($contact->{authInfo}) && $contact->{authInfo} ne '');
Branch: 1 branch
BranchTrueFalseTotal
if defined $contact->{"authInfo"} and $contact->{"authInfo"} ne "" 0 0 0
Condition0%0/3
defined $contact->{"authInfo"} and $contact->{"authInfo"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $contact->{"authInfo"} and $contact->{"authInfo"} ne ""
defined $contact->{"authInfo"} $contact->{"authInfo"} ne ""
Truth table0%0/3
A and B
A= defined $contact->{"authInfo"}B= $contact->{"authInfo"} ne ""
ABresult
0X0
100
111
1302  
1303 0 ▶ if (ref($contact->{status}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $contact->{"status"} eq "ARRAY") 0 0 0
1304 0 foreach my $status (grep { /^client/ } @{$contact->{status}}) {
1305 0 $frame->appendStatus($status);
1306 }
1307 }
1308 0 return $frame;
1309 }
1310  
1311 # Process response code and return result
1312 0 ▶sub _get_response_result {
Subroutine _get_response_result: not called CC=3 SCAR=24.8
1313 0 my ($self, $response) = @_;
1314  
1315 0 ▶ return undef if !$response;
Branch: 1 branch
BranchTrueFalseTotal
unless $response 0 0 0
1316  
1317 # If there was a response...
1318 0 $Code = $self->_get_response_code($response);
1319 0 $Message = $self->_get_message($response);
1320 0 ▶ if ($Code > 1999) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Net::EPP::Simple::Code > 1999) 0 0 0
1321 0 $Error = $response->msg;
1322 0 return undef;
1323 }
1324 0 return 1;
1325 }
1326  
1327 =head1 UPDATING OBJECTS
1328  
1329 The following methods can be used to update an object at the server:
1330  
1331 $epp->update_domain($domain);
1332 $epp->update_host($host);
1333 $epp->update_contact($contact);
1334  
1335 Each of these methods has the same profile. They will return one of the following:
1336  
1337 =over
1338  
1339 =item * undef in the case of an error (check C<$Net::EPP::Simple::Error> and C<$Net::EPP::Simple::Code>).
1340  
1341 =item * 1 if the update request was accepted.
1342  
1343 =back
1344  
1345 You may wish to check the value of $Net::EPP::Simple::Code to determine whether the response code was 1000 (OK) or 1001 (action pending).
1346  
1347 =cut
1348  
1349 =head2 UPDATING DOMAINS
1350  
1351 Use C<update_domain($info)> method to update a domain name.
1352  
1353 The C<$info> argument should look like this:
1354  
1355 {
1356 name => $domain,
1357 chg => {
1358 registrant => $new_registrant_id,
1359 authInfo => $new_domain_password,
1360  
1361 # this will be ignored if the server does not support the TTL extension
1362 ttl => {'NS' => 3600, 'DS' => 60},
1363 },
1364 add => {
1365  
1366 ns => [qw/ns1.example.com ns2.example.com/],
1367 contacts => {
1368 tech => 'contact-id',
1369 billing => 'contact-id',
1370 admin => 'contact-id',
1371 },
1372  
1373 # Status info, simple form:
1374 status => [qw/ clientUpdateProhibited clientHold /],
1375  
1376 # Status info may be in more detailed form:
1377 # status => {
1378 # clientUpdateProbhibited => 'Avoid accidental change',
1379 # clientHold => 'This domain is not delegated',
1380 # },
1381 },
1382 rem => {
1383 ns => [...],
1384 contacts => {
1385 tech => 'old_tech_id',
1386 billing => 'old_billing_id',
1387 admin => 'old_admin_id',
1388 },
1389 status => [qw/ clientTransferProhibited ... /],
1390 },
1391 }
1392  
1393 All fields except C<name> are optional.
1394  
1395 =cut
1396  
1397 0 ▶sub update_domain {
Subroutine update_domain: not called CC=1 SCAR=6.9
Pod undocumented
1398 0 my ($self, $domain) = @_;
1399 0 return $self->_update('domain', $domain);
1400 }
1401  
1402 =head2 UPDATING CONTACTS
1403  
1404 Use C<update_contact(info)> method to update a contact object.
1405  
1406 The C<$info> argument should look like this:
1407  
1408 {
1409 id => $contact_id,
1410 add => {
1411 status => [qw/ clientDeleteProhibited /],
1412  
1413 # OR
1414 # status => {
1415 # clientDeleteProhibited => 'Avoid accidental removal',
1416 # },
1417 },
1418 rem => {
1419 status => [qw/ clientUpdateProhibited /],
1420 },
1421 chg => {
1422 postalInfo => {
1423 int => {
1424 name => 'John Doe',
1425 org => 'Example Inc.',
1426 addr => {
1427 street => ['123 Example Dr.', 'Suite 100'],
1428 city => 'Dulles',
1429 sp => 'VA',
1430 pc => '20116-6503',
1431 cc => 'US',
1432 },
1433 },
1434 },
1435 voice => '+1.7035555555x1234',
1436 fax => '+1.7035555556',
1437 email => 'jdoe@example.com',
1438 authInfo => 'new-contact-password',
1439 },
1440 }
1441  
1442 All fields except C<id> are optional.
1443  
1444 =cut
1445  
1446 0 ▶sub update_contact {
Subroutine update_contact: not called CC=1 SCAR=6.9
Pod undocumented
1447 0 my ($self, $contact) = @_;
1448 0 return $self->_update('contact', $contact);
1449 }
1450  
1451 =head2 UPDATING HOSTS
1452  
1453 Use C<update_host($info)> method to update a host object.
1454  
1455 The C<$info> argument should look like this:
1456  
1457 {
1458 name => 'ns1.example.com',
1459 add => {
1460 status => [qw/ clientDeleteProhibited /],
1461  
1462 # OR
1463 # status => {
1464 # clientDeleteProhibited => 'Avoid accidental removal',
1465 # },
1466  
1467 addrs => [{ip => '123.45.67.89', version => 'v4'}, {ip => '98.76.54.32', version => 'v4'},],
1468 },
1469 rem => {
1470 status => [qw/ clientUpdateProhibited /],
1471 addrs => [{ip => '1.2.3.4', version => 'v4'}, {ip => '5.6.7.8', version => 'v4'},],
1472 },
1473 chg => {
1474 name => 'ns2.example.com',
1475 # this will be ignored if the server does not support the TTL extension
1476 ttl => {NS => 3600, DS => 60},
1477 },
1478 }
1479  
1480 All fields except C<name> are optional.
1481  
1482 =cut
1483  
1484 0 ▶sub update_host {
Subroutine update_host: not called CC=1 SCAR=6.9
Pod undocumented
1485 0 my ($self, $host) = @_;
1486 0 return $self->_update('host', $host);
1487 }
1488  
1489 # Update domain/contact/host information
1490 0 ▶sub _update {
Subroutine _update: not called CC=2 SCAR=17.9
1491 0 my ($self, $type, $info) = @_;
1492  
1493 0 my %frame_generator = (
1494 'domain' => \&_generate_update_domain_frame,
1495 'contact' => \&_generate_update_contact_frame,
1496 'host' => \&_generate_update_host_frame,
1497 );
1498  
1499 0 ▶ if (!exists $frame_generator{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $frame_generator{$type}) 0 0 0
1500 0 $Error = "Unknown object type: '$type'";
1501 0 return undef;
1502 }
1503  
1504 0 my $generator = $frame_generator{$type};
1505 0 my $frame = $self->$generator($info);
1506 0 return $self->_get_response_result($self->request($frame));
1507 }
1508  
1509 0 ▶sub _generate_update_domain_frame {
Subroutine _generate_update_domain_frame: not called CC=30 SCAR=68.4
1510 0 my ($self, $info) = @_;
1511  
1512 0 my $frame = Net::EPP::Frame::Command::Update::Domain->new;
1513 0 $frame->setDomain($info->{name});
1514  
1515 # 'add' element
1516 0 ▶ if (exists $info->{add} && ref $info->{add} eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info->{"add"} and ref $info->{"add"} eq "HASH") 0 0 0
Condition0%0/3
exists $info->{"add"} and ref $info->{"add"} eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $info->{"add"} and ref $info->{"add"} eq "HASH"
exists $info->{"add"} ref $info->{"add"} eq "HASH"
Truth table0%0/3
A and B
A= exists $info->{"add"}B= ref $info->{"add"} eq "HASH"
ABresult
0X0
100
111
1517  
1518 0 my $add = $info->{add};
1519  
1520 # Add DNS
1521 0 ▶ if (exists $add->{ns} && ref $add->{ns} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $add->{"ns"} and ref $add->{"ns"} eq "ARRAY") 0 0 0
Condition0%0/3
exists $add->{"ns"} and ref $add->{"ns"} eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $add->{"ns"} and ref $add->{"ns"} eq "ARRAY"
exists $add->{"ns"} ref $add->{"ns"} eq "ARRAY"
Truth table0%0/3
A and B
A= exists $add->{"ns"}B= ref $add->{"ns"} eq "ARRAY"
ABresult
0X0
100
111
1522 0 $frame->addNS(@{$add->{ns}});
1523 }
1524  
1525 # Add contacts
1526 0 ▶ if (exists $add->{contacts} && ref $add->{contacts} eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $add->{"contacts"} and ref $add->{"contacts"} eq "HASH") 0 0 0
Condition0%0/3
exists $add->{"contacts"} and ref $add->{"contacts"} eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $add->{"contacts"} and ref $add->{"contacts"} eq "HASH"
exists $add->{"contacts"} ref $add->{"contacts"} eq "HASH"
Truth table0%0/3
A and B
A= exists $add->{"contacts"}B= ref $add->{"contacts"} eq "HASH"
ABresult
0X0
100
111
1527  
1528 0 my $contacts = $add->{contacts};
1529 0 foreach my $type (keys %{$contacts}) {
1530 0 $frame->addContact($type, $contacts->{$type});
1531 }
1532 }
1533  
1534 # Add status info
1535 0 ▶ if (exists $add->{status} && ref $add->{status}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $add->{"status"} and ref $add->{"status"}) 0 0 0
Condition0%0/3
exists $add->{"status"} and ref $add->{"status"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $add->{"status"} and ref $add->{"status"}
exists $add->{"status"} ref $add->{"status"}
Truth table0%0/3
A and B
A= exists $add->{"status"}B= ref $add->{"status"}
ABresult
0X0
100
111
1536 0 ▶ if (ref $add->{status} eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $add->{'status'} eq 'HASH') { } 0 0 0
elsif (ref $add->{'status'} eq 'ARRAY') { } 0 0 0
1537 0 ▶ while (my ($type, $info) = each %{$add->{status}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$add{"status"};}) 0 0 0
1538 0 $frame->addStatus($type, $info);
1539 }
1540 } elsif (ref $add->{status} eq 'ARRAY') {
1541 0 $frame->addStatus($_) for @{$add->{status}};
1542 }
1543 }
1544 }
1545  
1546 # 'rem' element
1547 0 ▶ if (exists $info->{rem} && ref $info->{rem} eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info->{"rem"} and ref $info->{"rem"} eq "HASH") 0 0 0
Condition0%0/3
exists $info->{"rem"} and ref $info->{"rem"} eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $info->{"rem"} and ref $info->{"rem"} eq "HASH"
exists $info->{"rem"} ref $info->{"rem"} eq "HASH"
Truth table0%0/3
A and B
A= exists $info->{"rem"}B= ref $info->{"rem"} eq "HASH"
ABresult
0X0
100
111
1548  
1549 0 my $rem = $info->{rem};
1550  
1551 # DNS
1552 0 ▶ if (exists $rem->{ns} && ref $rem->{ns} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rem->{"ns"} and ref $rem->{"ns"} eq "ARRAY") 0 0 0
Condition0%0/3
exists $rem->{"ns"} and ref $rem->{"ns"} eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rem->{"ns"} and ref $rem->{"ns"} eq "ARRAY"
exists $rem->{"ns"} ref $rem->{"ns"} eq "ARRAY"
Truth table0%0/3
A and B
A= exists $rem->{"ns"}B= ref $rem->{"ns"} eq "ARRAY"
ABresult
0X0
100
111
1553 0 $frame->remNS(@{$rem->{ns}});
1554 }
1555  
1556 # Contacts
1557 0 ▶ if (exists $rem->{contacts} && ref $rem->{contacts} eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rem->{"contacts"} and ref $rem->{"contacts"} eq "HASH") 0 0 0
Condition0%0/3
exists $rem->{"contacts"} and ref $rem->{"contacts"} eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rem->{"contacts"} and ref $rem->{"contacts"} eq "HASH"
exists $rem->{"contacts"} ref $rem->{"contacts"} eq "HASH"
Truth table0%0/3
A and B
A= exists $rem->{"contacts"}B= ref $rem->{"contacts"} eq "HASH"
ABresult
0X0
100
111
1558 0 my $contacts = $rem->{contacts};
1559  
1560 0 foreach my $type (keys %{$contacts}) {
1561 0 $frame->remContact($type, $contacts->{$type});
1562 }
1563 }
1564  
1565 # Status info
1566 0 ▶ if (exists $rem->{status} && ref $rem->{status} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rem->{"status"} and ref $rem->{"status"} eq "ARRAY") 0 0 0
Condition0%0/3
exists $rem->{"status"} and ref $rem->{"status"} eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rem->{"status"} and ref $rem->{"status"} eq "ARRAY"
exists $rem->{"status"} ref $rem->{"status"} eq "ARRAY"
Truth table0%0/3
A and B
A= exists $rem->{"status"}B= ref $rem->{"status"} eq "ARRAY"
ABresult
0X0
100
111
1567 0 $frame->remStatus($_) for @{$rem->{status}};
1568 }
1569 }
1570  
1571 # 'chg' element
1572 0 ▶ if (exists $info->{chg} && ref $info->{chg} eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info->{"chg"} and ref $info->{"chg"} eq "HASH") 0 0 0
Condition0%0/3
exists $info->{"chg"} and ref $info->{"chg"} eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $info->{"chg"} and ref $info->{"chg"} eq "HASH"
exists $info->{"chg"} ref $info->{"chg"} eq "HASH"
Truth table0%0/3
A and B
A= exists $info->{"chg"}B= ref $info->{"chg"} eq "HASH"
ABresult
0X0
100
111
1573  
1574 0 my $chg = $info->{chg};
1575  
1576 0 ▶ if (defined $chg->{registrant}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $chg->{"registrant"}) 0 0 0
1577 0 $frame->chgRegistrant($chg->{registrant});
1578 }
1579  
1580 0 ▶ if (defined $chg->{authInfo}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $chg->{"authInfo"}) 0 0 0
1581 0 $frame->chgAuthInfo($chg->{authInfo});
1582 }
1583  
1584 0 ▶ if (defined $chg->{ttl} && $self->server_has_extension(Net::EPP::Frame::ObjectSpec->xmlns('ttl'))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $chg->{"ttl"} and $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))) 0 0 0
Condition0%0/3
defined $chg->{"ttl"} and $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))
!ll&&!rl&&r
000
MC/DC0%0/2
defined $chg->{"ttl"} and $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))
defined $chg->{"ttl"} $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))
Truth table0%0/3
A and B
A= defined $chg->{"ttl"}B= $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))
ABresult
0X0
100
111
1585 0 $frame->chgTTLs($chg->{ttl});
1586 }
1587  
1588 }
1589  
1590 0 return $frame;
1591 }
1592  
1593 0 ▶sub _generate_update_contact_frame {
Subroutine _generate_update_contact_frame: not called CC=21 SCAR=61.4
1594 0 my ($self, $info) = @_;
1595  
1596 0 my $frame = Net::EPP::Frame::Command::Update::Contact->new;
1597 0 $frame->setContact($info->{id});
1598  
1599 # Add
1600 0 ▶ if (exists $info->{add} && ref $info->{add} eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info->{"add"} and ref $info->{"add"} eq "HASH") 0 0 0
Condition0%0/3
exists $info->{"add"} and ref $info->{"add"} eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $info->{"add"} and ref $info->{"add"} eq "HASH"
exists $info->{"add"} ref $info->{"add"} eq "HASH"
Truth table0%0/3
A and B
A= exists $info->{"add"}B= ref $info->{"add"} eq "HASH"
ABresult
0X0
100
111
1601 0 my $add = $info->{add};
1602  
1603 0 ▶ if (exists $add->{status} && ref $add->{status}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $add->{"status"} and ref $add->{"status"}) 0 0 0
Condition0%0/3
exists $add->{"status"} and ref $add->{"status"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $add->{"status"} and ref $add->{"status"}
exists $add->{"status"} ref $add->{"status"}
Truth table0%0/3
A and B
A= exists $add->{"status"}B= ref $add->{"status"}
ABresult
0X0
100
111
1604 0 ▶ if (ref $add->{status} eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $add->{'status'} eq 'HASH') { } 0 0 0
elsif (ref $add->{'status'} eq 'ARRAY') { } 0 0 0
1605 0 ▶ while (my ($type, $info) = each %{$add->{status}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$add{"status"};}) 0 0 0
1606 0 $frame->addStatus($type, $info);
1607 }
1608 } elsif (ref $add->{status} eq 'ARRAY') {
1609 0 $frame->addStatus($_) for @{$add->{status}};
1610 }
1611 }
1612 }
1613  
1614 # Remove
1615 0 ▶ if (exists $info->{rem} && ref $info->{rem} eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info->{"rem"} and ref $info->{"rem"} eq "HASH") 0 0 0
Condition0%0/3
exists $info->{"rem"} and ref $info->{"rem"} eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $info->{"rem"} and ref $info->{"rem"} eq "HASH"
exists $info->{"rem"} ref $info->{"rem"} eq "HASH"
Truth table0%0/3
A and B
A= exists $info->{"rem"}B= ref $info->{"rem"} eq "HASH"
ABresult
0X0
100
111
1616  
1617 0 my $rem = $info->{rem};
1618  
1619 0 ▶ if (exists $rem->{status} && ref $rem->{status} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rem->{"status"} and ref $rem->{"status"} eq "ARRAY") 0 0 0
Condition0%0/3
exists $rem->{"status"} and ref $rem->{"status"} eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rem->{"status"} and ref $rem->{"status"} eq "ARRAY"
exists $rem->{"status"} ref $rem->{"status"} eq "ARRAY"
Truth table0%0/3
A and B
A= exists $rem->{"status"}B= ref $rem->{"status"} eq "ARRAY"
ABresult
0X0
100
111
1620 0 $frame->remStatus($_) for @{$rem->{status}};
1621 }
1622 }
1623  
1624 # Change
1625 0 ▶ if (exists $info->{chg} && ref $info->{chg} eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info->{"chg"} and ref $info->{"chg"} eq "HASH") 0 0 0
Condition0%0/3
exists $info->{"chg"} and ref $info->{"chg"} eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $info->{"chg"} and ref $info->{"chg"} eq "HASH"
exists $info->{"chg"} ref $info->{"chg"} eq "HASH"
Truth table0%0/3
A and B
A= exists $info->{"chg"}B= ref $info->{"chg"} eq "HASH"
ABresult
0X0
100
111
1626  
1627 0 my $chg = $info->{chg};
1628  
1629 # Change postal info
1630 0 ▶ if (ref $chg->{postalInfo} eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $chg->{"postalInfo"} eq "HASH") 0 0 0
1631 0 foreach my $type (keys %{$chg->{postalInfo}}) {
1632 0 $frame->chgPostalInfo($type, $chg->{postalInfo}->{$type}->{name}, $chg->{postalInfo}->{$type}->{org}, $chg->{postalInfo}->{$type}->{addr});
1633 }
1634 }
1635  
1636 # Change voice / fax / email
1637 0 for my $contact_type (qw/ voice fax email /) {
1638 0 ▶ if (defined $chg->{$contact_type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $chg->{$contact_type}) 0 0 0
1639 0 my $el = $frame->createElement("contact:$contact_type");
1640 0 $el->appendText($chg->{$contact_type});
1641 0 $frame->chg->appendChild($el);
1642 }
1643 }
1644  
1645 # Change auth info
1646 0 ▶ if ($chg->{authInfo}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chg->{"authInfo"}) 0 0 0
1647 0 $frame->chgAuthInfo($chg->{authInfo});
1648 }
1649  
1650 # 'disclose' option is still unimplemented
1651 }
1652  
1653 0 return $frame;
1654 }
1655  
1656 0 ▶sub _generate_update_host_frame {
Subroutine _generate_update_host_frame: not called CC=29 SCAR=67.7
1657 0 my ($self, $info) = @_;
1658  
1659 0 my $frame = Net::EPP::Frame::Command::Update::Host->new;
1660 0 $frame->setHost($info->{name});
1661  
1662 0 ▶ if (exists $info->{add} && ref $info->{add} eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info->{"add"} and ref $info->{"add"} eq "HASH") 0 0 0
Condition0%0/3
exists $info->{"add"} and ref $info->{"add"} eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $info->{"add"} and ref $info->{"add"} eq "HASH"
exists $info->{"add"} ref $info->{"add"} eq "HASH"
Truth table0%0/3
A and B
A= exists $info->{"add"}B= ref $info->{"add"} eq "HASH"
ABresult
0X0
100
111
1663 0 my $add = $info->{add};
1664  
1665 # Process addresses
1666 0 ▶ if (exists $add->{addrs} && ref $add->{addrs} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $add->{"addrs"} and ref $add->{"addrs"} eq "ARRAY") 0 0 0
Condition0%0/3
exists $add->{"addrs"} and ref $add->{"addrs"} eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $add->{"addrs"} and ref $add->{"addrs"} eq "ARRAY"
exists $add->{"addrs"} ref $add->{"addrs"} eq "ARRAY"
Truth table0%0/3
A and B
A= exists $add->{"addrs"}B= ref $add->{"addrs"} eq "ARRAY"
ABresult
0X0
100
111
1667 0 $frame->addAddr(@{$add->{addrs}});
1668 }
1669  
1670 # Process statuses
1671 0 ▶ if (exists $add->{status} && ref $add->{status}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $add->{"status"} and ref $add->{"status"}) 0 0 0
Condition0%0/3
exists $add->{"status"} and ref $add->{"status"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $add->{"status"} and ref $add->{"status"}
exists $add->{"status"} ref $add->{"status"}
Truth table0%0/3
A and B
A= exists $add->{"status"}B= ref $add->{"status"}
ABresult
0X0
100
111
1672 0 ▶ if (ref $add->{status} eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $add->{'status'} eq 'HASH') { } 0 0 0
elsif (ref $add->{'status'} eq 'ARRAY') { } 0 0 0
1673 0 ▶ while (my ($type, $info) = each %{$add->{status}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$add{"status"};}) 0 0 0
1674 0 $frame->addStatus($type, $info);
1675 }
1676 } elsif (ref $add->{status} eq 'ARRAY') {
1677 0 $frame->addStatus($_) for @{$add->{status}};
1678 }
1679 }
1680 }
1681  
1682 0 ▶ if (exists $info->{rem} && ref $info->{rem} eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info->{"rem"} and ref $info->{"rem"} eq "HASH") 0 0 0
Condition0%0/3
exists $info->{"rem"} and ref $info->{"rem"} eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $info->{"rem"} and ref $info->{"rem"} eq "HASH"
exists $info->{"rem"} ref $info->{"rem"} eq "HASH"
Truth table0%0/3
A and B
A= exists $info->{"rem"}B= ref $info->{"rem"} eq "HASH"
ABresult
0X0
100
111
1683 0 my $rem = $info->{rem};
1684  
1685 # Process addresses
1686 0 ▶ if (exists $rem->{addrs} && ref $rem->{addrs} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rem->{"addrs"} and ref $rem->{"addrs"} eq "ARRAY") 0 0 0
Condition0%0/3
exists $rem->{"addrs"} and ref $rem->{"addrs"} eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rem->{"addrs"} and ref $rem->{"addrs"} eq "ARRAY"
exists $rem->{"addrs"} ref $rem->{"addrs"} eq "ARRAY"
Truth table0%0/3
A and B
A= exists $rem->{"addrs"}B= ref $rem->{"addrs"} eq "ARRAY"
ABresult
0X0
100
111
1687 0 $frame->remAddr(@{$rem->{addrs}});
1688 }
1689  
1690 # Process statuses
1691 0 ▶ if (exists $rem->{status} && ref $rem->{status}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rem->{"status"} and ref $rem->{"status"}) 0 0 0
Condition0%0/3
exists $rem->{"status"} and ref $rem->{"status"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rem->{"status"} and ref $rem->{"status"}
exists $rem->{"status"} ref $rem->{"status"}
Truth table0%0/3
A and B
A= exists $rem->{"status"}B= ref $rem->{"status"}
ABresult
0X0
100
111
1692 0 ▶ if (ref $rem->{status} eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $rem->{'status'} eq 'HASH') { } 0 0 0
elsif (ref $rem->{'status'} eq 'ARRAY') { } 0 0 0
1693 0 ▶ while (my ($type, $info) = each %{$rem->{status}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$rem{"status"};}) 0 0 0
1694 0 $frame->remStatus($type, $info);
1695 }
1696 } elsif (ref $rem->{status} eq 'ARRAY') {
1697 0 $frame->remStatus($_) for @{$rem->{status}};
1698 }
1699 }
1700 }
1701  
1702 0 ▶ if (exists $info->{chg} && ref $info->{chg} eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info->{"chg"} and ref $info->{"chg"} eq "HASH") 0 0 0
Condition0%0/3
exists $info->{"chg"} and ref $info->{"chg"} eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $info->{"chg"} and ref $info->{"chg"} eq "HASH"
exists $info->{"chg"} ref $info->{"chg"} eq "HASH"
Truth table0%0/3
A and B
A= exists $info->{"chg"}B= ref $info->{"chg"} eq "HASH"
ABresult
0X0
100
111
1703 0 ▶ if ($info->{chg}->{name}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($info->{"chg"}{"name"}) 0 0 0
1704 0 $frame->chgName($info->{chg}->{name});
1705 }
1706 }
1707  
1708 0 ▶ if (exists $info->{chg} && ref $info->{chg} eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info->{"chg"} and ref $info->{"chg"} eq "HASH") 0 0 0
Condition0%0/3
exists $info->{"chg"} and ref $info->{"chg"} eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $info->{"chg"} and ref $info->{"chg"} eq "HASH"
exists $info->{"chg"} ref $info->{"chg"} eq "HASH"
Truth table0%0/3
A and B
A= exists $info->{"chg"}B= ref $info->{"chg"} eq "HASH"
ABresult
0X0
100
111
1709 0 ▶ if ($info->{chg}->{name}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($info->{"chg"}{"name"}) 0 0 0
1710 0 $frame->chgName($info->{chg}->{name});
1711 }
1712  
1713 0 ▶ if (defined $info->{chg}->{ttl} && $self->server_has_extension(Net::EPP::Frame::ObjectSpec->xmlns('ttl'))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $info->{"chg"}{"ttl"} and $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))) 0 0 0
Condition0%0/3
defined $info->{"chg"}{"ttl"} and $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))
!ll&&!rl&&r
000
MC/DC0%0/2
defined $info->{"chg"}{"ttl"} and $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))
defined $info->{"chg"}{"ttl"} $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))
Truth table0%0/3
A and B
A= defined $info->{"chg"}{"ttl"}B= $self->server_has_extension("Net::EPP::Frame::ObjectSpec"->xmlns("ttl"))
ABresult
0X0
100
111
1714 0 $frame->chgTTLs($info->{chg}->{ttl});
1715 }
1716 }
1717  
1718 0 return $frame;
1719 }
1720  
1721 =pod
1722  
1723 =head1 DELETING OBJECTS
1724  
1725 The following methods can be used to delete an object at the server:
1726  
1727 $epp->delete_domain($domain);
1728 $epp->delete_host($host);
1729 $epp->delete_contact($contact);
1730  
1731 Each of these methods has the same profile. They will return one of the following:
1732  
1733 =over
1734  
1735 =item * undef in the case of an error (check C<$Net::EPP::Simple::Error> and C<$Net::EPP::Simple::Code>).
1736  
1737 =item * 1 if the deletion request was accepted.
1738  
1739 =back
1740  
1741 You may wish to check the value of $Net::EPP::Simple::Code to determine whether the response code was 1000 (OK) or 1001 (action pending).
1742  
1743 =cut
1744  
1745 0 ▶sub delete_domain {
Subroutine delete_domain: not called CC=1 SCAR=6.9
Pod undocumented
1746 0 my ($self, $domain) = @_;
1747 0 return $self->_delete('domain', $domain);
1748 }
1749  
1750 0 ▶sub delete_host {
Subroutine delete_host: not called CC=1 SCAR=6.9
Pod undocumented
1751 0 my ($self, $host) = @_;
1752 0 return $self->_delete('host', $host);
1753 }
1754  
1755 0 ▶sub delete_contact {
Subroutine delete_contact: not called CC=1 SCAR=6.9
Pod undocumented
1756 0 my ($self, $contact) = @_;
1757 0 return $self->_delete('contact', $contact);
1758 }
1759  
1760 0 ▶sub _delete {
Subroutine _delete: not called CC=6 SCAR=37.4
1761 0 my ($self, $type, $identifier) = @_;
1762 0 my $frame;
1763 0 ▶ if ($type eq 'domain') {
Branch: 3 branches
BranchTrueFalseTotal
if ($type eq 'domain') { } 0 0 0
elsif ($type eq 'contact') { } 0 0 0
elsif ($type eq 'host') { } 0 0 0
1764 0 $frame = Net::EPP::Frame::Command::Delete::Domain->new;
1765 0 $frame->setDomain($identifier);
1766  
1767 } elsif ($type eq 'contact') {
1768 0 $frame = Net::EPP::Frame::Command::Delete::Contact->new;
1769 0 $frame->setContact($identifier);
1770  
1771 } elsif ($type eq 'host') {
1772 0 $frame = Net::EPP::Frame::Command::Delete::Host->new;
1773 0 $frame->setHost($identifier);
1774  
1775 } else {
1776 0 $Error = "Unknown object type '$type'";
1777 0 return undef;
1778  
1779 }
1780  
1781 0 my $response = $self->_request($frame);
1782  
1783 0 ▶ if (!$response) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $response) { } 0 0 0
1784 0 return undef;
1785  
1786 } else {
1787 0 $Code = $self->_get_response_code($response);
1788 0 $Message = $self->_get_message($response);
1789  
1790 0 ▶ if ($Code > 1999) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Net::EPP::Simple::Code > 1999) { } 0 0 0
1791 0 $Error = $self->_get_error_message($response);
1792 0 return undef;
1793  
1794 } else {
1795 0 return 1;
1796  
1797 }
1798 }
1799 }
1800  
1801 =head1 DOMAIN RENEWAL
1802  
1803 You can extend the validity period of the domain object by issuing a
1804 renew_domain() command.
1805  
1806 my $result = $epp->renew_domain({
1807 name => 'example.com',
1808 cur_exp_date => '2011-02-05', # current expiration date
1809 period => 2, # prolongation period in years
1810 });
1811  
1812 Return value is C<1> on success and C<undef> on error.
1813 In the case of error C<$Net::EPP::Simple::Error> contains the appropriate
1814 error message.
1815  
1816 =cut
1817  
1818 0 ▶sub renew_domain {
Subroutine renew_domain: not called CC=1 SCAR=6.9
Pod undocumented
1819 0 my ($self, $info) = @_;
1820  
1821 0 return $self->_get_response_result($self->request($self->_generate_renew_domain_frame($info)));
1822 }
1823  
1824 0 ▶sub _generate_renew_domain_frame {
Subroutine _generate_renew_domain_frame: not called CC=2 SCAR=17.9
1825 0 my ($self, $info) = @_;
1826  
1827 0 my $frame = Net::EPP::Frame::Command::Renew::Domain->new;
1828 0 $frame->setDomain($info->{name});
1829 0 $frame->setCurExpDate($info->{cur_exp_date});
1830 0 ▶ $frame->setPeriod($info->{period}) if $info->{period};
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"period"} 0 0 0
1831  
1832 0 return $frame;
1833 }
1834  
1835 =pod
1836  
1837 =head1 MISCELLANEOUS METHODS
1838  
1839 =cut
1840  
1841 0 ▶sub error { $Error }
Subroutine error: not called CC=1 SCAR=6.9
Pod documented
1842  
1843 0 ▶sub code { $Code }
Subroutine code: not called CC=1 SCAR=6.9
Pod undocumented
1844  
1845 0 ▶sub message { $Message }
Subroutine message: not called CC=1 SCAR=6.9
Pod undocumented
1846  
1847 =pod
1848  
1849 my $greeting = $epp->greeting;
1850  
1851 Returns the a L<Net::EPP::Frame::Greeting> object representing the greeting returned by the server.
1852  
1853 =cut
1854  
1855 0 ▶sub greeting {
Subroutine greeting: not called CC=1 SCAR=6.9
Pod undocumented
1856 0 my $self = shift;
1857 0 return $self->{'greeting'};
1858 }
1859  
1860 =pod
1861  
1862 $epp->ping;
1863  
1864 Checks that the connection is up by sending a C<E<lt>helloE<gt>> to the server. Returns false if no
1865 response is received.
1866  
1867 =cut
1868  
1869 0 ▶sub ping {
Subroutine ping: not called CC=2 SCAR=17.9
Pod undocumented
1870 0 my $self = shift;
1871 0 my $hello = Net::EPP::Frame::Hello->new;
1872 0 my $response = $self->request($hello);
1873  
1874 0 ▶ if (UNIVERSAL::isa($response, 'XML::LibXML::Document')) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($response, 'XML::LibXML::Document')) { } 0 0 0
1875 0 $Code = 1000;
1876 0 $Message = 'Command completed successfully.';
1877 0 return 1;
1878  
1879 } else {
1880 0 $Code = 2400;
1881 0 $Message = 'Error getting greeting from server.';
1882 0 return undef;
1883 }
1884 }
1885  
1886 0 ▶sub _request {
Subroutine _request: not called CC=5 SCAR=34.0
1887 0 my ($self, $frame) = @_;
1888  
1889 0 ▶ if ($self->{reconnect} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'reconnect'} > 0) { } 0 0 0
1890 0 $self->debug("reconnect is $self->{reconnect}, pinging");
1891 0 ▶ if (!$self->ping) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->ping) { } 0 0 0
1892 0 $self->debug('connection seems dead, trying to reconnect');
1893 0 for (1 .. $self->{reconnect}) {
1894 0 $self->debug("attempt #$_");
1895 0 ▶ if ($self->_connect) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connect) { } 0 0 0
1896 0 $self->debug("attempt #$_ succeeded");
1897 0 return $self->request($frame);
1898  
1899 } else {
1900 0 $self->debug("attempt #$_ failed, sleeping");
1901 0 sleep($self->{timeout});
1902  
1903 }
1904 }
1905 0 $self->debug('unable to reconnect!');
1906 0 return undef;
1907  
1908 } else {
1909 0 $self->debug("Connection is up, sending frame");
1910 0 return $self->request($frame);
1911  
1912 }
1913  
1914 } else {
1915 0 return $self->request($frame);
1916  
1917 }
1918 }
1919  
1920 =pod
1921  
1922 =head1 OVERRIDDEN METHODS FROM L<Net::EPP::Client>
1923  
1924 C<Net::EPP::Simple> overrides some methods inherited from
1925 L<Net::EPP::Client>. These are described below:
1926  
1927 =head2 C<request()>
1928  
1929 C<Net::EPP::Simple> overrides this method so it can automatically populate
1930 the C<E<lt>clTRIDE<gt>> element with a unique string. It then passes the
1931 frame back up to L<Net::EPP::Client>.
1932  
1933 =cut
1934  
1935 0 ▶sub request {
Subroutine request: not called CC=7 SCAR=40.3
Pod documented
1936 0 my ($self, $frame) = @_;
1937  
1938 # Make sure we start with blank variables
1939 0 $Code = undef;
1940 0 $Error = '';
1941 0 $Message = '';
1942  
1943 0 ▶ if (!$self->connected) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $self->connected) { } 0 0 0
elsif (not $frame) { } 0 0 0
1944 0 $Code = COMMAND_FAILED;
1945 0 $Error = $Message = 'Not connected';
1946 0 $self->debug('cannot send frame if not connected');
1947 0 return undef;
1948  
1949 } elsif (!$frame) {
1950 0 $Code = COMMAND_FAILED;
1951 0 $Error = $Message = 'Invalid frame';
1952 0 $self->debug($Message);
1953 0 return undef;
1954  
1955 } else {
1956 0 ▶ $frame->clTRID->appendText(sha1_hex(ref($self) . time() . $$)) if (UNIVERSAL::isa($frame, 'Net::EPP::Frame::Command'));
Branch: 1 branch
BranchTrueFalseTotal
if UNIVERSAL::isa($frame, "Net::EPP::Frame::Command") 0 0 0
1957  
1958 0 my $type = ref($frame);
1959 0 ▶ if ($frame =~ /^\//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($frame =~ m[^/]) { } 0 0 0
1960 0 $type = 'file';
1961  
1962 } else {
1963 0 $type = 'string';
1964  
1965 }
1966 0 $self->debug(sprintf('sending a %s to the server', $type));
1967 0 ▶ if (UNIVERSAL::isa($frame, 'XML::LibXML::Document')) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($frame, 'XML::LibXML::Document')) { } 0 0 0
1968 0 map { $self->debug('C: ' . $_) } split(/\n/, $frame->toString(2));
1969  
1970 } else {
1971 0 map { $self->debug('C: ' . $_) } split(/\n/, $frame);
1972  
1973 }
1974  
1975 0 my $response = $self->SUPER::request($frame);
1976  
1977 0 ▶ map { $self->debug('S: ' . $_) } split(/\n/, $response->toString(2)) if (UNIVERSAL::isa($response, 'XML::LibXML::Document'));
Branch: 1 branch
BranchTrueFalseTotal
if UNIVERSAL::isa($response, "XML::LibXML::Document") 0 0 0
1978  
1979 0 return $response;
1980 }
1981 }
1982  
1983 =pod
1984  
1985 =head2 C<get_frame()>
1986  
1987 C<Net::EPP::Simple> overrides this method so it can catch timeouts and
1988 network errors. If such an error occurs it will return C<undef>.
1989  
1990 =cut
1991  
1992 0 ▶sub get_frame {
Subroutine get_frame: not called CC=4 SCAR=30.0
Pod documented
1993 0 my $self = shift;
1994 0 ▶ if (!$self->connected) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->connected) { } 0 0 0
1995 0 $self->debug('cannot get frame if not connected');
1996 0 $Code = COMMAND_FAILED;
1997 0 $Error = $Message = 'Not connected';
1998 0 return undef;
1999  
2000 } else {
2001 0 my $frame;
2002 0 $self->debug(sprintf('reading frame, waiting %d seconds before timeout', $self->{timeout}));
2003 0 eval {
2004 0 ▶ local $SIG{ALRM} = sub { die 'timeout' };
Subroutine __ANON__: not called CC=1 SCAR=6.9
2005 0 $self->debug('setting timeout alarm for receiving frame');
2006 0 alarm($self->{timeout});
2007 0 $frame = $self->SUPER::get_frame();
2008 0 $self->debug('unsetting timeout alarm after successful receive');
2009 0 alarm(0);
2010 };
2011 0 ▶ if ($@ ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ ne '') { } 0 0 0
2012 0 chomp($@);
2013 0 $@ =~ s/ at .+ line .+$//;
2014 0 $self->debug("unsetting timeout alarm after alarm was triggered ($@)");
2015 0 alarm(0);
2016 0 $Code = COMMAND_FAILED;
2017 0 ▶ if ($@ =~ /^timeout/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ =~ /^timeout/) { } 0 0 0
2018 0 $Error = $Message = "get_frame() timed out after $self->{timeout} seconds";
2019  
2020 } else {
2021 0 $Error = $Message = "get_frame() received an error: $@";
2022  
2023 }
2024 0 return undef;
2025  
2026 } else {
2027 0 return bless($frame, 'Net::EPP::Frame::Response');
2028  
2029 }
2030 }
2031 }
2032  
2033 0 ▶sub send_frame {
Subroutine send_frame: not called CC=2 SCAR=17.9
Pod undocumented
2034 0 my ($self, $frame, $wfcheck) = @_;
2035 0 ▶ if (!$self->connected) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->connected) { } 0 0 0
2036 0 $self->debug('cannot send frame if not connected');
2037 0 $Code = 2400;
2038 0 $Message = 'Not connected';
2039 0 return undef;
2040  
2041 } else {
2042 0 return $self->SUPER::send_frame($frame, $wfcheck);
2043  
2044 }
2045 }
2046  
2047 # Get details error description including code, message and reason
2048 0 ▶sub _get_error_message {
Subroutine _get_error_message: not called CC=3 SCAR=24.8
2049 0 my ($self, $doc) = @_;
2050  
2051 0 my $code = $self->_get_response_code($doc);
2052 0 my $error = "Error $code";
2053  
2054 0 my $message = $self->_get_message($doc);
2055 0 ▶ if ($message) {
Branch: 1 branch
BranchTrueFalseTotal
if ($message) 0 0 0
2056 0 $error .= ": $message";
2057 }
2058  
2059 0 my $reason = $self->_get_reason($doc);
2060 0 ▶ if ($reason) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reason) 0 0 0
2061 0 $error .= " ($reason)";
2062 }
2063  
2064 0 return $error;
2065 }
2066  
2067 0 ▶sub _get_response_code {
Subroutine _get_response_code: not called CC=5 SCAR=34.0
2068 0 my ($self, $doc) = @_;
2069 0 ▶ if ($doc->isa('XML::DOM::Document') || $doc->isa('Net::EPP::Frame::Response')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($doc->isa("XML::DOM::Document") or $doc->isa("Net::EPP::Frame::Response")) 0 0 0
Condition0%0/3
$doc->isa("XML::DOM::Document") or $doc->isa("Net::EPP::Frame::Response")
l!l&&r!l&&!r
000
MC/DC0%0/2
$doc->isa("XML::DOM::Document") or $doc->isa("Net::EPP::Frame::Response")
$doc->isa("XML::DOM::Document") $doc->isa("Net::EPP::Frame::Response")
Truth table0%0/3
A or B
A= $doc->isa("XML::DOM::Document")B= $doc->isa("Net::EPP::Frame::Response")
ABresult
1X1
011
000
2070 0 my $els = $doc->getElementsByTagNameNS(EPP_XMLNS, 'result');
2071 0 ▶ if (defined($els)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $els) 0 0 0
2072 0 my $el = $els->shift;
2073 0 ▶ return $el->getAttribute('code') if (defined($el));
Branch: 1 branch
BranchTrueFalseTotal
if defined $el 0 0 0
2074 }
2075 }
2076 0 return 2400;
2077 }
2078  
2079 0 ▶sub _get_message {
Subroutine _get_message: not called CC=5 SCAR=34.0
2080 0 my ($self, $doc) = @_;
2081 0 ▶ if ($doc->isa('XML::DOM::Document') || $doc->isa('Net::EPP::Frame::Response')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($doc->isa("XML::DOM::Document") or $doc->isa("Net::EPP::Frame::Response")) 0 0 0
Condition0%0/3
$doc->isa("XML::DOM::Document") or $doc->isa("Net::EPP::Frame::Response")
l!l&&r!l&&!r
000
MC/DC0%0/2
$doc->isa("XML::DOM::Document") or $doc->isa("Net::EPP::Frame::Response")
$doc->isa("XML::DOM::Document") $doc->isa("Net::EPP::Frame::Response")
Truth table0%0/3
A or B
A= $doc->isa("XML::DOM::Document")B= $doc->isa("Net::EPP::Frame::Response")
ABresult
1X1
011
000
2082 0 my $msgs = $doc->getElementsByTagNameNS(EPP_XMLNS, 'msg');
2083 0 ▶ if (defined($msgs)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $msgs) 0 0 0
2084 0 my $msg = $msgs->shift;
2085 0 ▶ return $msg->textContent if (defined($msg));
Branch: 1 branch
BranchTrueFalseTotal
if defined $msg 0 0 0
2086 }
2087 }
2088 0 return '';
2089 }
2090  
2091 0 ▶sub _get_reason {
Subroutine _get_reason: not called CC=5 SCAR=34.0
2092 0 my ($self, $doc) = @_;
2093 0 ▶ if ($doc->isa('XML::DOM::Document') || $doc->isa('Net::EPP::Frame::Response')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($doc->isa("XML::DOM::Document") or $doc->isa("Net::EPP::Frame::Response")) 0 0 0
Condition0%0/3
$doc->isa("XML::DOM::Document") or $doc->isa("Net::EPP::Frame::Response")
l!l&&r!l&&!r
000
MC/DC0%0/2
$doc->isa("XML::DOM::Document") or $doc->isa("Net::EPP::Frame::Response")
$doc->isa("XML::DOM::Document") $doc->isa("Net::EPP::Frame::Response")
Truth table0%0/3
A or B
A= $doc->isa("XML::DOM::Document")B= $doc->isa("Net::EPP::Frame::Response")
ABresult
1X1
011
000
2094 0 my $reasons = $doc->getElementsByTagNameNS(EPP_XMLNS, 'reason');
2095 0 ▶ if (defined($reasons)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $reasons) 0 0 0
2096 0 my $reason = $reasons->shift;
2097 0 ▶ if (defined($reason)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $reason) 0 0 0
2098 0 return $reason->textContent;
2099 }
2100 }
2101 }
2102 0 return '';
2103 }
2104  
2105 0 ▶sub logout {
Subroutine logout: not called CC=3 SCAR=24.8
Pod undocumented
2106 0 my $self = shift;
2107 0 ▶ if ($self->authenticated) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->authenticated) 0 0 0
2108 0 $self->debug('logging out');
2109 0 my $response = $self->request(Net::EPP::Frame::Command::Logout->new);
2110 0 undef($self->{'authenticated'});
2111 0 ▶ if (!$response) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $response) { } 0 0 0
2112 0 $Code = COMMAND_FAILED;
2113 0 $Message = $Error = 'unknown error';
2114 0 return undef;
2115  
2116 } else {
2117 0 $Code = $self->_get_response_code($response);
2118 0 $Message = $self->_get_message($response);
2119  
2120 }
2121 }
2122 0 $self->debug('disconnecting from server');
2123 0 $self->disconnect;
2124 0 return 1;
2125 }
2126  
2127 0 ▶sub DESTROY {
Subroutine DESTROY: not called CC=2 SCAR=17.9
2128 0 my $self = shift;
2129 0 $self->debug('DESTROY() method called');
2130 0 ▶ $self->logout if ($self->connected);
Branch: 1 branch
BranchTrueFalseTotal
if $self->connected 0 0 0
2131 }
2132  
2133 0 ▶sub debug {
Subroutine debug: not called CC=3 SCAR=24.8
Pod documented
2134 0 my ($self, $msg) = @_;
2135 0 my $log = sprintf("%s (%d): %s", scalar(localtime()), $$, $msg);
2136 0 push(@Log, $log);
2137 0 ▶ print STDERR $log . "\n" if (defined($self->{debug}) && $self->{debug} == 1);
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"debug"} and $self->{"debug"} == 1 0 0 0
Condition0%0/3
defined $self->{"debug"} and $self->{"debug"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"debug"} and $self->{"debug"} == 1
defined $self->{"debug"} $self->{"debug"} == 1
Truth table0%0/3
A and B
A= defined $self->{"debug"}B= $self->{"debug"} == 1
ABresult
0X0
100
111
2138 }
2139  
2140 =pod
2141  
2142 $bool = $epp->server_has_object($xmlns);
2143 $bool = $epp->server_has_extension($xmlns);
2144  
2145 These methods both return a true value if the object/extension identified by
2146 C<$xmlns> was present in the server's greeting.
2147  
2148 =cut
2149  
2150 0 ▶sub server_has_object {
Subroutine server_has_object: not called CC=4 SCAR=30.0
Pod undocumented
2151 0 my ($self, $xmlns) = @_;
2152  
2153 0 ▶ if (!$self->greeting) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->greeting) 0 0 0
2154 0 carp('not connected');
2155 0 return undef;
2156 }
2157  
2158 0 foreach my $objURI ($self->greeting->getElementsByTagName('objURI')) {
2159 0 ▶ return 1 if ($objURI->textContent eq $xmlns);
Branch: 1 branch
BranchTrueFalseTotal
if $objURI->textContent eq $xmlns 0 0 0
2160 }
2161  
2162 0 return undef;
2163 }
2164  
2165 0 ▶sub server_has_extension {
Subroutine server_has_extension: not called CC=4 SCAR=30.0
Pod undocumented
2166 0 my ($self, $xmlns) = @_;
2167  
2168 0 ▶ if (!$self->greeting) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->greeting) 0 0 0
2169 0 carp('not connected');
2170 0 return undef;
2171 }
2172  
2173 0 foreach my $extURI ($self->greeting->getElementsByTagName('extURI')) {
2174 0 ▶ return 1 if ($extURI->textContent eq $xmlns);
Branch: 1 branch
BranchTrueFalseTotal
if $extURI->textContent eq $xmlns 0 0 0
2175 }
2176  
2177 0 return undef;
2178 }
2179  
2180 =pod
2181  
2182 $authenticated = $epp->authenticated;
2183  
2184 Returns a boolean if C<Net::EPP::Simple> has successfully authenticated with the server.
2185  
2186 =cut
2187  
2188 0 ▶sub authenticated {
Subroutine authenticated: not called CC=1 SCAR=6.9
Pod undocumented
2189 0 my $self = shift;
2190 0 return defined($self->{'authenticated'});
2191 }
2192  
2193 1 1;
2194  
2195 =pod
2196  
2197 =head1 PACKAGE VARIABLES
2198  
2199 =head2 $Net::EPP::Simple::Error
2200  
2201 This variable contains an english text message explaining the last error
2202 to occur. This is may be due to invalid parameters being passed to a
2203 method, a network error, or an error response being returned by the
2204 server.
2205  
2206 =head2 $Net::EPP::Simple::Message
2207  
2208 This variable contains the contains the text content of the
2209 C<E<lt>msgE<gt>> element in the response frame for the last transaction.
2210  
2211 =head2 $Net::EPP::Simple::Code
2212  
2213 This variable contains the integer result code returned by the server
2214 for the last transaction. A successful transaction will always return an
2215 error code of 1999 or lower, for an unsuccessful transaction it will be
2216 2011 or more. If there is an internal client error (due to invalid
2217 parameters being passed to a method, or a network error) then this will
2218 be set to 2400 (C<COMMAND_FAILED>). See L<Net::EPP::ResponseCodes> for
2219 more information about thes codes.
2220  
2221 =head1 COPYRIGHT
2222  
2223 This module is (c) 2008 - 2023 CentralNic Ltd and 2024 Gavin Brown. This module
2224 is free software; you can redistribute it and/or modify it under the same terms
2225 as Perl itself.
2226  
2227 =cut
↑ Summary EPP/Protocol.pm »