class Qpid::Proton::SASL

The SASL layer is responsible for establishing an authenticated and/or encrypted tunnel over which AMQP frames are passed between peers.

The peer acting as the SASL client must provide authentication credentials.

The peer acting as the SASL server must provide authentication against the received credentials.

@example

# SCENARIO: the remote endpoint has not initialized their connection
#           then the local endpoint, acting as a SASL server, decides
#           to allow an anonymous connection.
#
#           The SASL layer locally assumes the role of server and then
#           enables anonymous authentication for the remote endpoint.
#
sasl = @transport.sasl
sasl.server
sasl.mechanisms("ANONYMOUS")
sasl.done(Qpid::Proton::SASL::OK)

Constants

AUTH

Authentication failed due to bad credentials.

NONE

Negotation has not completed.

OK

Authentication succeeded.

Public Class Methods

new(transport) click to toggle source

Constructs a new instance for the given transport.

@param transport [Transport] The transport.

@private A SASL should be fetched only from its Transport

# File lib/core/sasl.rb, line 59
def initialize(transport)
  @impl = Cproton.pn_sasl(transport.impl)
end

Public Instance Methods

done(outcome) click to toggle source

Set the condition of the SASL negotiation.

@param outcome [Fixnum] The outcome.

# File lib/core/sasl.rb, line 88
def done(outcome)
  Cproton.pn_sasl_done(@impl, outcome)
end
mechanisms(mechanisms) click to toggle source

Sets the acceptable SASL mechanisms.

@param mechanisms [String] The space-delimited set of mechanisms.

@example Use anonymous SASL authentication.

@sasl.mechanisms("GSSAPI CRAM-MD5 PLAIN")
# File lib/core/sasl.rb, line 70
def mechanisms(mechanisms)
  Cproton.pn_sasl_mechanisms(@impl, mechanisms)
end
outcome() click to toggle source

Returns the outcome of the SASL negotiation.

@return [Fixnum] The outcome.

# File lib/core/sasl.rb, line 78
def outcome
  outcome = Cprotn.pn_sasl_outcome(@impl)
  return nil if outcome == NONE
  outcome
end