Ignore:
Timestamp:
Sep 7, 2018 2:56:38 AM (6 years ago)
Author:
ming
Message:

Fixed #2148: Add parsing support for the OAuth 2.0 authentication mechanism

Thanks to Joshua Colp for the patch submission.

File:
1 edited

Legend:

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

    r5809 r5883  
    104104} 
    105105 
     106static int print_oauth_credential(pjsip_oauth_credential *cred, char *buf, 
     107                                  pj_size_t size) 
     108{ 
     109    pj_ssize_t printed; 
     110    char *startbuf = buf; 
     111    char *endbuf = buf + size; 
     112 
     113    copy_advance_pair_quote_cond_always(buf, "token=", 6, cred->token, 
     114                                        '"', '"'); 
     115    copy_advance_pair_quote_cond_always(buf, ", username=", 11, cred->username, 
     116                                        '"', '"'); 
     117    copy_advance_pair_quote_cond_always(buf, ", realm=", 8, cred->realm, 
     118                                        '"', '"'); 
     119 
     120    return (int) (buf-startbuf); 
     121} 
     122 
    106123static int pjsip_authorization_hdr_print( pjsip_authorization_hdr *hdr, 
    107124                                          char *buf, pj_size_t size) 
     
    126143        printed = print_pgp_credential(&hdr->credential.pgp, buf, endbuf - buf); 
    127144    }  
     145    else if (pj_stricmp(&hdr->scheme, &pjsip_BEARER_STR) == 0) 
     146    { 
     147        printed = print_oauth_credential(&hdr->credential.oauth, buf, 
     148                                         endbuf - buf); 
     149    } 
    128150    else { 
    129151        pj_assert(0); 
Note: See TracChangeset for help on using the changeset viewer.