Class: Vines::Stream::Client::Auth
- Inherits:
-
State
- Object
- State
- Vines::Stream::Client::Auth
show all
- Defined in:
- lib/vines/stream/client/auth.rb
Constant Summary
collapse
- NS =
NAMESPACES[:sasl]
- MECHANISM =
'mechanism'.freeze
- AUTH =
'auth'.freeze
- PLAIN =
'PLAIN'.freeze
- EXTERNAL =
'EXTERNAL'.freeze
- SUCCESS =
%Q{<success xmlns="#{NS}"/>}.freeze
- MAX_AUTH_ATTEMPTS =
3
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 = BindRestart) ⇒ Auth
15
16
17
18
19
|
# File 'lib/vines/stream/client/auth.rb', line 15
def initialize(stream, success=BindRestart)
super
@attempts = 0
@sasl = SASL.new(stream)
end
|
Instance Method Details
#node(node) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/vines/stream/client/auth.rb', line 21
def node(node)
raise StreamErrors::NotAuthorized unless auth?(node)
if node.text.empty?
send_auth_fail(SaslErrors::MalformedRequest.new)
elsif stream.authentication_mechanisms.include?(node[MECHANISM])
case node[MECHANISM]
when PLAIN then plain_auth(node)
when EXTERNAL then external_auth(node)
end
else
send_auth_fail(SaslErrors::InvalidMechanism.new)
end
end
|