Class: Jabber::Bosh::Authentication::SASL::Query
- Inherits:
-
Object
- Object
- Jabber::Bosh::Authentication::SASL::Query
- Defined in:
- lib/jabber4r/bosh/authentication/sasl.rb
Constant Summary collapse
- MECHANISMS =
Full list of mechanisms www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml
[:plain].freeze
Instance Attribute Summary collapse
-
#jid ⇒ Object
readonly
Returns the value of attribute jid.
-
#mechanism ⇒ Object
readonly
Returns the value of attribute mechanism.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
Instance Method Summary collapse
-
#dump ⇒ Object
(also: #to_xml)
Public: Create XML string from SASL object.
-
#initialize(jid, password, options = {}) ⇒ Query
constructor
Public: Creates new SASL authentication object.
-
#plain? ⇒ Boolean
Public: Is SASL object is for plain authentication.
-
#to_ox ⇒ Object
Public: Create Ox::Element from SASL object.
Constructor Details
#initialize(jid, password, options = {}) ⇒ Query
Public: Creates new SASL authentication object
jid - [Jabber::JID|String] the jid of jabber server user password - String the user password options - Hash the authentication options (default: Empty hash)
:mechanism - Symbol the name of mechnism to use
Examples
non_sasl = Jabber::Protocol::Authentication::SASL.new(“strech@localhost/res-1”, “my-pass-phrase”) non_sasl.plain? # => true non_sasl.to_xml # =>
<auth xmlns=“urn:ietf:params:xml:ns:xmpp-sasl” mechanism=“PLAIN”>biwsbj1qdWxpZXQscj1vTXNUQUF3QUFBQU1BQUFBTlAwVEFBQUFBQUJQVTBBQQ==</auth>
184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/jabber4r/bosh/authentication/sasl.rb', line 184 def initialize(jid, password, = {}) raise TypeError, "Class(Jabber::JID) or Class(String) expected," + " but #{jid.class} was given" unless jid.is_a?(Jabber::JID) || jid.is_a?(String) @jid = jid.is_a?(Jabber::JID) ? jid : Jabber::JID.new(jid) @password = password @mechanism = .fetch(:mechanism, :plain) raise ArgumentError, "Unknown authentication mechanism '#{mechanism}'," + " available is [#{MECHANISMS * ", "}]" unless MECHANISMS.include?(mechanism) end |
Instance Attribute Details
#jid ⇒ Object (readonly)
Returns the value of attribute jid.
167 168 169 |
# File 'lib/jabber4r/bosh/authentication/sasl.rb', line 167 def jid @jid end |
#mechanism ⇒ Object (readonly)
Returns the value of attribute mechanism.
168 169 170 |
# File 'lib/jabber4r/bosh/authentication/sasl.rb', line 168 def mechanism @mechanism end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
167 168 169 |
# File 'lib/jabber4r/bosh/authentication/sasl.rb', line 167 def password @password end |
Instance Method Details
#dump ⇒ Object Also known as: to_xml
Public: Create XML string from SASL object
Returns String
209 210 211 |
# File 'lib/jabber4r/bosh/authentication/sasl.rb', line 209 def dump Ox.dump(send mechanism) end |
#plain? ⇒ Boolean
Public: Is SASL object is for plain authentication
Returns boolean
202 203 204 |
# File 'lib/jabber4r/bosh/authentication/sasl.rb', line 202 def plain? mechanism == :plain end |
#to_ox ⇒ Object
Public: Create Ox::Element from SASL object
Returns Ox::Element
217 218 219 |
# File 'lib/jabber4r/bosh/authentication/sasl.rb', line 217 def to_ox send(mechanism) end |