HP-UX C SIP Stack Programmer's Guide (Novembery 2007)

Authentication 209
Server Authentication Implementation
Sample Code
The following code demonstrates the usage of the authenticator functions for
server authentication.
/*=========================================================================================*/
RvStatus AuthenticateCredentials(
IN Transaction* pTransc,
IN RvSipAuthorizationHeaderHandle hAuthorization,
IN RvChar *password,
OUT RvBool* isCorrect)
{
RvStatus stat;
RvBool bIsSupported;
/*----------------------------------------------------------------------------------------
Validity Checking. Will the authenticator be able to verify this Authorization header?
--------------------------------------------------------------------------------------*/
stat = RvSipAuthenticatorCredentialsSupported(
pTransc->pMgr->hAuthenticator,
hAuthorization,
&bIsSupported);
if(bIsSupported != RV_TRUE)
{
printf("given credentials are invalid. cannot authenticate it\n");
return RV_ERROR_UNKNOWN;
}
/*----------------------------------------------------------------------------------------
Authorization header verification. The authenticator will use the given header and
password.
---------------------------------------------------------------------------------------*/
stat = RvSipAuthenticatorVerifyCredentials(
pTransc->pMgr->hAuthenticator,
hAuthorization,
password,
makeStrMethod(pTransc),
isCorrect);
if(*isCorrect == RV_TRUE)
{
printf("credentials were verified successfully! user authenticity was proved");
}