class CZTop::ZAP::Request
Represents a ZAP
request.
Attributes
@return [String, to_s]
@return [Array<String, to_s>] the credentials, 0 or more
@return [String, to_s] the authentication domain
@return [String, to_s] the connection identity
@see Mechanisms
@return [String, to_s] the security mechanism to be used
@return [String, to_s]
@return [String] ZAP
version
Public Class Methods
Crafts a new {Request} from a message.
@param msg [CZTop::message] the message @return [Request] the request @raise [VersionMismatch] if the message contains an unsupported version
# File lib/cztop/zap.rb, line 43 def self.from_message(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
Initializes a new ZAP
request. The security mechanism is set to CURVE (can be changed later).
@param domain [String] the domain within to authenticate @param credentials [Array<String>] the credentials of the user,
depending on the security mechanism used
# File lib/cztop/zap.rb, line 91 def initialize(domain, credentials = [], mechanism: Mechanisms::CURVE) @domain = domain @credentials = credentials @mechanism = mechanism @version = VERSION end
Public Instance Methods
Creates a sendable message from this {Request}. @return [CZTop::Message} this request packed into a message
# 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