epp-eis 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +5 -0
- data/Guardfile +5 -0
- data/README.markdown +57 -0
- data/Rakefile +1 -0
- data/epp-eis.gemspec +25 -0
- data/lib/epp-eis/contact.rb +271 -0
- data/lib/epp-eis/domain.rb +410 -0
- data/lib/epp-eis/extensions.rb +22 -0
- data/lib/epp-eis/nsset.rb +246 -0
- data/lib/epp-eis/session.rb +94 -0
- data/lib/epp-eis/version.rb +5 -0
- data/lib/epp-eis.rb +8 -0
- data/spec/legaldocs/test.pdf +0 -0
- data/spec/lib/epp-eis/contact_spec.rb +107 -0
- data/spec/lib/epp-eis/domain_spec.rb +189 -0
- data/spec/lib/epp-eis/nsset_spec.rb +87 -0
- data/spec/lib/epp-eis/session_spec.rb +18 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/support/file_mocks.rb +7 -0
- data/spec/xml/requests/contact/check_contact.xml +11 -0
- data/spec/xml/requests/contact/create_contact.xml +23 -0
- data/spec/xml/requests/contact/delete_contact.xml +11 -0
- data/spec/xml/requests/contact/info_contact.xml +11 -0
- data/spec/xml/requests/contact/update_contact.xml +29 -0
- data/spec/xml/requests/domain/create_domain.xml +21 -0
- data/spec/xml/requests/domain/delete_domain.xml +16 -0
- data/spec/xml/requests/domain/get_results.xml +9 -0
- data/spec/xml/requests/domain/list_domains.xml +9 -0
- data/spec/xml/requests/domain/transfer_domain.xml +17 -0
- data/spec/xml/requests/domain/update_domain.xml +28 -0
- data/spec/xml/requests/nsset/check_nsset.xml +12 -0
- data/spec/xml/requests/nsset/create_nsset.xml +20 -0
- data/spec/xml/requests/nsset/delete_nsset.xml +11 -0
- data/spec/xml/requests/nsset/info_nsset.xml +11 -0
- data/spec/xml/requests/nsset/update_nsset.xml +22 -0
- data/spec/xml/requests/session/hello.xml +4 -0
- data/spec/xml/responses/contact/check_contact_1000.xml +23 -0
- data/spec/xml/responses/contact/create_contact_1000.xml +18 -0
- data/spec/xml/responses/contact/delete_contact_1000.xml +12 -0
- data/spec/xml/responses/contact/get_results_list_contacts_1000.xml +24 -0
- data/spec/xml/responses/contact/info_contact_1000.xml +35 -0
- data/spec/xml/responses/contact/update_contact_1000.xml +12 -0
- data/spec/xml/responses/domain/check_domain_1000.xml +23 -0
- data/spec/xml/responses/domain/check_domain_available_1000.xml +19 -0
- data/spec/xml/responses/domain/check_domain_taken_1000.xml +20 -0
- data/spec/xml/responses/domain/create_domain_1000.xml +19 -0
- data/spec/xml/responses/domain/delete_domain_1000.xml +12 -0
- data/spec/xml/responses/domain/get_results_list_domains_1000.xml +18 -0
- data/spec/xml/responses/domain/info_domain_1000.xml +27 -0
- data/spec/xml/responses/domain/list_domains_1000.xml +17 -0
- data/spec/xml/responses/domain/renew_domain_1000.xml +18 -0
- data/spec/xml/responses/domain/transfer_domain_1000.xml +12 -0
- data/spec/xml/responses/domain/update_domain_1000.xml +12 -0
- data/spec/xml/responses/nsset/check_nsset_1000.xml +22 -0
- data/spec/xml/responses/nsset/create_nsset_1000.xml +18 -0
- data/spec/xml/responses/nsset/delete_nsset_1000.xml +12 -0
- data/spec/xml/responses/nsset/info_nsset_1000.xml +33 -0
- data/spec/xml/responses/nsset/update_nsset_1000.xml +12 -0
- data/spec/xml/responses/session/hello.xml +36 -0
- metadata +214 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
guard 'rspec', :version => 2, :cli => "--color", :bundler => true, :all_on_start => false, :all_after_pass => false, :keep_failed => true, :notification => false do
|
2
|
+
watch('spec/spec_helper.rb') { "spec" }
|
3
|
+
watch(%r{^spec/.+_spec\.rb})
|
4
|
+
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
5
|
+
end
|
data/README.markdown
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
Ruby client for Estonian Internet Foundation registry EPP server.
|
2
|
+
|
3
|
+
Under the hood, this gem uses magnificient [EPP server client](https://github.com/ultraspeed/epp) gem by Josh Delsman and Delwyn de Villiers.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
In Gemfile add it as a gem:
|
8
|
+
|
9
|
+
gem 'epp-eis'
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
require 'epp-eis'
|
14
|
+
|
15
|
+
server = Epp::Server.new(
|
16
|
+
:server => '127.0.0.1',
|
17
|
+
:tag => 'username',
|
18
|
+
:password => 'password',
|
19
|
+
:cert => OpenSSL::X509::Certificate.new(File.open('certificate.pem')),
|
20
|
+
:key => OpenSSL::PKey::RSA.new(File.open('priv_key.pem'))
|
21
|
+
)
|
22
|
+
|
23
|
+
server.is_domain_available?('fraktal.ee') #=> false
|
24
|
+
|
25
|
+
## TODO
|
26
|
+
|
27
|
+
Need to implement the following commands
|
28
|
+
|
29
|
+
* credit_info
|
30
|
+
|
31
|
+
Commands that are nice to have, but not needed.
|
32
|
+
|
33
|
+
* check_keyset
|
34
|
+
* create_keyset
|
35
|
+
* delete_keyset
|
36
|
+
* get_results
|
37
|
+
* info_keyset
|
38
|
+
* list_keysets
|
39
|
+
* poll
|
40
|
+
* prep_contacts
|
41
|
+
* prep_domains
|
42
|
+
* prep_domains_by_contact
|
43
|
+
* prep_domains_by_keyset
|
44
|
+
* prep_domains_by_nsset
|
45
|
+
* prep_keysets
|
46
|
+
* prep_keysets_by_contact
|
47
|
+
* prep_nssets
|
48
|
+
* prep_nssets_by_contact
|
49
|
+
* prep_nssets_by_ns
|
50
|
+
* sendauthinfo_contact
|
51
|
+
* sendauthinfo_domain
|
52
|
+
* sendauthinfo_keyset
|
53
|
+
* sendauthinfo_nsset
|
54
|
+
* technical_test
|
55
|
+
* transfer_contact
|
56
|
+
* transfer_keyset
|
57
|
+
* update_keyset
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/epp-eis.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'epp-eis/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'epp-eis'
|
7
|
+
s.version = Eis::Epp::VERSION
|
8
|
+
s.authors = ['Priit Haamer']
|
9
|
+
s.email = ['priit@fraktal.ee']
|
10
|
+
s.homepage = 'https://github.com/priithaamer/epp-eis'
|
11
|
+
s.summary = %q{Estonian Internet Foundation EPP service client}
|
12
|
+
s.description = %q{Ruby client for Estonian Internet Foundation EPP service}
|
13
|
+
|
14
|
+
s.rubyforge_project = 'epp-eis'
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ['lib']
|
20
|
+
|
21
|
+
s.add_runtime_dependency 'nokogiri'
|
22
|
+
|
23
|
+
s.add_development_dependency 'rspec'
|
24
|
+
s.add_development_dependency 'guard'
|
25
|
+
end
|
@@ -0,0 +1,271 @@
|
|
1
|
+
module Epp
|
2
|
+
module Eis
|
3
|
+
|
4
|
+
XML_NS_CONTACT = 'http://www.nic.cz/xml/epp/contact-1.6'
|
5
|
+
|
6
|
+
XML_SCHEMALOC = 'http://www.nic.cz/xml/epp/contact-1.6 contact-1.6.xsd'
|
7
|
+
|
8
|
+
class ContactCheck
|
9
|
+
attr_accessor :name, :available, :reason
|
10
|
+
|
11
|
+
def initialize(name, available, reason)
|
12
|
+
@name = name
|
13
|
+
@available = available
|
14
|
+
@reason = reason
|
15
|
+
end
|
16
|
+
|
17
|
+
def available?
|
18
|
+
@available
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class ContactCheckResponse
|
23
|
+
|
24
|
+
def initialize(response)
|
25
|
+
@response = Nokogiri::XML(response)
|
26
|
+
end
|
27
|
+
|
28
|
+
def code
|
29
|
+
@response.css('epp response result').first['code'].to_i
|
30
|
+
end
|
31
|
+
|
32
|
+
def message
|
33
|
+
@response.css('epp response result msg').text
|
34
|
+
end
|
35
|
+
|
36
|
+
def items
|
37
|
+
@response.css('contact|chkData contact|cd', 'contact' => XML_NS_CONTACT).collect do |contact|
|
38
|
+
ContactCheck.new(
|
39
|
+
contact.css('contact|id', 'contact' => XML_NS_CONTACT).text,
|
40
|
+
contact.css('contact|id', 'contact' => XML_NS_CONTACT).first['avail'].to_i == 1,
|
41
|
+
contact.css('contact|reason', 'contact' => XML_NS_CONTACT).text
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class ContactCreateResponse
|
48
|
+
def initialize(response)
|
49
|
+
@response = Nokogiri::XML(response)
|
50
|
+
end
|
51
|
+
|
52
|
+
def code
|
53
|
+
@response.css('epp response result').first['code'].to_i
|
54
|
+
end
|
55
|
+
|
56
|
+
def message
|
57
|
+
@response.css('epp response result msg').text
|
58
|
+
end
|
59
|
+
|
60
|
+
def contact_id
|
61
|
+
@response.css('contact|creData contact|id', 'contact' => XML_NS_CONTACT).text
|
62
|
+
end
|
63
|
+
|
64
|
+
def contact_create_date
|
65
|
+
@response.css('contact|creData contact|crDate', 'contact' => XML_NS_CONTACT).text
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class ContactDeleteResponse
|
70
|
+
def initialize(response)
|
71
|
+
@response = Nokogiri::XML(response)
|
72
|
+
end
|
73
|
+
|
74
|
+
def code
|
75
|
+
@response.css('epp response result').first['code'].to_i
|
76
|
+
end
|
77
|
+
|
78
|
+
def message
|
79
|
+
@response.css('epp response result msg').text
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
class ContactInfoResponse
|
84
|
+
def initialize(response)
|
85
|
+
@response = Nokogiri::XML(response)
|
86
|
+
end
|
87
|
+
|
88
|
+
def code
|
89
|
+
@response.css('epp response result').first['code'].to_i
|
90
|
+
end
|
91
|
+
|
92
|
+
def message
|
93
|
+
@response.css('epp response result msg').text
|
94
|
+
end
|
95
|
+
|
96
|
+
def contact_id
|
97
|
+
@response.css('contact|infData contact|id', 'contact' => XML_NS_CONTACT).text
|
98
|
+
end
|
99
|
+
|
100
|
+
def contact_roid
|
101
|
+
@response.css('contact|infData contact|roid', 'contact' => XML_NS_CONTACT).text
|
102
|
+
end
|
103
|
+
|
104
|
+
def contact_status
|
105
|
+
@response.css('contact|infData contact|status', 'contact' => XML_NS_CONTACT).first['s']
|
106
|
+
end
|
107
|
+
|
108
|
+
def contact_name
|
109
|
+
@response.css('contact|infData contact|postalInfo contact|name', 'contact' => XML_NS_CONTACT).text
|
110
|
+
end
|
111
|
+
|
112
|
+
def contact_street
|
113
|
+
@response.css('contact|infData contact|addr contact|street', 'contact' => XML_NS_CONTACT).text
|
114
|
+
end
|
115
|
+
|
116
|
+
def contact_city
|
117
|
+
@response.css('contact|infData contact|addr contact|city', 'contact' => XML_NS_CONTACT).text
|
118
|
+
end
|
119
|
+
|
120
|
+
def contact_postal_code
|
121
|
+
@response.css('contact|infData contact|addr contact|pc', 'contact' => XML_NS_CONTACT).text
|
122
|
+
end
|
123
|
+
|
124
|
+
def contact_country_code
|
125
|
+
@response.css('contact|infData contact|addr contact|cc', 'contact' => XML_NS_CONTACT).text
|
126
|
+
end
|
127
|
+
|
128
|
+
def contact_email
|
129
|
+
@response.css('contact|infData contact|email', 'contact' => XML_NS_CONTACT).text
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
class ContactUpdateResponse
|
134
|
+
def initialize(response)
|
135
|
+
@response = Nokogiri::XML(response)
|
136
|
+
end
|
137
|
+
|
138
|
+
def code
|
139
|
+
@response.css('epp response result').first['code'].to_i
|
140
|
+
end
|
141
|
+
|
142
|
+
def message
|
143
|
+
@response.css('epp response result msg').text
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
module ContactCommands
|
148
|
+
|
149
|
+
# Check availability for a contact id. You may provide multiple contact id names.
|
150
|
+
def check_contact(*contacts)
|
151
|
+
builder = build_epp_request do |xml|
|
152
|
+
xml.command {
|
153
|
+
xml.check {
|
154
|
+
xml.check('xmlns:contact' => XML_NS_CONTACT, 'xsi:schemaLocation' => XML_SCHEMALOC) {
|
155
|
+
xml.parent.namespace = xml.parent.namespace_definitions.first
|
156
|
+
contacts.each { |contact| xml.id_ contact }
|
157
|
+
}
|
158
|
+
}
|
159
|
+
xml.clTRID UUIDTools::UUID.timestamp_create.to_s
|
160
|
+
}
|
161
|
+
end
|
162
|
+
|
163
|
+
ContactCheckResponse.new(send_request(builder.to_xml))
|
164
|
+
end
|
165
|
+
|
166
|
+
# Create a new contact object. The contact object will be available immediately.
|
167
|
+
def create_contact(contact, name, street, city, postal_code, country_code, voice, email, ident, ident_type)
|
168
|
+
builder = build_epp_request do |xml|
|
169
|
+
xml.command {
|
170
|
+
xml.create {
|
171
|
+
xml.create('xmlns:contact' => XML_NS_CONTACT, 'xsi:schemaLocation' => XML_SCHEMALOC) {
|
172
|
+
xml.parent.namespace = xml.parent.namespace_definitions.first
|
173
|
+
xml.id_ contact
|
174
|
+
xml.postalInfo {
|
175
|
+
xml.name name
|
176
|
+
xml.addr {
|
177
|
+
xml.street street
|
178
|
+
xml.city city
|
179
|
+
xml.pc postal_code
|
180
|
+
xml.cc country_code
|
181
|
+
}
|
182
|
+
}
|
183
|
+
xml.voice voice
|
184
|
+
xml.email email
|
185
|
+
xml.ident ident, 'type' => ident_type
|
186
|
+
}
|
187
|
+
}
|
188
|
+
xml.clTRID UUIDTools::UUID.timestamp_create.to_s
|
189
|
+
}
|
190
|
+
end
|
191
|
+
|
192
|
+
ContactCreateResponse.new(send_request(builder.to_xml))
|
193
|
+
end
|
194
|
+
|
195
|
+
#Delete contact handle. Contact object can not be deleted if it has relations to other objects like domains or
|
196
|
+
# nssets.
|
197
|
+
def delete_contact(contact)
|
198
|
+
builder = build_epp_request do |xml|
|
199
|
+
xml.command {
|
200
|
+
xml.delete {
|
201
|
+
xml.delete('xmlns:contact' => XML_NS_CONTACT, 'xsi:schemaLocation' => XML_SCHEMALOC) {
|
202
|
+
xml.parent.namespace = xml.parent.namespace_definitions.first
|
203
|
+
xml.id_ contact
|
204
|
+
}
|
205
|
+
}
|
206
|
+
xml.clTRID UUIDTools::UUID.timestamp_create.to_s
|
207
|
+
}
|
208
|
+
end
|
209
|
+
|
210
|
+
ContactDeleteResponse.new(send_request(builder.to_xml))
|
211
|
+
end
|
212
|
+
|
213
|
+
# Returns detailed information about a contact.
|
214
|
+
def info_contact(contact)
|
215
|
+
builder = build_epp_request do |xml|
|
216
|
+
xml.command {
|
217
|
+
xml.info {
|
218
|
+
xml.info('xmlns:contact' => XML_NS_CONTACT, 'xsi:schemaLocation' => XML_SCHEMALOC) {
|
219
|
+
xml.parent.namespace = xml.parent.namespace_definitions.first
|
220
|
+
xml.id_ contact
|
221
|
+
}
|
222
|
+
}
|
223
|
+
xml.clTRID UUIDTools::UUID.timestamp_create.to_s
|
224
|
+
}
|
225
|
+
end
|
226
|
+
|
227
|
+
ContactInfoResponse.new(send_request(builder.to_xml))
|
228
|
+
end
|
229
|
+
|
230
|
+
def list_contacts
|
231
|
+
list_command('listContacts')
|
232
|
+
end
|
233
|
+
|
234
|
+
# Update contact object. All domain and nsset objects will be updated as well.
|
235
|
+
def update_contact(contact, name, street, city, postal_code, country_code, voice, email, ident, ident_type, legal_document, legal_doc_type)
|
236
|
+
builder = build_epp_request do |xml|
|
237
|
+
xml.command {
|
238
|
+
xml.update {
|
239
|
+
xml.update('xmlns:contact' => XML_NS_CONTACT, 'xsi:schemaLocation' => XML_SCHEMALOC) {
|
240
|
+
xml.parent.namespace = xml.parent.namespace_definitions.first
|
241
|
+
xml.id_ contact
|
242
|
+
if [name, street, city, postal_code, country_code].any?{ |item| !item.nil? }
|
243
|
+
xml.postalInfo {
|
244
|
+
xml.name name if name
|
245
|
+
if [street, city, postal_code, country_code].any?{ |item| !item.nil? }
|
246
|
+
xml.addr {
|
247
|
+
xml.street street if street
|
248
|
+
xml.city city if city
|
249
|
+
xml.pc postal_code if postal_code
|
250
|
+
xml.cc country_code if country_code
|
251
|
+
}
|
252
|
+
end
|
253
|
+
}
|
254
|
+
end
|
255
|
+
xml.voice voice if voice
|
256
|
+
xml.email email if email
|
257
|
+
xml.ident ident, 'type' => ident_type
|
258
|
+
}
|
259
|
+
}
|
260
|
+
add_legal_document(xml, legal_document, legal_doc_type)
|
261
|
+
xml.clTRID UUIDTools::UUID.timestamp_create.to_s
|
262
|
+
}
|
263
|
+
end
|
264
|
+
|
265
|
+
ContactUpdateResponse.new(send_request(builder.to_xml))
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
Epp::Server.send(:include, Epp::Eis::ContactCommands)
|