summaryrefslogtreecommitdiff
path: root/libpurple/protocols/jabber/auth.c
diff options
context:
space:
mode:
authorPaul Aurich <darkrain42@pidgin.im>2009-12-01 07:32:53 +0000
committerPaul Aurich <darkrain42@pidgin.im>2009-12-01 07:32:53 +0000
commit914c238288f4fe2114d2c27082dddde74229408a (patch)
tree23731792c985a7247219893e70e0137521150421 /libpurple/protocols/jabber/auth.c
parentc0f35ed74c23c0b1efe92e2aa5f792054e90b22e (diff)
downloadpidgin-914c238288f4fe2114d2c27082dddde74229408a.tar.gz
Let's try a more complex set of return states / values for auth mechs.
This won't build with Cyrus support yet.
Diffstat (limited to 'libpurple/protocols/jabber/auth.c')
-rw-r--r--libpurple/protocols/jabber/auth.c47
1 files changed, 37 insertions, 10 deletions
diff --git a/libpurple/protocols/jabber/auth.c b/libpurple/protocols/jabber/auth.c
index 64df7b5de9..c2a0125fe3 100644
--- a/libpurple/protocols/jabber/auth.c
+++ b/libpurple/protocols/jabber/auth.c
@@ -162,8 +162,10 @@ jabber_auth_start(JabberStream *js, xmlnode *packet)
{
GSList *mechanisms = NULL;
GSList *l;
- xmlnode *response;
+ xmlnode *response = NULL;
xmlnode *mechs, *mechnode;
+ JabberSaslState state;
+ const char *msg = NULL;
if(js->registration) {
jabber_register_start(js);
@@ -214,8 +216,12 @@ jabber_auth_start(JabberStream *js, xmlnode *packet)
return;
}
- response = js->auth_mech->start(js, mechs);
- if (response) {
+ state = js->auth_mech->start(js, mechs, &response, &msg);
+ if (state == JABBER_SASL_STATE_FAIL) {
+ purple_connection_error_reason(js->gc,
+ PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
+ msg ? msg : _("Unknown Error"));
+ } else if (response) {
jabber_send(js, response);
xmlnode_free(response);
}
@@ -413,8 +419,14 @@ jabber_auth_handle_challenge(JabberStream *js, xmlnode *packet)
}
if (js->auth_mech && js->auth_mech->handle_challenge) {
- xmlnode *response = js->auth_mech->handle_challenge(js, packet);
- if (response != NULL) {
+ xmlnode *response = NULL;
+ const char *msg = NULL;
+ JabberSaslState state = js->auth_mech->handle_challenge(js, packet, &response, &msg);
+ if (state == JABBER_SASL_STATE_FAIL) {
+ purple_connection_error_reason(js->gc,
+ PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
+ msg ? msg : _("Invalid challenge from server"));
+ } else if (response) {
jabber_send(js, response);
xmlnode_free(response);
}
@@ -433,9 +445,21 @@ void jabber_auth_handle_success(JabberStream *js, xmlnode *packet)
return;
}
- if (js->auth_mech && js->auth_mech->handle_success &&
- !js->auth_mech->handle_success(js, packet)) {
- return;
+ if (js->auth_mech && js->auth_mech->handle_success) {
+ const char *msg = NULL;
+ JabberSaslState state = js->auth_mech->handle_success(js, packet, &msg);
+
+ if (state == JABBER_SASL_STATE_FAIL) {
+ purple_connection_error_reason(js->gc,
+ PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
+ msg ? msg : _("Invalid response from server"));
+ return;
+ } else if (state == JABBER_SASL_STATE_CONTINUE) {
+ purple_connection_error_reason(js->gc,
+ PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
+ msg ? msg : _("Server thinks authentication is complete, but client does not"));
+ return;
+ }
}
/*
@@ -452,8 +476,11 @@ void jabber_auth_handle_failure(JabberStream *js, xmlnode *packet)
char *msg;
if (js->auth_mech && js->auth_mech->handle_failure) {
- xmlnode *stanza = js->auth_mech->handle_failure(js, packet);
- if (stanza) {
+ xmlnode *stanza = NULL;
+ const char *msg = NULL;
+ JabberSaslState state = js->auth_mech->handle_failure(js, packet, &stanza, &msg);
+
+ if (state != JABBER_SASL_STATE_FAIL && stanza) {
jabber_send(js, stanza);
xmlnode_free(stanza);
return;