ultraspeed-epp 1.0.2 → 1.0.3

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.
Files changed (4) hide show
  1. data/README.rdoc +18 -34
  2. data/lib/epp/server.rb +28 -11
  3. data/lib/epp.rb +4 -2
  4. metadata +22 -3
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = EPP Version 1.0.1
1
+ = EPP (by {Ultraspeed}[http://ultraspeed.co.uk])
2
2
 
3
3
  The EPP gem provides basic functionality for connecting and making requests on EPP (Extensible Provisioning Protocol) servers. Currently, major providers Centralnic and Nominet have been tested.
4
4
 
@@ -24,48 +24,32 @@ Once you do that, you can install the gem by typing <tt>sudo rake gems:install</
24
24
 
25
25
  == Example Usage
26
26
 
27
- First, you must initialize an Epp::Server object to use. This requires the server address and port:
27
+ First, you must initialize an Epp::Server object to use. This requires the EPP server address, tag/username and password:
28
28
 
29
29
  server = Epp::Server.new(
30
30
  :server => "testbed-epp.nominet.org.uk",
31
- :port => 700
31
+ :tag => "TESTING",
32
+ :password => "testing"
32
33
  )
33
34
 
34
35
  If no port is specified, it will be assumed that you will be using port 700.
35
36
 
36
- You would then make an XML request to the server. You can build this however you'd like. For simplicity purposes, here is a string <tt><login></tt> request:
37
-
38
- xml = %{
39
- <?xml version="1.0" encoding="UTF-8"?>
40
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
41
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
42
- xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
43
- <command>
44
- <login>
45
- <clID>EXAMPLE-TAG</clID>
46
- <pw>foo-123</pw>
47
- <options>
48
- <version>1.0</version>
49
- <lang>en</lang>
50
- </options>
51
- <svcs>
52
- <objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>
53
- <objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>
54
- <objURI>urn:ietf:params:xml:ns:host-1.0</objURI>
55
- </svcs>
56
- </login>
57
- <clTRID>ABC-12345</clTRID>
58
- </command>
59
- </epp>
60
- }
61
-
62
- response = server.request(xml)
63
-
64
- The EPP server would then return the XML response as a string, and set it equal to <tt>response</tt> for your usage.
37
+ You would then make an XML request to the server.
38
+
39
+ xml = "<?xml ... </epp>"
40
+ response = server.request(xml)
41
+
42
+ You can build this however you'd like. The process is as follows:
43
+
44
+ * Connect to EPP server, get the <greeting> frame
45
+ * Send a standard <login> request
46
+ * Send your request
47
+ * Send a standard <logout> request
48
+ * Disconnect the socket from the server
65
49
 
66
- You can close the connection to the server completely by using the following:
50
+ The EPP server would then return the XML response as a string. In this example, the response XML would be set equal to <tt>response</tt> for your usage.
67
51
 
68
- server.close_connection
52
+ Once the request is complete, it will automatically close the connection. For simplicity purposes, this plug-in will *not* use a persistent connection to the EPP server.
69
53
 
70
54
  == Bugs/Issues
71
55
 
data/lib/epp/server.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  module Epp #:nodoc:
2
2
  class Server
3
- include REXML
4
3
  include RequiresParameters
5
4
 
6
5
  attr_accessor :tag, :password, :server, :port, :clTRID
@@ -43,7 +42,7 @@ module Epp #:nodoc:
43
42
  return @response
44
43
  end
45
44
 
46
- private
45
+ # private
47
46
 
48
47
  # Wrapper which sends an XML frame to the server, and receives
49
48
  # the response frame in return.
@@ -53,8 +52,8 @@ module Epp #:nodoc:
53
52
  end
54
53
 
55
54
  def login
56
- xml = Document.new
57
- xml << XMLDecl.new("1.0", "UTF-8", "no")
55
+ xml = REXML::Document.new
56
+ xml << REXML::XMLDecl.new("1.0", "UTF-8", "no")
58
57
 
59
58
  xml.add_element("epp", {
60
59
  "xmlns" => "urn:ietf:params:xml:ns:epp-1.0",
@@ -79,12 +78,22 @@ module Epp #:nodoc:
79
78
 
80
79
  command.add_element("clTRID").text = @clTRID
81
80
 
82
- send_request(xml.to_s)
81
+ # Receive the login response
82
+ response = Hpricot.XML(send_request(xml.to_s))
83
+
84
+ result_message = (response/"epp"/"response"/"result"/"msg").text.strip
85
+ result_code = (response/"epp"/"response"/"result").attr("code").to_i
86
+
87
+ if result_code == 1000
88
+ return true
89
+ else
90
+ raise EppErrorResponse.new(:code => result_code, :message => result_message)
91
+ end
83
92
  end
84
93
 
85
94
  def logout
86
- xml = Document.new
87
- xml << XMLDecl.new("1.0", "UTF-8", "no")
95
+ xml = REXML::Document.new
96
+ xml << REXML::XMLDecl.new("1.0", "UTF-8", "no")
88
97
 
89
98
  xml.add_element('epp', {
90
99
  'xmlns' => "urn:ietf:params:xml:ns:epp-1.0",
@@ -95,7 +104,17 @@ module Epp #:nodoc:
95
104
  command = xml.root.add_element("command")
96
105
  login = command.add_element("logout")
97
106
 
98
- send_request(xml.to_s)
107
+ # Receive the logout response
108
+ response = Hpricot.XML(send_request(xml.to_s))
109
+
110
+ result_message = (response/"epp"/"response"/"result"/"msg").text.strip
111
+ result_code = (response/"epp"/"response"/"result").attr("code").to_i
112
+
113
+ if result_code == 1500
114
+ return true
115
+ else
116
+ raise EppErrorResponse.new(:code => result_code, :message => result_message)
117
+ end
99
118
  end
100
119
 
101
120
  # Establishes the connection to the server. If the connection is
@@ -157,9 +176,7 @@ module Epp #:nodoc:
157
176
  # Send an XML frame to the server. Should return the total byte
158
177
  # size of the frame sent to the server. If the socket returns EOF,
159
178
  # the connection has closed and a SocketError is raised.
160
- def send_frame(xml)
161
- raise SocketError.new("Connection closed by remote server") if @socket.eof?
162
-
179
+ def send_frame(xml)
163
180
  @socket.write([xml.size + 4].pack("N") + xml)
164
181
  end
165
182
  end
data/lib/epp.rb CHANGED
@@ -7,9 +7,11 @@ require 'socket'
7
7
  require 'activesupport'
8
8
  require 'require_parameters'
9
9
  require 'rexml/document'
10
+ require 'hpricot'
10
11
 
11
- require 'epp/server.rb'
12
+ require 'epp/server'
13
+ require 'epp/exceptions'
12
14
 
13
15
  module Epp #:nodoc:
14
- VERSION = '1.0.2'
16
+ VERSION = '1.0.3'
15
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ultraspeed-epp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Delsman
@@ -11,8 +11,27 @@ cert_chain: []
11
11
 
12
12
  date: 2009-06-04 00:00:00 -07:00
13
13
  default_executable:
14
- dependencies: []
15
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activesupport
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.3.2
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: hpricot
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.8.1
34
+ version:
16
35
  description: Basic functionality for connecting and making requests on EPP (Extensible Provisioning Protocol) servers.
17
36
  email: jdelsman@ultraspeed.com
18
37
  executables: []