Commit f53d8426 authored by Alexander Kanavin's avatar Alexander Kanavin

Merge branch 'tintou/latest-api' into 'master'

Adapt to latest API changes

See merge request !1
parents de363089 1f5de902
......@@ -37,7 +37,7 @@ static const gchar* allowed_realms[] = { "megahostname", NULL };
static void final_response_callback(GSignondPlugin* plugin, GSignondSessionData* result,
gpointer user_data)
{
const gchar* response = gsignond_dictionary_get_string(result,
const gchar* response = gsignond_dictionary_get_string(GSIGNOND_DICTIONARY(result),
"ResponseBase64");
g_print("Authenticated successfully, got final response:\n%s\n",
response);
......@@ -47,7 +47,7 @@ static void response_callback(GSignondPlugin* plugin, GSignondSessionData* resul
gpointer user_data)
{
//print the received intermediate response
const gchar* response = gsignond_dictionary_get_string(result,
const gchar* response = gsignond_dictionary_get_string(GSIGNOND_DICTIONARY(result),
"ResponseBase64");
g_print("Authenticated successfully, got intermediate response:\n%s\n",
response);
......@@ -58,10 +58,10 @@ static void response_callback(GSignondPlugin* plugin, GSignondSessionData* resul
const gchar* server_challenge = "some challenge";
//submit the challenge to the plugin
GSignondSessionData* data = gsignond_dictionary_new();
gsignond_dictionary_set_string(data, "ChallengeBase64", server_challenge);
GSignondSessionData* data = gsignond_session_data_new();
gsignond_dictionary_set_string(GSIGNOND_DICTIONARY(data), "ChallengeBase64", server_challenge);
gsignond_plugin_request(plugin, data);
gsignond_dictionary_unref(data);
g_object_unref(data);
}
// print an error and exit the mainloop
......@@ -73,21 +73,21 @@ static void error_callback(GSignondPlugin* plugin, GError* error,
static void anonymous_authorization(gpointer plugin)
{
GSignondSessionData* data = gsignond_dictionary_new();
GSignondSessionData* data = gsignond_session_data_new();
//fill in necessary data
gsignond_dictionary_set_string(data, "AnonymousToken",
gsignond_dictionary_set_string(GSIGNOND_DICTIONARY(data), "AnonymousToken",
"megauser@example.com");
//start the authorization
//any further processing happens in signal callbacks
gsignond_plugin_request_initial(plugin, data, NULL, "ANONYMOUS");
gsignond_dictionary_unref(data);
g_object_unref(data);
}
static void plain_authorization(gpointer plugin)
{
GSignondSessionData* data = gsignond_dictionary_new();
GSignondSessionData* data = gsignond_session_data_new();
//fill in necessary data
gsignond_session_data_set_username(data, "megauser@example.com");
......@@ -96,62 +96,62 @@ static void plain_authorization(gpointer plugin)
//start the authorization
//any further processing happens in signal callbacks
gsignond_plugin_request_initial(plugin, data, NULL, "PLAIN");
gsignond_dictionary_unref(data);
g_object_unref(data);
}
static void cram_md5_authorization(gpointer plugin)
{
GSignondSessionData* data = gsignond_dictionary_new();
GSignondSessionData* data = gsignond_session_data_new();
//fill in necessary data
gsignond_session_data_set_username(data, "megauser@example.com");
gsignond_session_data_set_secret(data, "megapassword");
//initial server challenge, for simplicty it's hardcoded
gsignond_dictionary_set_string(data, "ChallengeBase64", "some challenge");
gsignond_dictionary_set_string(GSIGNOND_DICTIONARY(data), "ChallengeBase64", "some challenge");
//start the authorization
//any further processing happens in signal callbacks
gsignond_plugin_request_initial(plugin, data, NULL, "CRAM-MD5");
gsignond_dictionary_unref(data);
g_object_unref(data);
}
static void digest_md5_authorization(gpointer plugin)
{
GSignondSessionData* data = gsignond_dictionary_new();
GSignondSessionData* data = gsignond_session_data_new();
//fill in necessary data
gsignond_dictionary_set_string(data, "Service", "megaservice");
gsignond_dictionary_set_string(data, "Hostname", "megahostname");
gsignond_dictionary_set_string(GSIGNOND_DICTIONARY(data), "Service", "megaservice");
gsignond_dictionary_set_string(GSIGNOND_DICTIONARY(data), "Hostname", "megahostname");
GSequence* allowed_realms_s = gsignond_copy_array_to_sequence(allowed_realms);
gsignond_session_data_set_allowed_realms(data, allowed_realms_s);
g_sequence_free(allowed_realms_s);
gsignond_session_data_set_username(data, "megauser@example.com");
gsignond_session_data_set_secret(data, "megapassword");
//initial server challenge, for simplicty it's hardcoded
gsignond_dictionary_set_string(data, "ChallengeBase64", "some challenge");
gsignond_dictionary_set_string(GSIGNOND_DICTIONARY(data), "ChallengeBase64", "some challenge");
//start the authorization
//any further processing happens in signal callbacks
gsignond_plugin_request_initial(plugin, data, NULL, "DIGEST-MD5");
gsignond_dictionary_unref(data);
g_object_unref(data);
}
static void scram_sha1_authorization(gpointer plugin)
{
GSignondSessionData* data = gsignond_dictionary_new();
GSignondSessionData* data = gsignond_session_data_new();
//fill in necessary data
gsignond_session_data_set_username(data, "megauser@example.com");
gsignond_session_data_set_secret(data, "megapassword");
//initial server challenge, for simplicty it's hardcoded
gsignond_dictionary_set_string(data, "ChallengeBase64", "some challenge");
gsignond_dictionary_set_string(GSIGNOND_DICTIONARY(data), "ChallengeBase64", "some challenge");
//start the authorization
//any further processing happens in signal callbacks
gsignond_plugin_request_initial(plugin, data, NULL, "SCRAM-SHA-1");
gsignond_dictionary_unref(data);
g_object_unref(data);
}
......
......@@ -198,7 +198,7 @@ static void gsignond_sasl_plugin_cancel (GSignondPlugin *self)
static void _reset_session(GSignondSaslPlugin *self)
{
if (self->session_data) {
gsignond_dictionary_unref(self->session_data);
g_object_unref(self->session_data);
self->session_data = NULL;
}
if (self->gsasl_session) {
......@@ -225,8 +225,8 @@ _do_gsasl_iteration(GSignondPlugin *plugin, const gchar* challenge)
return;
}
GSignondSessionData *response = gsignond_dictionary_new();
gsignond_dictionary_set_string(response, "ResponseBase64", output);
GSignondSessionData *response = gsignond_session_data_new();
gsignond_dictionary_set_string(GSIGNOND_DICTIONARY(response), "ResponseBase64", output);
if (step_res == GSASL_OK) {
_reset_session(self);
......@@ -236,7 +236,7 @@ _do_gsasl_iteration(GSignondPlugin *plugin, const gchar* challenge)
}
free(output);
gsignond_dictionary_unref(response);
g_object_unref(response);
}
......@@ -274,7 +274,7 @@ _gsasl_callback (Gsasl * gsasl_context,
case GSASL_AUTHZID:
return _set_gsasl_property(gsasl_session, gsasl_property,
gsignond_dictionary_get_string(
session_data, "Authzid"));
GSIGNOND_DICTIONARY(session_data), "Authzid"));
break;
case GSASL_PASSWORD:
return _set_gsasl_property(gsasl_session, gsasl_property,
......@@ -284,77 +284,77 @@ _gsasl_callback (Gsasl * gsasl_context,
case GSASL_ANONYMOUS_TOKEN:
return _set_gsasl_property(gsasl_session, gsasl_property,
gsignond_dictionary_get_string(
session_data, "AnonymousToken"));
GSIGNOND_DICTIONARY(session_data), "AnonymousToken"));
break;
case GSASL_SERVICE:
return _set_gsasl_property(gsasl_session, gsasl_property,
gsignond_dictionary_get_string(
session_data, "Service"));
GSIGNOND_DICTIONARY(session_data), "Service"));
break;
case GSASL_HOSTNAME:
return _set_gsasl_property(gsasl_session, gsasl_property,
gsignond_dictionary_get_string(
session_data, "Hostname"));
GSIGNOND_DICTIONARY(session_data), "Hostname"));
break;
case GSASL_GSSAPI_DISPLAY_NAME:
return _set_gsasl_property(gsasl_session, gsasl_property,
gsignond_dictionary_get_string(
session_data, "GssapiDisplayName"));
GSIGNOND_DICTIONARY(session_data), "GssapiDisplayName"));
break;
case GSASL_PASSCODE:
return _set_gsasl_property(gsasl_session, gsasl_property,
gsignond_dictionary_get_string(
session_data, "Passcode"));
GSIGNOND_DICTIONARY(session_data), "Passcode"));
break;
case GSASL_SUGGESTED_PIN:
return _set_gsasl_property(gsasl_session, gsasl_property,
gsignond_dictionary_get_string(
session_data, "SuggestedPin"));
GSIGNOND_DICTIONARY(session_data), "SuggestedPin"));
break;
case GSASL_PIN:
return _set_gsasl_property(gsasl_session, gsasl_property,
gsignond_dictionary_get_string(
session_data, "Pin"));
GSIGNOND_DICTIONARY(session_data), "Pin"));
break;
case GSASL_REALM:
return _set_gsasl_property(gsasl_session, gsasl_property,
gsignond_dictionary_get_string(
session_data, "Realm"));
GSIGNOND_DICTIONARY(session_data), "Realm"));
break;
case GSASL_DIGEST_MD5_HASHED_PASSWORD:
return _set_gsasl_property(gsasl_session, gsasl_property,
gsignond_dictionary_get_string(
session_data, "DigestMd5HashedPassword"));
GSIGNOND_DICTIONARY(session_data), "DigestMd5HashedPassword"));
break;
case GSASL_QOPS:
return _set_gsasl_property(gsasl_session, gsasl_property,
gsignond_dictionary_get_string(
session_data, "Qops"));
GSIGNOND_DICTIONARY(session_data), "Qops"));
break;
case GSASL_QOP:
return _set_gsasl_property(gsasl_session, gsasl_property,
gsignond_dictionary_get_string(
session_data, "Qop"));
GSIGNOND_DICTIONARY(session_data), "Qop"));
break;
case GSASL_SCRAM_ITER:
return _set_gsasl_property(gsasl_session, gsasl_property,
gsignond_dictionary_get_string(
session_data, "ScramIter"));
GSIGNOND_DICTIONARY(session_data), "ScramIter"));
break;
case GSASL_SCRAM_SALT:
return _set_gsasl_property(gsasl_session, gsasl_property,
gsignond_dictionary_get_string(
session_data, "ScramSalt"));
GSIGNOND_DICTIONARY(session_data), "ScramSalt"));
break;
case GSASL_SCRAM_SALTED_PASSWORD:
return _set_gsasl_property(gsasl_session, gsasl_property,
gsignond_dictionary_get_string(
session_data, "ScramSaltedPassword"));
GSIGNOND_DICTIONARY(session_data), "ScramSaltedPassword"));
break;
case GSASL_CB_TLS_UNIQUE:
return _set_gsasl_property(gsasl_session, gsasl_property,
gsignond_dictionary_get_string(
session_data, "CbTlsUnique"));
GSIGNOND_DICTIONARY(session_data), "CbTlsUnique"));
break;
default:
break;
......@@ -376,7 +376,7 @@ static void gsignond_sasl_plugin_request (
g_error_free(error);
return;
}
_do_gsasl_iteration(plugin, gsignond_dictionary_get_string(session_data, "ChallengeBase64"));
_do_gsasl_iteration(plugin, gsignond_dictionary_get_string(GSIGNOND_DICTIONARY(session_data), "ChallengeBase64"));
}
static void gsignond_sasl_plugin_request_initial (
......@@ -401,7 +401,7 @@ static void gsignond_sasl_plugin_request_initial (
return;
}
realm = gsignond_session_data_get_realm (session_data);
host = gsignond_dictionary_get_string(session_data, "Hostname");
host = gsignond_dictionary_get_string(GSIGNOND_DICTIONARY(session_data), "Hostname");
allowed_realms = gsignond_session_data_get_allowed_realms (session_data);
if (allowed_realms) {
for (realm_iter = g_sequence_get_begin_iter (allowed_realms);
......@@ -450,14 +450,13 @@ static void gsignond_sasl_plugin_request_initial (
g_error_free (error);
return;
}
gsignond_dictionary_ref(session_data);
self->session_data = session_data;
_do_gsasl_iteration(plugin, gsignond_dictionary_get_string(session_data, "ChallengeBase64"));
self->session_data = g_object_ref(session_data);
_do_gsasl_iteration(plugin, gsignond_dictionary_get_string(GSIGNOND_DICTIONARY(session_data), "ChallengeBase64"));
}
static void gsignond_sasl_plugin_user_action_finished (
GSignondPlugin *plugin,
GSignondSessionData *session_data)
GSignondSignonuiData *ui_data)
{
GError* error = g_error_new(GSIGNOND_ERROR,
GSIGNOND_ERROR_WRONG_STATE,
......@@ -469,7 +468,7 @@ static void gsignond_sasl_plugin_user_action_finished (
static void gsignond_sasl_plugin_refresh (
GSignondPlugin *plugin,
GSignondSessionData *session_data)
GSignondSignonuiData *ui_data)
{
GError* error = g_error_new(GSIGNOND_ERROR,
GSIGNOND_ERROR_WRONG_STATE,
......
......@@ -57,7 +57,7 @@ struct _GSignondSaslPlugin
Gsasl *gsasl_context;
Gsasl_session *gsasl_session;
GSignondDictionary* session_data;
GSignondSessionData* session_data;
};
struct _GSignondSaslPluginClass
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment