Class: SASL::Mechanism

Inherits:
Object
  • Object
show all
Defined in:
lib/sasl/base.rb

Overview

Common functions for mechanisms

Mechanisms implement handling of methods start and receive. They return: [message_name, content] or nil where message_name is either ‘auth’ or ‘response’ and content is either a string which may transmitted encoded as Base64 or nil.

Direct Known Subclasses

Anonymous, DigestMD5, Plain

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mechanism, preferences) ⇒ Mechanism

Returns a new instance of Mechanism.



116
117
118
119
120
# File 'lib/sasl/base.rb', line 116

def initialize(mechanism, preferences)
  @mechanism = mechanism
  @preferences = preferences
  @state = nil
end

Instance Attribute Details

#mechanismObject (readonly)

Returns the value of attribute mechanism.



113
114
115
# File 'lib/sasl/base.rb', line 113

def mechanism
  @mechanism
end

#preferencesObject (readonly)

Returns the value of attribute preferences.



114
115
116
# File 'lib/sasl/base.rb', line 114

def preferences
  @preferences
end

Instance Method Details

#failure?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/sasl/base.rb', line 125

def failure?
  @state == :failure
end

#receive(message_name, content) ⇒ Object



134
135
136
137
138
139
140
141
142
# File 'lib/sasl/base.rb', line 134

def receive(message_name, content)
  case message_name
  when 'success'
    @state = :success
  when 'failure'
    @state = :failure
  end
  nil
end

#startObject

Raises:



129
130
131
# File 'lib/sasl/base.rb', line 129

def start
  raise AbstractMethod
end

#success?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'lib/sasl/base.rb', line 122

def success?
  @state == :success
end