line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SRS::EPP::Command::Create::Domain; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$SRS::EPP::Command::Create::Domain::VERSION = '0.22'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
3181
|
use Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
7
|
|
|
|
|
|
|
extends 'SRS::EPP::Command::Create'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'SRS::EPP::Common::Domain::NameServers'; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
7797
|
use MooseX::Params::Validate; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
12
|
1
|
|
|
1
|
|
509
|
use SRS::EPP::Session; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use XML::EPP::Domain; |
14
|
|
|
|
|
|
|
use XML::SRS::TimeStamp; |
15
|
|
|
|
|
|
|
use XML::SRS::Server::List; |
16
|
|
|
|
|
|
|
use XML::SRS::Server; |
17
|
|
|
|
|
|
|
use XML::SRS::Contact; |
18
|
|
|
|
|
|
|
use XML::SRS::DS; |
19
|
|
|
|
|
|
|
use XML::SRS::DS::List; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use feature 'switch'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# for plugin system to connect |
24
|
|
|
|
|
|
|
sub xmlns { |
25
|
|
|
|
|
|
|
return XML::EPP::Domain::Node::xmlns(); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub process { |
29
|
|
|
|
|
|
|
my $self = shift; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my ( $session ) = pos_validated_list( |
32
|
|
|
|
|
|
|
\@_, |
33
|
|
|
|
|
|
|
{ isa => 'SRS::EPP::Session' }, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$self->session($session); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $epp = $self->message; |
39
|
|
|
|
|
|
|
my $message = $epp->message; |
40
|
|
|
|
|
|
|
my $payload = $message->argument->payload; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$self->log_info("$self registering ".$payload->name); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# find the admin contact |
45
|
|
|
|
|
|
|
my $contacts = $payload->contact; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# create all the contacts (using their handles) |
48
|
|
|
|
|
|
|
my $contact_registrant = XML::SRS::Contact->new( handle_id => $payload->registrant() ); |
49
|
|
|
|
|
|
|
$self->log_info("$self registrant = ".$payload->registrant); |
50
|
|
|
|
|
|
|
my ($contact_admin, $contact_technical); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
foreach my $contact (@$contacts) { |
53
|
|
|
|
|
|
|
given ($contact->type) { |
54
|
|
|
|
|
|
|
when ('admin') { |
55
|
|
|
|
|
|
|
if ($contact_admin) { |
56
|
|
|
|
|
|
|
$self->log_error("$self multiple admin contacts"); |
57
|
|
|
|
|
|
|
return $self->make_error( |
58
|
|
|
|
|
|
|
code => 2306, |
59
|
|
|
|
|
|
|
message => 'Only one admin contact per domain supported', |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
$contact_admin = XML::SRS::Contact->new( handle_id => $contact->value ); |
63
|
|
|
|
|
|
|
$self->log_info("$self admin contact = ".$contact->value); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
when ('tech') { |
66
|
|
|
|
|
|
|
if ($contact_technical) { |
67
|
|
|
|
|
|
|
$self->log_error("$self multiple tech contacts"); |
68
|
|
|
|
|
|
|
return $self->make_error( |
69
|
|
|
|
|
|
|
code => 2306, |
70
|
|
|
|
|
|
|
message => 'Only one tech contact per domain supported', |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
$contact_technical = XML::SRS::Contact->new( handle_id => $contact->value ); |
74
|
|
|
|
|
|
|
$self->log_info("$self tech contact = ".$contact->value); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
default { |
77
|
|
|
|
|
|
|
# Contacts other than admin or tech not supported |
78
|
|
|
|
|
|
|
return $self->make_error( |
79
|
|
|
|
|
|
|
code => 2102, |
80
|
|
|
|
|
|
|
message => "Only contacts of type 'admin' or 'tech' are supported", |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $term = 1; |
87
|
|
|
|
|
|
|
my $default = " (default)"; |
88
|
|
|
|
|
|
|
if ($payload->period) { |
89
|
|
|
|
|
|
|
$term = $payload->period->months; |
90
|
|
|
|
|
|
|
$default = ""; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
$self->log_info("$self registering for $term month(s)$default"); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
my $request = XML::SRS::Domain::Create->new( |
95
|
|
|
|
|
|
|
domain_name => $payload->name(), |
96
|
|
|
|
|
|
|
term => $term, |
97
|
|
|
|
|
|
|
contact_registrant => $contact_registrant, |
98
|
|
|
|
|
|
|
$contact_admin ? (contact_admin => $contact_admin) : (), |
99
|
|
|
|
|
|
|
$contact_technical ? (contact_technical => $contact_technical) : (), |
100
|
|
|
|
|
|
|
action_id => $self->client_id || $self->server_id, |
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
my $ns = $payload->ns ? $payload->ns->ns : undef; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
if ($ns) { |
106
|
|
|
|
|
|
|
my @ns_objs = eval { $self->translate_ns_epp_to_srs(@$ns); }; |
107
|
|
|
|
|
|
|
my $error = $@; |
108
|
|
|
|
|
|
|
if ($error) { |
109
|
|
|
|
|
|
|
$self->log_error("$self error in nameservers; $error"); |
110
|
|
|
|
|
|
|
return $error if $error->isa('SRS::EPP::Response::Error'); |
111
|
|
|
|
|
|
|
die $error; # rethrow |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
$self->log_info("$self provided ".@ns_objs." nameserver(s)"); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my $list = XML::SRS::Server::List->new( |
116
|
|
|
|
|
|
|
nameservers => \@ns_objs, |
117
|
|
|
|
|
|
|
); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
$request->nameservers($list); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
else { |
122
|
|
|
|
|
|
|
$self->log_info("$self: no nameservers provided"); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
my @ds; |
126
|
|
|
|
|
|
|
if ($message->extension) { |
127
|
|
|
|
|
|
|
foreach my $ext_obj (@{ $message->extension->ext_objs }) { |
128
|
|
|
|
|
|
|
if ($ext_obj->isa('XML::EPP::DNSSEC::Create')) { |
129
|
|
|
|
|
|
|
# Check for any elements we don't support |
130
|
|
|
|
|
|
|
if ($ext_obj->key_data) { |
131
|
|
|
|
|
|
|
return $self->make_error( |
132
|
|
|
|
|
|
|
code => 2306, |
133
|
|
|
|
|
|
|
message => 'Key data not supported', |
134
|
|
|
|
|
|
|
); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
if ($ext_obj->max_sig_life) { |
138
|
|
|
|
|
|
|
return $self->make_error( |
139
|
|
|
|
|
|
|
code => 2306, |
140
|
|
|
|
|
|
|
message => 'Max sig life not supported', |
141
|
|
|
|
|
|
|
); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# Make sure we have some ds data |
145
|
|
|
|
|
|
|
unless ($ext_obj->ds_data) { |
146
|
|
|
|
|
|
|
return $self->make_error( |
147
|
|
|
|
|
|
|
code => 2306, |
148
|
|
|
|
|
|
|
message => 'At least one dsData element must be supplied', |
149
|
|
|
|
|
|
|
); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
foreach my $epp_ds (@{$ext_obj->ds_data}) { |
153
|
|
|
|
|
|
|
push @ds, XML::SRS::DS->new( |
154
|
|
|
|
|
|
|
key_tag => $epp_ds->key_tag, |
155
|
|
|
|
|
|
|
algorithm => $epp_ds->alg, |
156
|
|
|
|
|
|
|
digest => $epp_ds->digest, |
157
|
|
|
|
|
|
|
digest_type => $epp_ds->digest_type, |
158
|
|
|
|
|
|
|
); |
159
|
|
|
|
|
|
|
}; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
$request->dns_sec(\@ds); |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
return $request; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub notify { |
170
|
|
|
|
|
|
|
my $self = shift; |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
my ( $rs ) = pos_validated_list( |
173
|
|
|
|
|
|
|
\@_, |
174
|
|
|
|
|
|
|
{ isa => 'ArrayRef[SRS::EPP::SRSResponse]' }, |
175
|
|
|
|
|
|
|
); |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
my $epp = $self->message; |
178
|
|
|
|
|
|
|
my $eppMessage = $epp->message; |
179
|
|
|
|
|
|
|
my $eppPayload = $eppMessage->argument->payload; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
my $message = $rs->[0]->message; |
182
|
|
|
|
|
|
|
my $response = $message->response; |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
$self->log_info("$self: registered ".$response->name." OK"); |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
# let's create the returned create domain response |
187
|
|
|
|
|
|
|
my $r = XML::EPP::Domain::Create::Response->new( |
188
|
|
|
|
|
|
|
name => $response->name, |
189
|
|
|
|
|
|
|
created => $response->registered_date->timestamptz, |
190
|
|
|
|
|
|
|
expiry_date => $response->billed_until->timestamptz, |
191
|
|
|
|
|
|
|
); |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
return $self->make_response( |
194
|
|
|
|
|
|
|
code => 1000, |
195
|
|
|
|
|
|
|
payload => $r, |
196
|
|
|
|
|
|
|
); |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
1; |