Class: Qpid::Proton::SASL

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

Overview

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.

Examples:

# 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)

Constant Summary collapse

NONE =

Negotation has not completed.

Cproton::PN_SASL_NONE
OK =

Authentication succeeded.

Cproton::PN_SASL_OK
AUTH =

Authentication failed due to bad credentials.

Cproton::PN_SASL_AUTH

Instance Method Summary collapse

Instance Method Details

#done(outcome) ⇒ Object

Set the condition of the SASL negotiation.

Parameters:

  • outcome (Fixnum)

    The outcome.



88
89
90
# File 'lib/core/sasl.rb', line 88

def done(outcome)
  Cproton.pn_sasl_done(@impl, outcome)
end

#mechanisms(mechanisms) ⇒ Object

Sets the acceptable SASL mechanisms.

Examples:

Use anonymous SASL authentication.

@sasl.mechanisms("GSSAPI CRAM-MD5 PLAIN")

Parameters:

  • mechanisms (String)

    The space-delimited set of mechanisms.



70
71
72
# File 'lib/core/sasl.rb', line 70

def mechanisms(mechanisms)
  Cproton.pn_sasl_mechanisms(@impl, mechanisms)
end

#outcomeFixnum

Returns the outcome of the SASL negotiation.

Returns:

  • (Fixnum)

    The outcome.



78
79
80
81
82
# File 'lib/core/sasl.rb', line 78

def outcome
  outcome = Cprotn.pn_sasl_outcome(@impl)
  return nil if outcome == NONE
  outcome
end