Class: CZTop::ZAP::Request
- Inherits:
-
Object
- Object
- CZTop::ZAP::Request
- Defined in:
- lib/cztop/zap.rb
Overview
Represents a ZAP request.
Instance Attribute Summary collapse
- #address ⇒ String, #to_s
-
#credentials ⇒ Array<String, #to_s>
The credentials, 0 or more.
-
#domain ⇒ String, #to_s
The authentication domain.
-
#identity ⇒ String, #to_s
The connection identity.
-
#mechanism ⇒ String, #to_s
The security mechanism to be used.
- #request_id ⇒ String, #to_s
-
#version ⇒ String
ZAP version.
Class Method Summary collapse
-
.from_message(msg) ⇒ Request
Crafts a new Request from a message.
Instance Method Summary collapse
-
#initialize(domain, credentials = [], mechanism: Mechanisms::CURVE) ⇒ Request
constructor
Initializes a new ZAP request.
-
#to_msg ⇒ CZTop::Message
Creates a sendable message from this Request.
Constructor Details
#initialize(domain, credentials = [], mechanism: Mechanisms::CURVE) ⇒ Request
Initializes a new ZAP request. The security mechanism is set to CURVE (can be changed later).
91 92 93 94 95 96 |
# File 'lib/cztop/zap.rb', line 91 def initialize(domain, credentials = [], mechanism: Mechanisms::CURVE) @domain = domain @credentials = credentials @mechanism = mechanism @version = VERSION end |
Instance Attribute Details
#address ⇒ String, #to_s
76 77 78 |
# File 'lib/cztop/zap.rb', line 76 def address @address end |
#credentials ⇒ Array<String, #to_s>
Returns the credentials, 0 or more.
70 71 72 |
# File 'lib/cztop/zap.rb', line 70 def credentials @credentials end |
#domain ⇒ String, #to_s
Returns the authentication domain.
67 68 69 |
# File 'lib/cztop/zap.rb', line 67 def domain @domain end |
#identity ⇒ String, #to_s
Returns the connection identity.
79 80 81 |
# File 'lib/cztop/zap.rb', line 79 def identity @identity end |
#mechanism ⇒ String, #to_s
Returns the security mechanism to be used.
83 84 85 |
# File 'lib/cztop/zap.rb', line 83 def mechanism @mechanism end |
#request_id ⇒ String, #to_s
73 74 75 |
# File 'lib/cztop/zap.rb', line 73 def request_id @request_id end |
#version ⇒ String
Returns ZAP version.
64 65 66 |
# File 'lib/cztop/zap.rb', line 64 def version @version end |
Class Method Details
.from_message(msg) ⇒ Request
Crafts a new CZTop::ZAP::Request from a message.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cztop/zap.rb', line 43 def self.(msg) version, # The version frame, which SHALL contain the three octets "1.0". request_id, # The request id, which MAY contain an opaque binary blob. domain, # The domain, which SHALL contain a string. address, # The address, the origin network IP address. identity, # The identity, the connection Identity, if any. mechanism, # The mechanism, which SHALL contain a string. *credentials = # The credentials, which SHALL be zero or more opaque frames. msg.to_a raise VersionMismatch if version != VERSION new(domain, credentials, mechanism: mechanism).tap do |r| r.version = version r.request_id = request_id r.address = address r.identity = identity end end |
Instance Method Details
#to_msg ⇒ CZTop::Message
Creates a sendable message from this CZTop::ZAP::Request.
100 101 102 103 104 105 |
# File 'lib/cztop/zap.rb', line 100 def to_msg fields = [ @version, @request_id, @domain, @address, @identity, @mechanism, @credentials].flatten.map(&:to_s) CZTop::Message.new(fields) end |