Module: SASL
- Defined in:
- lib/sasl/base.rb,
lib/sasl/plain.rb,
lib/sasl/anonymous.rb,
lib/sasl/digest_md5.rb
Overview
RFC 4422: tools.ietf.org/html/rfc4422
Defined Under Namespace
Classes: AbstractMethod, Anonymous, DigestMD5, Mechanism, Plain, Preferences, UnknownMechanism
Class Method Summary collapse
- .new(mechanisms, preferences) ⇒ Object
-
.new_mechanism(mechanism, preferences) ⇒ Object
Create a SASL Mechanism for the named mechanism.
Class Method Details
.new(mechanisms, preferences) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/sasl/base.rb', line 41 def SASL.new(mechanisms, preferences) best_mechanism = if preferences.want_anonymous? && mechanisms.include?('ANONYMOUS') 'ANONYMOUS' elsif preferences.has_password? if mechanisms.include?('DIGEST-MD5') 'DIGEST-MD5' elsif preferences.allow_plaintext? 'PLAIN' else raise UnknownMechanism.new(mechanisms) end else raise UnknownMechanism.new(mechanisms) end new_mechanism(best_mechanism, preferences) end |
.new_mechanism(mechanism, preferences) ⇒ Object
Create a SASL Mechanism for the named mechanism
- mechanism
- String
-
mechanism name
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/sasl/base.rb', line 62 def SASL.new_mechanism(mechanism, preferences) mechanism_class = case mechanism when 'DIGEST-MD5' DigestMD5 when 'PLAIN' Plain when 'ANONYMOUS' Anonymous else raise UnknownMechanism.new(mechanism) end mechanism_class.new(mechanism, preferences) end |