File Coverage

blib/lib/Net/DRI/Protocol/EPP/Extensions/AT/Domain.pm
Criterion Covered Total %
statement 15 72 20.8
branch 0 32 0.0
condition 0 3 0.0
subroutine 5 10 50.0
pod 0 5 0.0
total 20 122 16.3


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, nic.at domain transactions extension
2             ## Contributed by Michael Braunoeder from NIC.AT
3             ##
4             ## Copyright (c) 2006-2008,2013,2016 Patrick Mevzek . All rights reserved.
5             ##
6             ## This file is part of Net::DRI
7             ##
8             ## Net::DRI is free software; you can redistribute it and/or modify
9             ## it under the terms of the GNU General Public License as published by
10             ## the Free Software Foundation; either version 2 of the License, or
11             ## (at your option) any later version.
12             ##
13             ## See the LICENSE file that comes with this distribution for more details.
14             ####################################################################################################
15              
16             package Net::DRI::Protocol::EPP::Extensions::AT::Domain;
17              
18 1     1   891 use strict;
  1         2  
  1         23  
19 1     1   3 use warnings;
  1         2  
  1         20  
20 1     1   3 use feature 'state';
  1         1  
  1         65  
21              
22 1     1   3 use Net::DRI::Util;
  1         1  
  1         20  
23 1     1   3 use Net::DRI::Exception;
  1         2  
  1         571  
24              
25             our $NS = 'http://www.nic.at/xsd/at-ext-domain-1.0';
26             our $ExtNS = 'http://www.nic.at/xsd/at-ext-epp-1.0';
27              
28             ####################################################################################################
29              
30             sub register_commands {
31 0     0 0   my ( $class, $version ) = @_;
32 0           state $rops = { domain => { nocommand => [ \&extonly, \&extonly_parse_result ],
33             delete => [ \&delete, undef ],
34             transfer_request => [ \&transfer_request, \&extonly_parse_result ],
35             },
36             };
37 0           return $rops;
38             }
39              
40             ####################################################################################################
41              
42             sub extonly {
43 0     0 0   my ( $epp, $domain, $rd ) = @_;
44              
45 0           my $transaction;
46 0 0         $transaction = $rd->{transactionname} if $rd->{transactionname};
47              
48 0 0         return unless ($transaction);
49              
50 0           my $mes = $epp->message();
51              
52 0 0 0       Net::DRI::Exception->die(1,'protocol/EPP',2,'Domain name needed') unless defined($domain) && $domain;
53 0 0         Net::DRI::Exception->die(1,'protocol/EPP',10,'Invalid domain name: '.$domain) unless Net::DRI::Util::is_hostname($domain);
54             ##$mes->command_body([['domain:name',$domain]]); ## Useless if pure extension
55            
56 0           my $eid = $mes->command_extension_register( 'command',
57             'xmlns="' . $ExtNS
58             . '" xsi:schemaLocation="'
59             . $ExtNS
60             . ' at-ext-epp-1.0.xsd"' );
61              
62              
63 0           my $cltrid=$mes->cltrid();
64              
65 0 0         if ( $transaction eq 'withdraw' ) {
    0          
66              
67 0           my %domns;
68 0           $domns{'xmlns:domain'} = $NS;
69 0           $domns{'xsi:schemaLocation'} = $NS . ' at-ext-domain-1.0.xsd';
70              
71 0           my %zdhash;
72 0 0         $zdhash{'value'} = $rd->{zd} ? $rd->{zd} : 0;
73            
74 0           $mes->command_extension(
75             $eid,
76              
77             [
78             ['withdraw',
79             [ 'domain:withdraw', ['domain:name', $domain], \%domns ,
80             ['domain:zd', \%zdhash], \%domns ]],
81             ['clTRID', $cltrid ]
82              
83             ]
84             );
85              
86              
87             }
88             elsif ( $transaction eq 'transfer_execute' ) {
89              
90              
91 0           my $token;
92 0 0         $token = $rd->{token} if $rd->{token};
93              
94 0 0         return unless ( defined($token) );
95              
96 0           my %domns;
97 0           $domns{'xmlns:domain'} = 'urn:ietf:params:xml:ns:domain-1.0';
98 0           $domns{'xsi:schemaLocation'} = 'urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd';
99              
100 0           my %domns2;
101 0           $domns2{'xmlns:at-ext-domain'} = $NS;
102 0           $domns2{'xsi:schemaLocation'} = $NS . ' at-ext-domain-1.0.xsd';
103              
104              
105              
106 0           $mes->command_extension(
107             $eid,
108             [
109             ['transfer',
110              
111             { 'op' => 'execute' },
112             [ 'domain:transfer', \%domns, [ 'domain:name', $domain ]
113             ]
114             ],
115             ['extension',
116             ['at-ext-domain:transfer' , \%domns2, ['at-ext-domain:token',$token]
117             ]
118             ],
119             ['clTRID', $cltrid]
120             ]
121             );
122              
123             }
124 0           return;
125             }
126              
127             sub delete { ## no critic (Subroutines::ProhibitBuiltinHomonyms)
128              
129 0     0 0   my ( $epp, $domain, $rd ) = @_;
130 0           my $mes = $epp->message();
131              
132 0           my $scheduledate;
133 0 0         $scheduledate = $rd->{scheduledate} if $rd->{scheduledate};
134              
135 0 0         return unless ( defined($scheduledate) );
136              
137 0           my $eid = $mes->command_extension_register( 'at-ext-domain:delete',
138             'xmlns:at-ext-domain="' . $NS
139             . '" xsi:schemaLocation="'
140             . $NS
141             . ' at-ext-domain-1.0.xsd"' );
142              
143 0           $mes->command_extension( $eid,
144             [ 'at-ext-domain:scheduledate', $scheduledate ] );
145 0           return;
146             }
147              
148             sub transfer_request {
149 0     0 0   my ( $epp, $domain, $rd ) = @_;
150 0           my $mes = $epp->message();
151              
152 0           my $registrarinfo;
153 0 0         $registrarinfo = $rd->{registrarinfo} if $rd->{registrarinfo};
154              
155 0 0         return unless ( defined($registrarinfo) );
156              
157 0           my $eid = $mes->command_extension_register( 'at-ext-domain:clientdata',
158             'xmlns:at-ext-domain="' . $NS
159             . '" xsi:schemaLocation="'
160             . $NS
161             . ' at-ext-domain-1.0.xsd"' );
162              
163 0           my %entryname;
164 0           $entryname{name} = 'Registrarinfo';
165 0           $mes->command_extension( $eid,
166             [ 'at-ext-domain:entry', \%entryname, $registrarinfo ] );
167 0           return;
168             }
169              
170             sub extonly_parse_result {
171 0     0 0   my ($po,$otype,$oaction,$oname,$rinfo)=@_;
172 0           my $mes=$po->message();
173 0 0         return unless $mes->is_success();
174              
175 0           my $keydatedata=$mes->get_extension($NS,'keydate');
176 0 0         return unless defined $keydatedata;
177              
178 0           my $keydate = $keydatedata->textContent();
179 0 0         return unless defined $keydate;
180              
181 0           $rinfo->{domain}->{$oname}->{keydate}=$keydate;
182              
183 0           return;
184             }
185              
186              
187              
188             ####################################################################################################
189             1;
190              
191             __END__