Infinity.SaslContext

Fields

None

Methods

class

new ()

client_list_mechanisms ()

client_start_session (io, mech, session_data)

client_suggest_mechanism (mechanisms)

client_supports_mechanism (mech)

ref ()

server_list_mechanisms ()

server_start_session (io, mech, session_data)

server_supports_mechanism (mech)

set_callback (callback, *user_data)

stop_session (session)

unref ()

Details

class Infinity.SaslContext

Infinity.SaslContext is an opaque data type. You should only access it via the public API functions.

classmethod new()
Raises:

GLib.Error

Returns:

A new Infinity.SaslContext, or None on error. Free with Infinity.SaslContext.unref() when no longer needed.

Return type:

Infinity.SaslContext

Creates a new Infinity.SaslContext with a reference count of 1. If the function fails it returns None and error is set.

client_list_mechanisms()
Raises:

GLib.Error

Returns:

A newly allocated string. Free with GLib.free() when no longer in use.

Return type:

str

Returns a newly allocated space-separated string containing SASL mechanisms that self supports for client sessions.

client_start_session(io, mech, session_data)
Parameters:
Raises:

GLib.Error

Returns:

A Infinity.SaslContextSession.

Return type:

Infinity.SaslContextSession

Starts a new client-side SASL session using mech for authentication. When the session finished, that is either when an error occurred or the authentication finished successfully, use Infinity.SaslContext.stop_session().

The callback function will be called in the thread that io runs in.

client_suggest_mechanism(mechanisms)
Parameters:

mechanisms (str) – Space-separated list of SASL mechanism names.

Returns:

The name of the suggested mechanism.

Return type:

str

Given a list of SASL mechanisms this function suggests the which is the “best” one to be used.

client_supports_mechanism(mech)
Parameters:

mech (str) – The name of the mechanism to be tested.

Returns:

True if mech is supported or False otherwise.

Return type:

bool

Checks whether self supports the mechanism with name mech for client sessions.

ref()
Returns:

The passed in pointer, self.

Return type:

Infinity.SaslContext

Increases the reference count of self by one.

server_list_mechanisms()
Raises:

GLib.Error

Returns:

A newly allocated string. Free with GLib.free() when no longer in use.

Return type:

str

Returns a newly allocated space-separated string containing SASL mechanisms that self supports for server sessions.

server_start_session(io, mech, session_data)
Parameters:
Raises:

GLib.Error

Returns:

A Infinity.SaslContextSession.

Return type:

Infinity.SaslContextSession

Starts a new server-side SASL session using mech for authentication. When the session finished, that is either when an error occurred or the authentication finished successfully, use Infinity.SaslContext.stop_session().

The callback function will be called in the thread that io runs in.

server_supports_mechanism(mech)
Parameters:

mech (str) – The name of the mechanism to be tested.

Returns:

True if mech is supported or False otherwise.

Return type:

bool

Checks whether self supports the mechanism with name mech for server sessions.

set_callback(callback, *user_data)
Parameters:

Sets the callback to call when, during authentication, a certain properties needs to be provided, such as a username or a password. The callback function is expected to set the requested property using Infinity.SaslContextSession.set_property() and then call Infinity.SaslContextSession.continue_() with retval being GSASL_OK. If it cannot provide the property then it should only call Infinity.SaslContextSession.continue_() with retval indicating the problem.

The callback function does not need to provide the property immediately. It is also allowed return and call Infinity.SaslContextSession.continue_() later.

stop_session(session)
Parameters:

session (Infinity.SaslContextSession) – A Infinity.SaslContextSession created with self.

Finishes session and frees all resources allocated to it. This can be used to cancel an authentication session, or to free it after it finished (either successfully or not).

session should no longer be used after this function was called.

unref()

Decreases the reference count of sasl by one. When the reference count reaches zero then the object is freed and may no longer be used. If that happens then also all sessions created with Infinity.SaslContext.client_start_session() or Infinity.SaslContext.server_start_session() are stopped automatically.