epp_client 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -1,4 +1,2 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in epp_client.gemspec
1
+ source :rubygems
4
2
  gemspec
data/README.markdown ADDED
@@ -0,0 +1,57 @@
1
+ # EPP Client
2
+
3
+ Está é uma biblioteca que permite acessar serviços que implementam o protocolo [EPP](http://tools.ietf.org/html/rfc4930)
4
+
5
+ ## Como usar
6
+
7
+ Adicione a biblioteca ao arquivo Gemfile:
8
+
9
+ ```ruby
10
+ gem 'epp_client'
11
+ ```
12
+
13
+ E crie o arquivo de configuração em `config/epp_client.yml`:
14
+
15
+ ```yaml
16
+ registrobr:
17
+ certificates_path: config/registrobr
18
+ templates_path: config/registrobr/templates
19
+ certificates:
20
+ cert: client.pem
21
+ key: key.pem
22
+ ca_file: root.pem
23
+ templates:
24
+ login: login.xml.erb
25
+ logout: logout.xml.erb
26
+ domain_check: domain_check.xml.erb
27
+ ```
28
+
29
+ Você precisa disponibilizar os certificados e templates do registrar conforme configuração acima na sua aplicação.
30
+
31
+ O [EPP Server](https://github.com/matheustardivo/epp_server) é um exemplo de aplicação utilizando o [Sinatra](http://www.sinatrarb.com) para fazer consultas de domínio no [Registro.br](http://registro.br).
32
+
33
+ ## Autor
34
+ Matheus Tardivo (<http://matheustardivo.com>)
35
+
36
+ ## Licença:
37
+
38
+ (The MIT License)
39
+
40
+ Permission is hereby granted, free of charge, to any person obtaining
41
+ a copy of this software and associated documentation files (the
42
+ 'Software'), to deal in the Software without restriction, including
43
+ without limitation the rights to use, copy, modify, merge, publish,
44
+ distribute, sublicense, and/or sell copies of the Software, and to
45
+ permit persons to whom the Software is furnished to do so, subject to
46
+ the following conditions:
47
+
48
+ The above copyright notice and this permission notice shall be
49
+ included in all copies or substantial portions of the Software.
50
+
51
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
52
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
53
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
54
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
55
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
56
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
57
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,11 @@
1
+ registrobr:
2
+ certificates_path: config/registrobr
3
+ templates_path: config/registrobr/templates
4
+ certificates:
5
+ cert: client.pem
6
+ key: key.pem
7
+ ca_file: root.pem
8
+ templates:
9
+ login: login.xml.erb
10
+ logout: logout.xml.erb
11
+ domain_check: domain_check.xml.erb
File without changes
File without changes
File without changes
File without changes
data/lib/epp_client.rb CHANGED
@@ -3,4 +3,5 @@ require 'openssl'
3
3
  require 'uuid'
4
4
  require 'erb'
5
5
 
6
+ require 'epp_client/base'
6
7
  require 'epp_client/registrobr'
@@ -0,0 +1,31 @@
1
+ require 'yaml'
2
+
3
+ module EppClient
4
+ extend self
5
+
6
+ @@config = nil
7
+
8
+ def config_file
9
+ "config/epp_client.yml"
10
+ end
11
+
12
+ def config?
13
+ File.exist?(config_file)
14
+ end
15
+
16
+ def config
17
+ raise MissingConfigurationError, "file not found on #{config_file.inspect}" unless config?
18
+ @@config ||= YAML.load(File.open(config_file))
19
+ end
20
+
21
+ def template(registrar, symbol)
22
+ "#{config[registrar.to_s]['templates_path']}/#{config[registrar.to_s]['templates'][symbol.to_s]}"
23
+ end
24
+
25
+ def certificate(registrar, symbol)
26
+ "#{config[registrar.to_s]['certificates_path']}/#{config[registrar.to_s]['certificates'][symbol.to_s]}"
27
+ end
28
+
29
+ class MissingEnvironmentError < StandardError; end
30
+ class MissingConfigurationError < StandardError; end
31
+ end
@@ -1,16 +1 @@
1
1
  require 'epp_client/registrobr/client'
2
-
3
- TEMPLATES_FOLDER = 'files/registrobr/templates/'
4
- CERTIFICATES_FOLDER = 'files/registrobr/'
5
-
6
- TEMPLATES = {
7
- :login => "#{TEMPLATES_FOLDER}login.xml.erb",
8
- :logout => "#{TEMPLATES_FOLDER}logout.xml.erb",
9
- :domain_check => "#{TEMPLATES_FOLDER}domain_check.xml.erb"
10
- }
11
-
12
- CERTIFICATES = {
13
- :cert => "#{CERTIFICATES_FOLDER}client.pem",
14
- :key => "#{CERTIFICATES_FOLDER}key.pem",
15
- :ca_file => "#{CERTIFICATES_FOLDER}root.pem"
16
- }
@@ -24,9 +24,9 @@ module EppClient
24
24
  private
25
25
  def connect
26
26
  ssl_context = OpenSSL::SSL::SSLContext.new(:TLSv1)
27
- ssl_context.cert = OpenSSL::X509::Certificate.new(File.open(CERTIFICATES[:cert]))
28
- ssl_context.key = OpenSSL::PKey::RSA.new(File.open(CERTIFICATES[:key]))
29
- ssl_context.ca_file = CERTIFICATES[:ca_file]
27
+ ssl_context.cert = OpenSSL::X509::Certificate.new(File.open(EppClient.certificate(:registrobr, :cert)))
28
+ ssl_context.key = OpenSSL::PKey::RSA.new(File.open(EppClient.certificate(:registrobr, :key)))
29
+ ssl_context.ca_file = EppClient.certificate(:registrobr, :ca_file)
30
30
  ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
31
31
 
32
32
  @ssl_socket = OpenSSL::SSL::SSLSocket.new(TCPSocket.new(@host, @port), ssl_context)
@@ -56,9 +56,10 @@ module EppClient
56
56
  end
57
57
 
58
58
  def send_request(xml)
59
- raise TemplateNotFoundError unless TEMPLATES[xml]
59
+ template_file = EppClient.template(:registrobr, xml)
60
+ raise TemplateNotFoundError unless template_file
60
61
 
61
- actual_template = ERB.new File.open(TEMPLATES[xml]).readlines.join
62
+ actual_template = ERB.new File.open(template_file).readlines.join
62
63
  @uuid = generate_uuid
63
64
 
64
65
  send_frame(actual_template.result(binding))
@@ -1,3 +1,3 @@
1
1
  module EppClient
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epp_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70138644799620 !ruby/object:Gem::Requirement
16
+ requirement: &70250511546080 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.9'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70138644799620
24
+ version_requirements: *70250511546080
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70138644797420 !ruby/object:Gem::Requirement
27
+ requirement: &70250511545160 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.7'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70138644797420
35
+ version_requirements: *70250511545160
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: pry
38
- requirement: &70138644796000 !ruby/object:Gem::Requirement
38
+ requirement: &70250511544360 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0.9'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70138644796000
46
+ version_requirements: *70250511544360
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: awesome_print
49
- requirement: &70138644794700 !ruby/object:Gem::Requirement
49
+ requirement: &70250511543320 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '1.0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70138644794700
57
+ version_requirements: *70250511543320
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: uuid
60
- requirement: &70138644793220 !ruby/object:Gem::Requirement
60
+ requirement: &70250511542820 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '2.3'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70138644793220
68
+ version_requirements: *70250511542820
69
69
  description: Library to access EPP services
70
70
  email:
71
71
  - matheustardivo@gmail.com
@@ -76,16 +76,19 @@ files:
76
76
  - .gitignore
77
77
  - Gemfile
78
78
  - Gemfile.lock
79
+ - README.markdown
79
80
  - Rakefile
81
+ - config/epp_client.yml
82
+ - config/registrobr/client.pem
83
+ - config/registrobr/key.pem
84
+ - config/registrobr/root.pem
85
+ - config/registrobr/server.pem
86
+ - config/registrobr/templates/domain_check.xml.erb
87
+ - config/registrobr/templates/login.xml.erb
88
+ - config/registrobr/templates/logout.xml.erb
80
89
  - epp_client.gemspec
81
- - files/registrobr/client.pem
82
- - files/registrobr/key.pem
83
- - files/registrobr/root.pem
84
- - files/registrobr/server.pem
85
- - files/registrobr/templates/domain_check.xml.erb
86
- - files/registrobr/templates/login.xml.erb
87
- - files/registrobr/templates/logout.xml.erb
88
90
  - lib/epp_client.rb
91
+ - lib/epp_client/base.rb
89
92
  - lib/epp_client/registrobr.rb
90
93
  - lib/epp_client/registrobr/client.rb
91
94
  - lib/epp_client/version.rb