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.



94
95
96
97
98
# File 'lib/sasl/base.rb', line 94

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

Instance Attribute Details

#mechanismObject (readonly)

Returns the value of attribute mechanism.



91
92
93
# File 'lib/sasl/base.rb', line 91

def mechanism
  @mechanism
end

#preferencesObject (readonly)

Returns the value of attribute preferences.



92
93
94
# File 'lib/sasl/base.rb', line 92

def preferences
  @preferences
end

Instance Method Details

#failure?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/sasl/base.rb', line 103

def failure?
  @state == :failure
end

#receive(message_name, content) ⇒ Object



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

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

#startObject

Raises:



107
108
109
# File 'lib/sasl/base.rb', line 107

def start
  raise AbstractMethod
end

#success?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/sasl/base.rb', line 100

def success?
  @state == :success
end