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).
100 101 102 103 104 105 |
# File 'lib/cztop/zap.rb', line 100 def initialize(domain, credentials = [], mechanism: Mechanisms::CURVE) @domain = domain @credentials = credentials @mechanism = mechanism @version = VERSION end |
Instance Attribute Details
#address ⇒ String, #to_s
85 86 87 |
# File 'lib/cztop/zap.rb', line 85 def address @address end |
#credentials ⇒ Array<String, #to_s>
Returns the credentials, 0 or more.
79 80 81 |
# File 'lib/cztop/zap.rb', line 79 def credentials @credentials end |
#domain ⇒ String, #to_s
Returns the authentication domain.
76 77 78 |
# File 'lib/cztop/zap.rb', line 76 def domain @domain end |
#identity ⇒ String, #to_s
Returns the connection identity.
88 89 90 |
# File 'lib/cztop/zap.rb', line 88 def identity @identity end |
#mechanism ⇒ String, #to_s
Returns the security mechanism to be used.
92 93 94 |
# File 'lib/cztop/zap.rb', line 92 def mechanism @mechanism end |
#request_id ⇒ String, #to_s
82 83 84 |
# File 'lib/cztop/zap.rb', line 82 def request_id @request_id end |
#version ⇒ String
Returns ZAP version.
73 74 75 |
# File 'lib/cztop/zap.rb', line 73 def version @version end |
Class Method Details
.from_message(msg) ⇒ Request
Crafts a new CZTop::ZAP::Request from a message.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/cztop/zap.rb', line 52 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.
110 111 112 113 114 115 |
# File 'lib/cztop/zap.rb', line 110 def to_msg fields = [@version, @request_id, @domain, @address, @identity, @mechanism, @credentials].flatten.map(&:to_s) CZTop::Message.new(fields) end |