Class: Hexspace::SaslTransport
- Inherits:
-
Thrift::FramedTransport
- Object
- Thrift::FramedTransport
- Hexspace::SaslTransport
- Defined in:
- lib/hexspace/sasl_transport.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(transport, **options) ⇒ SaslTransport
constructor
A new instance of SaslTransport.
- #open ⇒ Object
- #write_sasl(status, body) ⇒ Object
Constructor Details
#initialize(transport, **options) ⇒ SaslTransport
Returns a new instance of SaslTransport.
5 6 7 8 |
# File 'lib/hexspace/sasl_transport.rb', line 5 def initialize(transport, **) super(transport) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/hexspace/sasl_transport.rb', line 3 def @options end |
Instance Method Details
#open ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/hexspace/sasl_transport.rb', line 10 def open super step = [[:authzid], [:username], [:password]].map(&:to_s).join("\x00".b) write_sasl("\x01", "PLAIN") write_sasl("\x02", step) resp = @transport.read(5) case resp[0] when "\x03" len = resp[1..-1].unpack1("N") raise Error, @transport.read(len) when "\x05" # success else raise Error, "Unknown response: #{resp.inspect}" end end |
#write_sasl(status, body) ⇒ Object
30 31 32 33 |
# File 'lib/hexspace/sasl_transport.rb', line 30 def write_sasl(status, body) @transport.write("#{status}#{[body.bytesize].pack("N")}#{body}") @transport.flush end |