Class: Vines::Stream::Client::TLS

Inherits:
State
  • Object
show all
Defined in:
lib/vines/stream/client/tls.rb

Direct Known Subclasses

Server::TLS

Constant Summary collapse

NS =
NAMESPACES[:tls]
PROCEED =
%Q{<proceed xmlns="#{NS}"/>}.freeze
FAILURE =
%Q{<failure xmlns="#{NS}"/>}.freeze
STARTTLS =
'starttls'.freeze

Constants inherited from State

State::BODY, State::STREAM

Instance Attribute Summary

Attributes inherited from State

#stream

Instance Method Summary collapse

Methods inherited from State

#==, #eql?, #hash

Methods included from Log

#log

Constructor Details

#initialize(stream, success = AuthRestart) ⇒ TLS

Returns a new instance of TLS.



12
13
14
# File 'lib/vines/stream/client/tls.rb', line 12

def initialize(stream, success=AuthRestart)
  super
end

Instance Method Details

#node(node) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/vines/stream/client/tls.rb', line 16

def node(node)
  raise StreamErrors::NotAuthorized unless starttls?(node)
  if stream.encrypt?
    stream.write(PROCEED)
    stream.encrypt
    stream.reset
    advance
  else
    stream.write(FAILURE)
    stream.write('</stream:stream>')
    stream.close_connection_after_writing
  end
end