comparison src/protocols/simple/simple.c @ 11424:e1ab173ef3b5

[gaim-migrate @ 13661] prefs for STUN adjustments for NTLM in SIP committer: Tailor Script <tailor@pidgin.im>
author Thomas Butter <tbutter>
date Fri, 02 Sep 2005 09:09:04 +0000
parents 1e495a5fcbbc
children 617e67e1c985
comparison
equal deleted inserted replaced
11423:202a3b3c5a88 11424:e1ab173ef3b5
273 ret = g_strdup_printf("Digest username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", nc=\"%s\", response=\"%s\"\r\n",sip->username, auth->realm, auth->nonce, target, noncecount, response); 273 ret = g_strdup_printf("Digest username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", nc=\"%s\", response=\"%s\"\r\n",sip->username, auth->realm, auth->nonce, target, noncecount, response);
274 return ret; 274 return ret;
275 } else if(auth->type == 2) { /* NTLM */ 275 } else if(auth->type == 2) { /* NTLM */
276 if(auth->nc == 3) { 276 if(auth->nc == 3) {
277 ret = gaim_ntlm_gen_type3(sip->username, sip->password, "gaim", sip->servername, auth->nonce); 277 ret = gaim_ntlm_gen_type3(sip->username, sip->password, "gaim", sip->servername, auth->nonce);
278 tmp = g_strdup_printf("NTLM %s\r\n",ret); 278 tmp = g_strdup_printf("NTLM qop=\"auth\" realm=\"%s\" targetname=\"%s\" response=\"%s\"\r\n",auth->realm, auth->target, ret);
279 g_free(ret); 279 g_free(ret);
280 return tmp; 280 return tmp;
281 } 281 }
282 ret = gaim_ntlm_gen_type1("gaim", sip->servername); 282 ret = gaim_ntlm_gen_type1("gaim", sip->servername);
283 tmp = g_strdup_printf("NTLM %s\r\n", ret); 283 /* tmp = g_strdup_printf("NTLM qop=\"auth\" realm=\"%s\" targetname=\"%s\" response=\"%s\"\r\n", auth->realm, auth->target, ret); */
284 tmp = g_strdup_printf("NTLM qop=\"auth\" realm=\"%s\" targetname=\"%s\" response=\"010000003134303017f6dcfb4531f92f\"\r\n", auth->realm, auth->target);
284 g_free(ret); 285 g_free(ret);
285 return tmp; 286 return tmp;
286 } 287 }
287 288
288 sprintf(noncecount, "%08d", auth->nc++); 289 sprintf(noncecount, "%08d", auth->nc++);
292 return ret; 293 return ret;
293 } 294 }
294 295
295 static void fill_auth(struct simple_account_data *sip, gchar *hdr, struct sip_auth *auth) { 296 static void fill_auth(struct simple_account_data *sip, gchar *hdr, struct sip_auth *auth) {
296 int i=0; 297 int i=0;
298 char *tmp;
299 char *tmp2;
297 if(!hdr) { 300 if(!hdr) {
298 gaim_debug_error("simple", "fill_auth: hdr==NULL\n"); 301 gaim_debug_error("simple", "fill_auth: hdr==NULL\n");
299 return; 302 return;
300 } 303 }
301 304
302 if(!g_strncasecmp(hdr, "NTLM", 4)) { 305 if(!g_strncasecmp(hdr, "NTLM", 4)) {
303 gaim_debug_info("simple", "found NTLM\n"); 306 gaim_debug_info("simple", "found NTLM\n");
304 auth->type = 2; 307 auth->type = 2;
305 if(!auth->nonce && !auth->nc) { 308 if(!auth->nonce && !auth->nc) {
309 gchar **parts = g_strsplit(hdr, " ", 0);
310 while(parts[i]) {
311 if(!strncmp(parts[i],"targetname",10)) {
312 auth->target = g_strndup(parts[i]+12,strlen(parts[i]+12)-1);
313 }
314 if(!strncmp(parts[i],"realm",5)) {
315 tmp = strstr(hdr, "realm=");
316 tmp += 7;
317 tmp2 = strchr(tmp, '"');
318 *tmp2 = 0;
319 auth->realm = g_strdup(tmp);
320 *tmp2 = '"';
321 }
322 i++;
323 }
306 auth->nc = 1; 324 auth->nc = 1;
307 } 325 }
308 if(!auth->nonce && auth->nc==2) { 326 if(!auth->nonce && auth->nc==2) {
309 auth->nc = 3; 327 auth->nc = 3;
310 auth->nonce = gaim_ntlm_parse_type2(hdr+5); 328 auth->nonce = gaim_ntlm_parse_type2(hdr+5);