epp-client-secdns 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog ADDED
@@ -0,0 +1,5 @@
1
+ 2010-05-14 mat
2
+ * first release
3
+
4
+ 2010-05-04 mat
5
+ * Initial commit
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in epp-client.gemspec
4
+ Dir['*.gemspec'].each do |i|
5
+ gemspec :name => i.sub(/\.gemspec$/, '')
6
+ end
data/MIT-LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2010 Mathieu Arnold, Absolight
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/README ADDED
@@ -0,0 +1,5 @@
1
+ An extensible EPP client library
2
+
3
+ When possible, the objects that are received via EPP are translated to their
4
+ equivalent in ruby, that is, dates in Date object, timestamps in DateTime
5
+ objects.
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env rake
2
+ require 'rake'
3
+ require 'rdoc/task'
4
+ require 'rubygems/package_task'
5
+ require "bundler/gem_helper"
6
+
7
+ MY_GEMS = Dir['*.gemspec'].map {|g| g.sub(/.*-(.*)\.gemspec/, '\1')}
8
+
9
+ MY_GEMS.each do |g|
10
+ namespace g do
11
+ Bundler::GemHelper.new(Dir.pwd, "epp-client-#{g}").install
12
+ end
13
+ end
14
+
15
+ namespace :all do
16
+ task :build => MY_GEMS.map { |f| "#{f}:build" }
17
+ task :install => MY_GEMS.map { |f| "#{f}:install" }
18
+ task :release => MY_GEMS.map { |f| "#{f}:release" }
19
+ end
20
+
21
+ task :build => 'all:build'
22
+ task :install => 'all:install'
23
+ task :release => 'all:release'
24
+
25
+ desc "Generate documentation for the Rails framework"
26
+ Rake::RDocTask.new do |rdoc|
27
+ rdoc.rdoc_dir = 'doc/rdoc'
28
+ rdoc.title = "Documentation"
29
+
30
+ rdoc.options << '--line-numbers' << '--inline-source'
31
+ rdoc.options << '--charset' << 'utf-8'
32
+
33
+ rdoc.rdoc_files.include('README')
34
+ rdoc.rdoc_files.include('ChangeLog')
35
+ rdoc.rdoc_files.include('lib/**/*.rb')
36
+ end
37
+
@@ -0,0 +1,37 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/epp-client/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'epp-client-secdns'
6
+ gem.version = EPPClient::VERSION
7
+ gem.date = '2010-05-14'
8
+ gem.authors = ['Mathieu Arnold']
9
+ gem.email = ['m@absolight.fr']
10
+ gem.description = 'SecDNS EPP client library.'
11
+ gem.summary = 'SecDNS EPP client library'
12
+ gem.homepage = "https://github.com/Absolight/epp-client"
13
+
14
+ gem.required_ruby_version = '>= 1.8.7'
15
+ gem.required_rubygems_version = ">= 1.3.6"
16
+
17
+ gem.files = [
18
+ 'ChangeLog',
19
+ 'Gemfile',
20
+ 'MIT-LICENSE',
21
+ 'README',
22
+ 'Rakefile',
23
+ 'epp-client-secdns.gemspec',
24
+ 'lib/epp-client/secdns.rb',
25
+ 'vendor/ietf/rfc4310.txt',
26
+ 'vendor/ietf/rfc5910.txt',
27
+ 'vendor/ietf/secDNS-1.0.xsd',
28
+ 'vendor/ietf/secDNS-1.1.xsd',
29
+ ]
30
+
31
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
32
+ gem.require_paths = ['lib']
33
+
34
+ gem.add_development_dependency "bundler", ">= 1.0.0"
35
+ gem.add_dependency('nokogiri', '~> 1.4')
36
+ gem.add_dependency('builder', '>= 2.1.2')
37
+ end
@@ -0,0 +1,243 @@
1
+ module EPPClient
2
+ module SecDNS
3
+ SCHEMAS_SECDNS = %w[
4
+ secDNS-1.1
5
+ ]
6
+
7
+ EPPClient::SCHEMAS_URL.merge!(SCHEMAS_SECDNS.inject({}) do |a,s|
8
+ a[s.sub(/-1\.1$/, '')] = "urn:ietf:params:xml:ns:#{s}" if s =~ /-1\.1$/
9
+ a[s] = "urn:ietf:params:xml:ns:#{s}"
10
+ a
11
+ end)
12
+
13
+ def initialize(args)
14
+ super
15
+ @extensions << EPPClient::SCHEMAS_URL['secDNS-1.1']
16
+ end
17
+
18
+ # Extends the base domain info so that the specific secDNS elements
19
+ # can be added.
20
+ #
21
+ # either:
22
+ # [<tt>:keyData</tt>]
23
+ # containing an array of keyData objects with the following fields :
24
+ # [<tt>:flags</tt>]
25
+ # The flags field value as described in {section 2.1.1 of RFC
26
+ # 4034}[http://tools.ietf.org/html/rfc4034#section-2.1.1].
27
+ # [<tt>:protocol</tt>]
28
+ # The protocol field value as described in {section 2.1.2 of RFC
29
+ # 4034}[http://tools.ietf.org/html/rfc4034#section-2.1.2].
30
+ # [<tt>:alg</tt>]
31
+ # The algorithm number field value as described in {section 2.1.3 of RFC
32
+ # 4034}[http://tools.ietf.org/html/rfc4034#section-2.1.3].
33
+ # [<tt>:pubKey</tt>]
34
+ # The encoded public key field value as described in {Section 2.1.4 of
35
+ # RFC 4034}[http://tools.ietf.org/html/rfc4034#section-2.1.4].
36
+ # [<tt>:dsData</tt>]
37
+ # containing an array of dsData objects with the following fields :
38
+ # [<tt>:keyTag</tt>]
39
+ # The key tag value as described in {Section 5.1.1 of RFC
40
+ # 4034}[http://tools.ietf.org/html/rfc4034#section-5.1.1].
41
+ # [<tt>:alg</tt>]
42
+ # The algorithm value as described in {Section 5.1.2 of RFC
43
+ # 4034}[http://tools.ietf.org/html/rfc4034#section-5.1.2].
44
+ # [<tt>:digestType</tt>]
45
+ # The digest type value as described in {Section 5.1.3 of RFC
46
+ # 4034}[http://tools.ietf.org/html/rfc4034#section-5.1.3].
47
+ # [<tt>:digest</tt>]
48
+ # The digest value as described in {Section 5.1.1 of RFC
49
+ # 4034}[http://tools.ietf.org/html/rfc4034#section-5.1.1].
50
+ # [<tt>:keyData</tt>]
51
+ # An optional element that describes the key data used as input in the DS
52
+ # hash calculation for use in server validation. The <tt>:keyData</tt>
53
+ # element contains the child elements defined above.
54
+ #
55
+ # Optionnaly :
56
+ # [<tt>:maxSigLife</tt>]
57
+ # An element that indicates a child's preference for the number of seconds
58
+ # after signature generation when the parent's signature on the DS
59
+ # information provided by the child will expire.
60
+ def domain_info(domain)
61
+ super # placeholder so that I can add some doc
62
+ end
63
+
64
+ def domain_info_process(xml) #:nodoc:
65
+ ret = super
66
+ ret_secdns = {}
67
+ if (maxSigLife = xml.xpath('epp:extension/secDNS:infData/secDNS:maxSigLife', EPPClient::SCHEMAS_URL)).size > 0
68
+ ret_secdns[:maxSigLife] = maxSigLife.text
69
+ end
70
+ ret_secdns[:dsData] = xml.xpath('epp:extension/secDNS:infData/secDNS:dsData', EPPClient::SCHEMAS_URL).map do |s|
71
+ parse_ds_data(s)
72
+ end
73
+ ret_secdns[:keyData] = xml.xpath('epp:extension/secDNS:infData/secDNS:keyData', EPPClient::SCHEMAS_URL).map do |s|
74
+ parse_key_data(s)
75
+ end
76
+
77
+ ret[:secDNS] = ret_secdns unless ret_secdns.values.reject {|v| v.nil?}.size == 0
78
+ ret
79
+ end
80
+
81
+ # Extends the base domain create so that the specific secDNS create
82
+ # informations can be sent, the additionnal informations are :
83
+ #
84
+ # either:
85
+ # [<tt>:keyData</tt>]
86
+ # containing an array of keyData objects as described in the domain_info function.
87
+ # [<tt>:dsData</tt>]
88
+ # containing an array of dsData objects as described in the domain_info function.
89
+ #
90
+ # Optionnaly :
91
+ # [<tt>:maxSigLife</tt>]
92
+ # as described in the domain_info function.
93
+ def domain_create(domain)
94
+ super # placeholder so that I can add some doc
95
+ end
96
+
97
+ def domain_create_xml(domain) #:nodoc:
98
+ ret = super
99
+
100
+ if domain.key?(:maxSigLife) || domain.key?(:dsData) || domain.key?(:keyData)
101
+ ext = extension do |xml|
102
+ xml.create( :xmlns => EPPClient::SCHEMAS_URL['secDNS']) do
103
+ if domain.key?(:maxSigLife)
104
+ xml.maxSigLife(domain[:maxSigLife])
105
+ end
106
+ if domain.key?(:dsData)
107
+ domain[:dsData].each do |ds|
108
+ make_ds_data(xml, ds)
109
+ end
110
+ elsif domain.key?(:keyData)
111
+ domain[:keyData].each do |key|
112
+ make_key_data(xml, key)
113
+ end
114
+ end
115
+ end
116
+ end
117
+ return insert_extension(ret, ext)
118
+ else
119
+ return ret
120
+ end
121
+ end
122
+
123
+ # Extends the base domain update so that secDNS informations can be sent, the
124
+ # additionnal informations are contained in an <tt>:secDNS</tt> object :
125
+ #
126
+ # [:rem]
127
+ # To remove keys or ds from the delegation, with possible attributes one of :
128
+ #
129
+ # [<tt>:all</tt>]
130
+ # used to remove all DS and key data with a value of boolean true. A
131
+ # value of boolean false will do nothing. Removing all DS information
132
+ # can remove the ability of the parent to secure the delegation to the
133
+ # child zone.
134
+ # [<tt>:dsData</tt>]
135
+ # an array of dsData elements described in the domain_info function.
136
+ # [<tt>:keyData</tt>]
137
+ # an array of keyData elements as described in the domain_info function.
138
+ #
139
+ # [:add]
140
+ # To add keys or DS from the delegation, with possible attributes one of :
141
+ #
142
+ # [<tt>:dsData</tt>]
143
+ # an array of dsData elements described in the domain_info function.
144
+ # [<tt>:keyData</tt>]
145
+ # an array of keyData elements as described in the domain_info function.
146
+ # [:chg]
147
+ # contains security information to be changed, one of :
148
+ #
149
+ # [:maxSigLife]
150
+ # optional, as described in the domain_info function.
151
+ def domain_update(args)
152
+ super # placeholder so that I can add some doc
153
+ end
154
+
155
+ def domain_update_xml(domain)
156
+ ret = super
157
+
158
+ if domain.key?(:secDNS)
159
+ sd = domain[:secDNS]
160
+ ext = extension do |xml|
161
+ xml.update(sd[:urgent] == true ? {:urgent => true}: {}, {:xmlns => EPPClient::SCHEMAS_URL['secDNS']}) do
162
+ if sd.key?(:rem)
163
+ xml.rem do
164
+ if sd[:rem].key?(:all) && sd[:rem][:all] == true
165
+ xml.all true
166
+ elsif sd[:rem].key?(:dsData)
167
+ sd[:rem][:dsData].each do |ds|
168
+ make_ds_data(xml, ds)
169
+ end
170
+ elsif sd[:rem].key?(:keyData)
171
+ sd[:rem][:keyData].each do |key|
172
+ make_key_data(xml, key)
173
+ end
174
+ end
175
+ end
176
+ end
177
+ if sd.key?(:add)
178
+ xml.add do
179
+ if sd[:add].key?(:dsData)
180
+ sd[:add][:dsData].each do |ds|
181
+ make_ds_data(xml, ds)
182
+ end
183
+ elsif sd[:add].key?(:keyData)
184
+ sd[:add][:keyData].each do |key|
185
+ make_key_data(xml, key)
186
+ end
187
+ end
188
+ end
189
+ end
190
+ if sd.key?(:chg) && sd[:chg].key?(:maxSigLife)
191
+ xml.chg do
192
+ xml.maxSigLife sd[:chg][:maxSigLife]
193
+ end
194
+ end
195
+ end
196
+ end
197
+ return insert_extension(ret, ext)
198
+ else
199
+ return ret
200
+ end
201
+ end
202
+
203
+ private
204
+ def make_key_data(xml, key)
205
+ xml.keyData do
206
+ xml.flags key[:flags]
207
+ xml.protocol key[:protocol]
208
+ xml.alg key[:alg]
209
+ xml.pubKey key[:pubKey]
210
+ end
211
+ end
212
+ def make_ds_data(xml, ds)
213
+ xml.dsData do
214
+ xml.keyTag ds[:keyTag]
215
+ xml.alg ds[:alg]
216
+ xml.digestType ds[:digestType]
217
+ xml.digest ds[:digest]
218
+ make_key_data(xml, ds[:keyData]) if ds.key?(:keyData)
219
+ end
220
+ end
221
+ def parse_key_data(xml)
222
+ {
223
+ :flags => xml.xpath("secDNS:flags", EPPClient::SCHEMAS_URL).text.to_i,
224
+ :protocol => xml.xpath("secDNS:protocol", EPPClient::SCHEMAS_URL).text.to_i,
225
+ :alg => xml.xpath("secDNS:alg", EPPClient::SCHEMAS_URL).text.to_i,
226
+ :pubKey => xml.xpath("secDNS:pubKey", EPPClient::SCHEMAS_URL).text,
227
+ }
228
+ end
229
+ def parse_ds_data(xml)
230
+ ret = {
231
+ :keyTag => xml.xpath("secDNS:keyTag", EPPClient::SCHEMAS_URL).text.to_i,
232
+ :alg => xml.xpath("secDNS:alg", EPPClient::SCHEMAS_URL).text.to_i,
233
+ :digestType => xml.xpath("secDNS:digestType", EPPClient::SCHEMAS_URL).text.to_i,
234
+ :digest => xml.xpath("secDNS:digest", EPPClient::SCHEMAS_URL).text
235
+ }
236
+ if (keyData = xml.xpath('secDNS:keyData', EPPClient::SCHEMAS_URL)).size > 0
237
+ ret[:keyData] = parse_key_data(keyData)
238
+ end
239
+ ret
240
+ end
241
+
242
+ end
243
+ end