CamelSasl
3
CAMEL Library

# CamelSasl

## Synopsis

                        CamelSasl;
    GByteArray*         camel_sasl_challenge                (CamelSasl *sasl,
                                                             GByteArray *token,
                                                             CamelException *ex);
    char*               camel_sasl_challenge_base64         (CamelSasl *sasl,
                                                             const char *token,
                                                             CamelException *ex);
    gboolean            camel_sasl_authenticated            (CamelSasl *sasl);
    CamelSasl*          camel_sasl_new                      (const char *service_name,
                                                             const char *mechanism,
                                                             CamelService *service);
    GList*              camel_sasl_authtype_list            (gboolean include_plain);
    CamelServiceAuthType* camel_sasl_authtype               (const char *mechanism);

## Description

## Details

### CamelSasl

    typedef struct {
    	CamelObject parent_object;

    	char *service_name;
    	char *mech;		/* mechanism */
    	CamelService *service;
    	gboolean authenticated;
    } CamelSasl;

### camel_sasl_challenge ()

    GByteArray*         camel_sasl_challenge                (CamelSasl *sasl,
                                                             GByteArray *token,
                                                             CamelException *ex);

If `token` is `NULL`, generate the initial SASL message to send to the server. (This will be `NULL` if the client doesn't initiate the exchange.) Otherwise, `token` is a challenge from the server, and the return value is the response.

`sasl` :

  a CamelSasl object

`token` :

  a token, or `NULL`

`ex` :

  a CamelException

Returns :

  the SASL response or `NULL`. If an error occurred, `ex` will also be set.

### camel_sasl_challenge_base64 ()

    char*               camel_sasl_challenge_base64         (CamelSasl *sasl,
                                                             const char *token,
                                                             CamelException *ex);

As with camel_sasl_challenge, but the challenge `token` and the response are both base64-encoded.

`sasl` :

  a CamelSasl object

`token` :

  a base64-encoded token

`ex` :

  a CamelException

Returns :

  the base64 encoded challenge string

### camel_sasl_authenticated ()

    gboolean            camel_sasl_authenticated            (CamelSasl *sasl);

`sasl` :

  a CamelSasl object

Returns :

  whether or not `sasl` has successfully authenticated the user. This will be `TRUE` after it returns the last needed response. The caller must still pass that information on to the server and verify that it has accepted it.

### camel_sasl_new ()

    CamelSasl*          camel_sasl_new                      (const char *service_name,
                                                             const char *mechanism,
                                                             CamelService *service);

`service_name` :

  the SASL service name

`mechanism` :

  the SASL mechanism

`service` :

  the CamelService that will be using this SASL

Returns :

  a new CamelSasl object for the given `service_name`, `mechanism`, and `service`, or `NULL` if the mechanism is not supported.

### camel_sasl_authtype_list ()

    GList*              camel_sasl_authtype_list            (gboolean include_plain);

`include_plain` :

  whether or not to include the PLAIN mechanism

Returns :

  a GList of SASL-supported authtypes. The caller must free the list, but not the contents.

### camel_sasl_authtype ()

    CamelServiceAuthType* camel_sasl_authtype               (const char *mechanism);

`mechanism` :

  the SASL mechanism to get an authtype for

Returns :

  a CamelServiceAuthType for the given mechanism, if it is supported.