HP-UX C SIP Stack Programmer's Guide (Novembery 2007)
Authentication 193
Client Authentication Implementation
Sample Code
The following code sample demonstrates how to get the authentication objects
from a call-leg, and how to set the shared secret in each object.
/*=========================================================================*/
#define USERNAME "John"
#define PASSWORD "1234"
void AppSetSharedSecretInAllAuthObjects(
RvSipAuthenticatorHandle hAuthenticator,
RvSipCallLegHandle hCallLeg)
{
RvStatus rv;
RvSipAuthObjHandle hAuthObj = NULL;
/* Gets the first auth-obj from the call-leg. */
rv = RvSipCallLegAuthObjGet(hCallLeg, RVSIP_FIRST_ELEMENT,
NULL, &hAuthObj);
if(rv != RV_OK || hAuthObj == NULL)
{
printf("\nClient - no auth-obj in call-leg\n");
return;
}
while (rv == RV_OK && hAuthObj != NULL)
{
/* Sets the shared secret in the authentication object. */
rv = RvSipAuthObjSetUserInfo(hAuthenticator, hAuthObj,
USERNAME, PASSWORD);
/* Gets the next auth-obj from the call-leg. */
RvSipCallLegAuthObjGet(hCallLeg, RVSIP_NEXT_ELEMENT,
hAuthObj, &hAuthObj);
}
}
/*====================================================================================*/
AUTHENTICATING A
M
ESSAGE IN ADVANCE
The authenticator uses the Authentication header from the 407 response to
authenticate an outgoing request. The authenticator provides several API
functions that allow you to authenticate requests in advance. To authenticate
requests in advance, you should supply the authenticator with an Authentication
header with which to work.