Class: DBus::Authentication::Client Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dbus/auth.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Authenticates the connection before messages can be exchanged.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(socket, mechs = nil) ⇒ Client

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create a new authentication client.

Parameters:

  • mechs (Array<Mechanism,Class>, nil) (defaults to: nil)

    custom list of auth Mechanism objects or classes



133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/dbus/auth.rb', line 133

def initialize(socket, mechs = nil)
  @unix_fd = false
  @address_uuid = nil

  @socket = socket
  @state = nil
  @auth_list = mechs || [
    External,
    DBusCookieSHA1,
    ExternalWithoutUid,
    Anonymous
  ]
end

Instance Attribute Details

#address_uuidString (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


129
130
131
# File 'lib/dbus/auth.rb', line 129

def address_uuid
  @address_uuid
end

#unix_fdBoolean (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

NOTE: not implemented yet in upper layers

Returns:

  • (Boolean)

    have we negotiated Unix file descriptor passing



126
127
128
# File 'lib/dbus/auth.rb', line 126

def unix_fd
  @unix_fd
end

Instance Method Details

#authenticatevoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Start the authentication process.



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/dbus/auth.rb', line 150

def authenticate
  DBus.logger.debug "Authenticating"
  send_nul_byte

  use_next_mechanism

  @state, command = next_state_via_mechanism.to_a
  send(command)

  loop do
    DBus.logger.debug "auth STATE: #{@state}"
    words = next_msg

    @state, command = next_state(words).to_a
    break if [:TerminatedOk, :TerminatedError].include? @state

    send(command)
  end

  raise AuthenticationFailed, command.first if @state == :TerminatedError

  send("BEGIN")
end