Class: Gsasl::RemoteAuthenticator

Inherits:
Object
  • Object
show all
Defined in:
lib/gsasl/remote_authenticator.rb

Overview

This class handles remote authentication sessions that are based on a socket like interaction mechanism. This class will most of the time not be used directly but through helper methods (See Peer#authenticate_with).

Instance Method Summary collapse

Constructor Details

#initializeRemoteAuthenticator

Returns a new instance of RemoteAuthenticator.



6
7
8
9
# File 'lib/gsasl/remote_authenticator.rb', line 6

def initialize
  @receive_callback = nil
  @send_callback = nil
end

Instance Method Details

#receive { ... } ⇒ Object

This defines or calls the recieve callback. It will be defined, if a block is given, otherwise the callback is going to be called.

Yields:

  • the block that is going to be called if data need to be read from the remote site.

Yield Returns:

  • (String)

    the callback should return a string that includes a challenge



17
18
19
20
21
22
23
24
25
26
# File 'lib/gsasl/remote_authenticator.rb', line 17

def receive(&block)
  if block_given?
    # define the callback
    @receive_callback = block
  elsif @receive_callback
    @receive_callback.call
  else
    raise GsaslError, "The receive callback is not defined!"
  end
end

#send(data = nil) {|data| ... } ⇒ Object

This defines or calls the send callback. It will be defined, if a block is given, otherwise the callback is going to be called.

Yields:

  • (data)

    the block that is going to be called if data need to be send to the remote site.

Yield Parameters:

  • data (String)

    that should be send to a remote site.



33
34
35
36
37
38
39
40
41
42
# File 'lib/gsasl/remote_authenticator.rb', line 33

def send(data = nil, &block)
  if block_given?
    # define the callback
    @send_callback = block
  elsif @send_callback
    @send_callback.call(data)
  else
    raise GsaslError, "The send callback is not defined!"
  end
end