Changeset 1370


Ignore:
Timestamp:
Jun 18, 2007 11:01:42 AM (17 years ago)
Author:
bennylp
Message:

Fixed ticket #231: Add the ability to respond to any realms in SIP authentication

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip/sip_auth_client.c

    r1294 r1370  
    7070                               const pj_str_t *qop, 
    7171                               const pj_str_t *uri, 
     72                               const pj_str_t *realm, 
    7273                               const pjsip_cred_info *cred_info, 
    7374                               const pj_str_t *method) 
     
    8990        MD5_APPEND( &pms, cred_info->username.ptr, cred_info->username.slen); 
    9091        MD5_APPEND( &pms, ":", 1); 
    91         MD5_APPEND( &pms, cred_info->realm.ptr, cred_info->realm.slen); 
     92        MD5_APPEND( &pms, realm->ptr, realm->slen); 
    9293        MD5_APPEND( &pms, ":", 1); 
    9394        MD5_APPEND( &pms, cred_info->data.ptr, cred_info->data.slen); 
     
    222223        /* Convert digest to string and store in chal->response. */ 
    223224        pjsip_auth_create_digest( &cred->response, &cred->nonce, NULL, NULL,  
    224                                   NULL, uri, cred_info, method); 
     225                                  NULL, uri, &chal->realm, cred_info, method); 
    225226 
    226227    } else if (has_auth_qop(pool, &chal->qop)) { 
     
    240241 
    241242        pjsip_auth_create_digest( &cred->response, &cred->nonce, &cred->nc,  
    242                                   cnonce, &pjsip_AUTH_STR, uri, cred_info,  
    243                                   method ); 
     243                                  cnonce, &pjsip_AUTH_STR, uri, &chal->realm,  
     244                                  cred_info, method ); 
    244245 
    245246    } else { 
     
    329330{ 
    330331    unsigned i; 
     332    int wildcard = -1; 
     333 
    331334    PJ_UNUSED_ARG(auth_scheme); 
     335 
    332336    for (i=0; i<sess->cred_cnt; ++i) { 
    333337        if (pj_stricmp(&sess->cred_info[i].realm, realm) == 0) 
    334338            return &sess->cred_info[i]; 
    335     } 
     339        else if (sess->cred_info[i].realm.slen == 1 && 
     340                 sess->cred_info[i].realm.ptr[0] == '*') 
     341        { 
     342            wildcard = i; 
     343        } 
     344    } 
     345 
     346    /* No matching realm. See if we have credential with wildcard ('*') 
     347     * as the realm. 
     348     */ 
     349    if (wildcard != -1) 
     350        return &sess->cred_info[wildcard]; 
     351 
     352    /* Nothing is suitable */ 
    336353    return NULL; 
    337354} 
Note: See TracChangeset for help on using the changeset viewer.