Class: Net::SASL::LoginAuthenticator

Inherits:
Authenticator show all
Defined in:
lib/net/sasl/login_authenticator.rb

Overview

Authenticator for the “LOGIN” SASL mechanism. The authentication credentials are transmitted in cleartext so this mechanism should only be used over an encrypted link.

Deprecated

The SASL mechanisms registry marks “LOGIN” as obsoleted by “PLAIN”. It is included here for compatibility with existing servers. See draft-murchison-sasl-login for both specification and deprecation.

Constant Summary collapse

STATE_DONE =
:DONE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Authenticator

#supports_initial_response?

Constructor Details

#initialize(username, password, **_options) ⇒ LoginAuthenticator

Provide the username and password credentials for authentication.

LOGIN doesn’t support authzid, and an ArgumentError will be raised if a third positional parameter is passed.

This should generally be instantiated via Net::SASL.authenticator.



28
29
30
31
# File 'lib/net/sasl/login_authenticator.rb', line 28

def initialize(username, password, **_options)
  super
  @state = STATE_USER
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



20
21
22
# File 'lib/net/sasl/login_authenticator.rb', line 20

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



20
21
22
# File 'lib/net/sasl/login_authenticator.rb', line 20

def username
  @username
end

Instance Method Details

#done?Boolean

Returns true after sending the username and password.

Returns:

  • (Boolean)


46
47
48
# File 'lib/net/sasl/login_authenticator.rb', line 46

def done?
  @state == STATE_DONE
end

#process(data) ⇒ Object

returns the SASL response for LOGIN



34
35
36
37
38
39
40
41
42
43
# File 'lib/net/sasl/login_authenticator.rb', line 34

def process(data)
  case @state
  when STATE_USER
    @state = STATE_PASSWORD
    @username
  when STATE_PASSWORD
    @state = STATE_DONE
    @password
  end
end