aboutsummaryrefslogtreecommitdiffstats
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/msn/msn.h2
-rw-r--r--protocols/msn/ns.c8
-rw-r--r--protocols/msn/soap.c27
3 files changed, 34 insertions, 3 deletions
diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h
index f6666178..ae4ea42b 100644
--- a/protocols/msn/msn.h
+++ b/protocols/msn/msn.h
@@ -203,7 +203,7 @@ extern GSList *msn_switchboards;
/* ns.c */
gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond );
-void msn_auth_got_passport_token( struct im_connection *ic, char *token );
+void msn_auth_got_passport_token( struct im_connection *ic, const char *token, const char *error );
void msn_auth_got_contact_list( struct im_connection *ic );
/* msn_util.c */
diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c
index a599b0ba..2449c8d5 100644
--- a/protocols/msn/ns.c
+++ b/protocols/msn/ns.c
@@ -696,7 +696,7 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int
return( 1 );
}
-void msn_auth_got_passport_token( struct im_connection *ic, char *token )
+void msn_auth_got_passport_token( struct im_connection *ic, const char *token, const char *error )
{
struct msn_data *md;
@@ -706,12 +706,18 @@ void msn_auth_got_passport_token( struct im_connection *ic, char *token )
md = ic->proto_data;
+ if( token )
{
char buf[1536];
g_snprintf( buf, sizeof( buf ), "USR %d SSO S %s %s\r\n", ++md->trId, md->tokens[0], token );
msn_write( ic, buf, strlen( buf ) );
}
+ else
+ {
+ imcb_error( ic, "Error during Passport authentication: %s", error );
+ imc_logout( ic, TRUE );
+ }
}
void msn_auth_got_contact_list( struct im_connection *ic )
diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c
index b8762ce1..fe716d9d 100644
--- a/protocols/msn/soap.c
+++ b/protocols/msn/soap.c
@@ -172,6 +172,7 @@ struct msn_soap_passport_sso_data
char *policy;
char *nonce;
char *secret;
+ char *error;
};
static int msn_soap_passport_sso_build_request( struct msn_soap_req_data *soap_req )
@@ -216,8 +217,25 @@ static xt_status msn_soap_passport_sso_token( struct xt_node *node, gpointer dat
return XT_HANDLED;
}
+static xt_status msn_soap_passport_failure( struct xt_node *node, gpointer data )
+{
+ struct msn_soap_req_data *soap_req = data;
+ struct msn_soap_passport_sso_data *sd = soap_req->data;
+ struct xt_node *code = xt_find_node( node->children, "faultcode" );
+ struct xt_node *string = xt_find_node( node->children, "faultstring" );
+
+ if( code == NULL || code->text_len == 0 )
+ sd->error = g_strdup( "Unknown error" );
+ else
+ sd->error = g_strdup_printf( "%s (%s)", code->text, string && string->text_len ?
+ string->text : "no description available" );
+
+ return XT_HANDLED;
+}
+
static const struct xt_handler_entry msn_soap_passport_sso_parser[] = {
{ "wsse:BinarySecurityToken", "wst:RequestedSecurityToken", msn_soap_passport_sso_token },
+ { "S:Fault", "S:Envelope", msn_soap_passport_failure },
{ NULL, NULL, NULL }
};
@@ -269,6 +287,12 @@ static int msn_soap_passport_sso_handle_response( struct msn_soap_req_data *soap
GUINT32_TO_LE( 20 ),
GUINT32_TO_LE( 72 ),
};
+
+ if( sd->secret == NULL )
+ {
+ msn_auth_got_passport_token( ic, NULL, sd->error );
+ return MSN_SOAP_OK;
+ }
key1_len = base64_decode( sd->secret, (unsigned char**) &key1 );
@@ -286,7 +310,7 @@ static int msn_soap_passport_sso_handle_response( struct msn_soap_req_data *soap
memcpy( blurb.cipherbytes, des3res, 72 );
blurb64 = base64_encode( (unsigned char*) &blurb, sizeof( blurb ) );
- msn_auth_got_passport_token( ic, blurb64 );
+ msn_auth_got_passport_token( ic, blurb64, NULL );
g_free( padnonce );
g_free( blurb64 );
@@ -305,6 +329,7 @@ static int msn_soap_passport_sso_free_data( struct msn_soap_req_data *soap_req )
g_free( sd->policy );
g_free( sd->nonce );
g_free( sd->secret );
+ g_free( sd->error );
return MSN_SOAP_OK;
}