#include "SIPParserInclude\CSIPAuthorizationParser.h"
#include "HHCoreInclude\CHHString.h"
namespace SIPParserFW
{
std::string CSIPAuthorizationParser::m_strSIPCredentialStringDelimiter = "," ;
std::string CSIPAuthorizationParser::m_strSIPCredentialNameAndValueDelimiter = "=" ;
CSIPAuthorizationParser::CSIPAuthorizationParser()
: m_pUserNameData( NULL ), m_pRealmData( NULL ), m_pNonceData( NULL ),
m_pURIData( NULL ), m_pResponseData( NULL ), m_pDigestData( NULL ),
m_pAlgorithmData( NULL ), m_pCNonceData( NULL ), m_pOpaqueData( NULL ),
m_pMessageQOPData( NULL ), m_pNonceCountData( NULL ), m_pSIPOtherCredentialParameters( NULL )
{
ReleaseCSIPAuthorizationParserData() ;
}
CSIPAuthorizationParser::CSIPAuthorizationParser( const CSIPAuthorizationParser &SIPAuthorizationParser )
: ASIPParser( SIPAuthorizationParser ), m_pUserNameData( NULL ), m_pRealmData( NULL ), m_pNonceData( NULL ),
m_pURIData( NULL ), m_pResponseData( NULL ), m_pDigestData( NULL ),
m_pAlgorithmData( NULL ), m_pCNonceData( NULL ), m_pOpaqueData( NULL ),
m_pMessageQOPData( NULL ), m_pNonceCountData( NULL ), m_pSIPOtherCredentialParameters( NULL )
{
ReleaseCSIPAuthorizationParserData() ;
CopyCSIPAuthorizationParserData( SIPAuthorizationParser ) ;
}
CSIPAuthorizationParser::~CSIPAuthorizationParser()
{
ReleaseCSIPAuthorizationParserData() ;
}
CSIPAuthorizationParser& CSIPAuthorizationParser::operator=( const CSIPAuthorizationParser &SIPAuthorizationParser )
{
ReleaseCSIPAuthorizationParserData() ;
ASIPParser::operator=( SIPAuthorizationParser ) ;
CopyCSIPAuthorizationParserData( SIPAuthorizationParser ) ;
return *this ;
}
void CSIPAuthorizationParser::ReleaseCSIPAuthorizationParserData()
{
m_strAuthorizationType.erase() ;
if( m_pUserNameData != NULL )
{
m_pUserNameData->Release() ;
m_pUserNameData = NULL ;
}
if( m_pRealmData != NULL )
{
m_pRealmData->Release() ;
m_pRealmData = NULL ;
}
if( m_pNonceData != NULL )
{
m_pNonceData->Release() ;
m_pNonceData = NULL ;
}
if( m_pURIData != NULL )
{
m_pURIData->Release() ;
m_pURIData = NULL ;
}
if( m_pResponseData != NULL )
{
m_pResponseData->Release() ;
m_pResponseData = NULL ;
}
if( m_pDigestData != NULL )
{
m_pDigestData->Release() ;
m_pDigestData = NULL ;
}
if( m_pAlgorithmData != NULL )
{
m_pAlgorithmData->Release() ;
m_pAlgorithmData = NULL ;
}
if( m_pCNonceData != NULL )
{
m_pCNonceData->Release() ;
m_pCNonceData = NULL ;
}
if( m_pOpaqueData != NULL )
{
m_pOpaqueData->Release() ;
m_pOpaqueData = NULL ;
}
if( m_pMessageQOPData != NULL )
{
m_pMessageQOPData->Release() ;
m_pMessageQOPData = NULL ;
}
if( m_pNonceCountData != NULL )
{
m_pNonceCountData->Release() ;
m_pNonceCountData = NULL ;
}
if( m_pSIPOtherCredentialParameters != NULL )
{
m_pSIPOtherCredentialParameters->Release() ;
m_pSIPOtherCredentialParameters = NULL ;
}
}
void CSIPAuthorizationParser::CopyCSIPAuthorizationParserData( const CSIPAuthorizationParser &SIPAuthorizationParser )
{
m_strAuthorizationType = SIPAuthorizationParser.m_strAuthorizationType ;
m_pUserNameData = ( ( SIPAuthorizationParser.m_pUserNameData != NULL )
? dynamic_cast< CMessageData* > ( SIPAuthorizationParser.m_pUserNameData->Copy() ) : NULL ) ;
m_pRealmData = ( ( SIPAuthorizationParser.m_pRealmData != NULL )
? dynamic_cast< CMessageData* > ( SIPAuthorizationParser.m_pRealmData->Copy() ) : NULL ) ;
m_pNonceData = ( ( SIPAuthorizationParser.m_pNonceData != NULL )
? dynamic_cast< CMessageData* > ( SIPAuthorizationParser.m_pNonceData->Copy() ) : NULL ) ;
m_pURIData = ( ( SIPAuthorizationParser.m_pURIData != NULL )
? dynamic_cast< CMessageData* > ( SIPAuthorizationParser.m_pURIData->Copy() ) : NULL ) ;
m_pResponseData = ( ( SIPAuthorizationParser.m_pResponseData != NULL )
? dynamic_cast< CMessageData* > ( SIPAuthorizationParser.m_pResponseData->Copy() ) : NULL ) ;
m_pDigestData = ( ( SIPAuthorizationParser.m_pDigestData != NULL )
? dynamic_cast< CMessageData* > ( SIPAuthorizationParser.m_pDigestData->Copy() ) : NULL ) ;
m_pAlgorithmData = ( ( SIPAuthorizationParser.m_pAlgorithmData != NULL )
? dynamic_cast< CMessageData* > ( SIPAuthorizationParser.m_pAlgorithmData->Copy() ) : NULL ) ;
m_pCNonceData = ( ( SIPAuthorizationParser.m_pCNonceData != NULL )
? dynamic_cast< CMessageData* > ( SIPAuthorizationParser.m_pCNonceData->Copy() ) : NULL ) ;
m_pOpaqueData = ( ( SIPAuthorizationParser.m_pOpaqueData != NULL )
? dynamic_cast< CMessageData* > ( SIPAuthorizationParser.m_pOpaqueData->Copy() ) : NULL ) ;
m_pMessageQOPData = ( ( SIPAuthorizationParser.m_pMessageQOPData != NULL )
? dynamic_cast< CMessageData* > ( SIPAuthorizationParser.m_pMessageQOPData->Copy() ) : NULL ) ;
m_pNonceCountData = ( ( SIPAuthorizationParser.m_pNonceCountData != NULL )
? dynamic_cast< CMessageData* > ( SIPAuthorizationParser.m_pNonceCountData->Copy() ) : NULL ) ;
m_pSIPOtherCredentialParameters = ( ( SIPAuthorizationParser.m_pSIPOtherCredentialParameters != NULL )
? dynamic_cast< CSIPParamListParser* > ( SIPAuthorizationParser.m_pSIPOtherCredentialParameters->Copy() ) : NULL ) ;
}
CSIPAuthorizationParser& CSIPAuthorizationParser::operator=( const CSIPWWWAuthenticateParser &SIPWWWAuthenticateParser )
{
ReleaseCSIPAuthorizationParserData() ;
ASIPParser::operator=( SIPWWWAuthenticateParser ) ;
CopyCSIPAuthorizationParserData( SIPWWWAuthenticateParser ) ;
return *this ;
}
void CSIPAuthorizationParser::CopyCSIPAuthorizationParserData( const CSIPWWWAuthenticateParser &SIPWWWAuthenticateParser )
{
m_strAuthorizationType = SIPWWWAuthenticateParser.m_strWWWAuthenticateType ;
m_pRealmData = ( ( SIPWWWAuthenticateParser.m_pRealmData != NULL )
? dynamic_cast< CMessageData* > ( SIPWWWAuthenticateParser.m_pRealmData->Copy() ) : NULL ) ;
m_pNonceData = ( ( SIPWWWAuthenticateParser.m_pNonceData != NULL )
? dynamic_cast< CMessageData* > ( SIPWWWAuthenticateParser.m_pNonceData->Copy() ) : NULL ) ;
m_pAlgorithmData = ( ( SIPWWWAuthenticateParser.m_pAlgorithmData != NULL )
? dynamic_cast< CMessageData* > ( SIPWWWAuthenticateParser.m_pAlgorithmData->Copy() ) : NULL ) ;
m_pOpaqueData = ( ( SIPWWWAuthenticateParser.m_pOpaqueData != NULL )
? dynamic_cast< CMessageData* > ( SIPWWWAuthenticateParser.m_pOpaqueData->Copy() ) : NULL ) ;
}
CSIPAuthorizationParser* CSIPAuthorizationParser::GetAvailable()
{
CSIPAuthorizationParser *pSIPAuthorizationParser = CPoolObject<CSIPAuthorizationParser>::GetAvailable() ;
return pSIPAuthorizationParser ;
}
void CSIPAuthorizationParser::Release()
{
ReleaseParameters() ;
CPoolObject<CSIPAuthorizationParser>::Release( this ) ;
}
void CSIPAuthorizationParser::ReleaseParameters()
{
ReleaseCSIPAuthorizationParserData() ;
ASIPParser::ReleaseParameters() ;
}
ASIPParser* CSIPAuthorizationParser::Copy()
{
CSIPAuthorizationParser *pSIPAuthorizationParser = CSIPAuthorizationParser::GetAvailable() ;
if( pSIPAuthorizationParser == NULL )
return NULL ;
*pSIPAuthorizationParser = *this ;
return pSIPAuthorizationParser ;
}
void CSIPAuthorizationParser::SetUserName( const std::string &strUserName )
{
if( m_pUserNameData == NULL )
m_pUserNameData = CMessageData::GetAvailable() ;
m_pUserNameData->SetData( strUserName.c_str(), strUserName.size() ) ;
}
std::string CSIPAuthorizationParser::GetUserName() const
{
if( m_pUserNameData == NULL )
return "" ;
return ( const char* ) m_pUserNameData->GetData() ;
}
void CSIPAuthorizationParser::SetRealm( const std::string &strRealm )
{
if( m_pRealmData == NULL )
m_pRealmData = CMessageData::GetAvailable() ;
m_pRealmData->SetData( strRealm.c_str(), strRealm.size() ) ;
}
std::string CSIPAuthorizationParser::GetRealm() const
{
if( m_pRealmData == NULL )
return "" ;
return ( const char* ) m_pRealmData->GetData() ;
}
void CSIPAuthorizationParser::SetNonce( const std::string &strNonce )
{
if( m_pNonceData == NULL )
m_pNonceData = CMessageData::GetAvailable() ;
m_pNonceData->SetData( strNonce.c_str(), strNonce.size() ) ;
}
std::string CSIPAuthorizationParser::GetNonce() const
{
if( m_pNonceData == NULL )
return "" ;
return ( const char* ) m_pNonceData->GetData() ;
}
void CSIPAuthorizationParser::SetURI( const std::string &strURI )
{
if( m_pURIData == NULL )
m_pURIData = CMessageData::GetAvailable() ;
m_pURIData->SetData( strURI.c_str(), strURI.size() ) ;
}
std::string CSIPAuthorizationParser::GetURI() const
{
if( m_pURIData == NULL )
return "" ;
return ( const char* ) m_pURIData->GetData() ;
}
void CSIPAuthorizationParser::SetResponse( const std::string &strResponse )
{
if( m_pResponseData == NULL )
m_pResponseData = CMessageData::GetAvailable() ;
m_pResponseData->SetData( strResponse.c_str(), strResponse.size() ) ;
}
std::string CSIPAuthorizationParser::GetResponse() const
{
if( m_pResponseData == NULL )
return "" ;
return ( const char* ) m_pResponseData->GetData() ;
}
void CSIPAuthorizationParser::SetDigest( const std::string &strDigest )
{
if( m_pDigestData == NULL )
m_pDigestData = CMessageData::GetAvailable() ;
m_pDigestData->SetData( strDigest.c_str(), strDigest.size() ) ;
}
std::string CSIPAuthorizationParser::GetDigest() const
{
if( m_pDigestData == NULL )
return "" ;
return ( const char* ) m_pDigestData->GetData() ;
}
void CSIPAuthorizationParser::SetAlgorithm( const std::string &strAlgorithm )
{
if( m_pAlgorithmData == NULL )
m_pAlgorithmData = CMessageData::GetAvailable() ;
m_pAlgorithmData->SetData( strAlgorithm.c_str(), strAlgorithm.size() ) ;
}
std::string CSIPAuthorizationParser::GetAlgorithm() const
{
if( m_pAlgorithmData == NULL )
return "" ;
return ( const char* ) m_pAlgorithmData->GetData() ;
}
void CSIPAuthorizationParser::SetCNonce( const std::string &strCNonce )
{
if( m_pCNonceData == NULL )
m_pCNonceData = CMessageData::GetAvailable() ;
m_pCNonceData->SetData( strCNonce.c_str(), strCNonce.size() ) ;
}
std::string CSIPAuthorizationParser::GetCNonce() const
{
if( m_pCNonceData == NULL )
return "" ;
return ( const char* ) m_pCNonceData->GetData() ;
}
void CSIPAuthorizationParser::SetOpaque( const std::string &strOpaque )
{
if( m_pOpaqueData == NULL )
m_pOpaqueData = CMessageData::GetAvailable() ;
m_pOpaqueData->SetData( strOpaque.c_str(), strOpaque.size() ) ;
}
std::string CSIPAuthorizationParser::GetOpaque() const
{
if( m_pOpaqueData == NULL )
return "" ;
return ( const char* ) m_pOpaqueData->GetData() ;
}
void CSIPAuthorizationParser::SetMessageQOP( const std::string &strMessageQOP )
{
if( m_pMessageQOPData == NULL )
m_pMessageQOPData = CMessageData::GetAvailable() ;
m_pMessageQOPData->SetData( strMessageQOP.c_str(), strMessageQOP.size() ) ;
}
std::string CSIPAuthorizationParser::GetMessageQOP() const
{
if( m_pMessageQOPData == NULL )
return "" ;
return ( const char* ) m_pMessageQOPData->GetData() ;
}
void CSIPAuthorizationParser::SetNonceCount( const std::string &strNonceCount )
{
if( m_pNonceCountData == NULL )
m_pNonceCountData = CMessageData::GetAvailable() ;
m_pNonceCountData->SetData( strNonceCount.c_str(), strNonceCount.size() ) ;
}
std::string CSIPAuthorizationParser::GetNonceCount() const
{
if( m_pNonceCountData == NULL )
return "" ;
return ( const char* ) m_pNonceCountData->GetData() ;
}
/* Grammer
Authorization = "Authorization" HCOLON credentials
credentials = ("Digest" LWS digest-response) / other-response
digest-response = dig-resp *(COMMA dig-resp)
dig-resp = username / realm / nonce / digest-uri / dresponse / algorithm / cnonce / opaque / message-qop / nonce-count / auth-param
username = "username" EQUAL username-value
username-value = quoted-string
realm = "realm" EQUAL realm-value
realm-value = quoted-string
nonce = "nonce" EQUAL nonce-value
nonce-value = quoted-string
digest-uri = "uri" EQUAL LDQUOT digest-uri-value RDQUOT
digest-uri-value = rquest-uri ; Equal to request-uri as specified by HTTP/1.1
dresponse = "response" EQUAL request-digest
request-digest = LDQUOT 32LHEX RDQUOT
algorithm = "algorithm" EQUAL ( "MD5" / "MD5-sess" / token )
cnonce = "cnonce" EQUAL cnonce-value
cnonce-value = nonce-value
opaque = "opaque" EQUAL quoted-string
message-qop = "qop" EQUAL qop-value
qop-value = "auth" / "auth-int" / token
nonce-count = "nc" EQUAL nc-value
nc-value = 8LHEX
auth-param = auth-param-name EQUAL ( token / quoted-string )
auth-param-name = token
other-response = auth-scheme LWS auth-param *(COMMA auth-param)
auth-scheme = token
*/
//Proxy-Authorization = "Proxy-Authorization" HCOLON credentials
// Please see RFC3261, Pages 165
// Please see RFC3261, Pages 196
// Please see RFC3261, Pages 197
// Please see RFC3261, Pages 199
// Please see RFC3261, Pages from 219 to 232 for ABNF forms
// Please see file ..\Document\SIPAuthorization Parsing Logic.txt for parsing algorithm
// Page 165:
//This header field, along with Proxy-Authorization, breaks the general
//rules about multiple header field values. Although not a commaseparated
//list, this header field name may be present multiple times,
//and MUST NOT be combined into a single header line using the usual
//rules described in Section 7.3.
// Page 196:
//When a UAC resubmits a request with its credentials after receiving a
//401 (Unauthorized) or 407 (Proxy Authentication Required) response,
//it MUST increment the CSeq header field value as it would normally
//when sending an updated request.
// Page 197:
//If a proxy were to resubmit a request adding a Proxy-Authorization
//header field value, it would need to increment the CSeq in the new
//request. However, this would cause the UAC that submitted the
//original request to discard a response from the UAS, as the CSeq
//value would be different.
//When the originating UAC receives the 407 (Proxy Authentication
//Required) it SHOULD, if it is able, re-originate the request with the
//proper credentials. It should follow the same procedures for the
//display of the "realm" parameter that are given above for responding
//to 401.
//If no credentials for a realm can be located, UACs MAY attempt to
//retry the request with a username of "anonymous" and no password (a
//password of "").
//The UAC SHOULD also cache the credentials used in the re-originated
//request.
// Page 199:
//This section describes the modifications and clarifications required
//to apply the HTTP Digest authentication scheme to SIP. The SIP
//scheme usage is almost completely identical to that for HTTP [17].
//Since RFC 2543 is based on HTTP Digest as defined in RFC 2069 [39],
//SIP servers supporting RFC 2617 MUST ensure they are backwards
//compatible with RFC 2069. Procedures for this backwards
//compatibility are specified in RFC 2617. Note, however, that SIP
//servers MUST NOT accept or request Basic authentication.
FW_RETURN_TYPE CSIPAuthorizationParser::Parse( const std::string &strStringToParse )
{
if( strStringToParse.empty() )
return SIP_PARSE_ERR_EMPTY_STRING_TO_PARSE ;
/* SEARCH FOR SPACE */
std::string::size_type iSpacePosition = strStringToParse.find( SIP_CONST_SPACE ) ;
if( iSpacePosition == std::string::npos )
{
return SIP_PARSE_ERR_INVALID_SIP_AUTHORIZATION ;
}
// Set Authorization Type
SetAuthorizationType( strStringToParse.substr( 0, iSpacePosition ) ) ;
return ParseSIPAuthorizationCredentialStringList( strStringToParse.substr( iSpacePosition + strlen( SIP_CONST_SPACE ) ) ) ;
}
FW_RETURN_TYPE CSIPAuthorizationParser::ParseSIPAuthorizationCredentialStringList( const std::string &strStringToParse )
{
if( strStringToParse.empty() )
return SIP_PARSE_ERR_EMPTY_STRING_TO_PARSE ;
char *strSIPCredentialStringToken = NULL ;
char *strNextSIPCredentialStringToken = NULL ;
int iSIPCredentialNameAndValueDelimiterSize = m_strSIPCredentialNameAndValueDelimiter.size() ;
std::string lstrStringToParse = strStringToParse ;
strSIPCredentialStringToken = strtok_s( ( char* ) lstrStringToParse.data(),
m_strSIPCredentialStringDelimiter.c_str(), &strNextSIPCredentialStringToken ) ;
while( strSIPCredentialStringToken != NULL )
{
std::string strSIPCredentialString( ( const char* ) strSIPCredentialStringToken ) ;
if( !strSIPCredentialString.empty() )
{
std::string::size_type iSIPCredentialNameAndValueDelimiterPosition =
strSIPCredentialString.find( m_strSIPCredentialNameAndValueDelimiter ) ;
std::string strCredentialName = strSIPCredentialString.substr( 0, iSIPCredentialNameAndValueDelimiterPosition ) ;
std::string strCredentialValue = strSIPCredentialString.substr( iSIPCredentialNameAndValueDelimiterPosition + iSIPCredentialNameAndValueDelimiterSize ) ;
strCredentialValue = ASIPParser::GetQuotedString( strCredentialValue,
m_strSIPCredentialStringDelimiter, &strNextSIPCredentialStringToken ) ;
/*if( strCredentialName.find( SIP_PARAM_USERNAME ) != std::string::npos )
SetUserName( strCredentialValue ) ;
else if( strCredentialName.find( SIP_PARAM_REALM ) != std::string::npos )
SetRealm( strCredentialValue ) ;
else if( strCredentialName.find( SIP_PARAM_NONCE ) != std::string::npos )
SetNonce( strCredentialValue ) ;
else if( strCredentialName.find( SIP_PARAM_URI ) != std::string::npos )
SetURI( strCredentialValue ) ;
else if( strCredentialName.find( SIP_PARAM_RESPONSE ) != std::string::npos )
SetResponse( strCredentialValue ) ;
else if( strCredentialName.find( SIP_PARAM_ALGORITHM ) != std::string::npos )
SetAlgorithm( strCredentialValue ) ;
else if( strCredentialName.find( SIP_PARAM_CNONCE ) != std::string::npos )
SetCNonce( strCredentialValue ) ;
else if( strCredentialName.find( SIP_PARAM_OPAQUE ) != std::string::npos )
SetOpaque( strCredentialValue ) ;
else if( strCredentialName.find( SIP_PARAM_QOP ) != std::string::npos )
SetMessageQOP( strCredentialValue ) ;
else if( strCredentialName.find( SIP_PARAM_NONCE_COUNT ) != std::string::npos )
SetNonceCount( strCredentialValue ) ;
else if( strCredentialName.find( SIP_PARAM_DIGEST ) != std::string::npos )
SetDigest( strCredentialValue ) ;
else
{
FW_RETURN_TYPE FWRetValue = SIP_ERR_SUCCESS ;
CSIPParamListParser *pSIPOtherCredentialParameters = NULL ;
if( ( FWRetValue = GetSIPOtherCredentialParameters( &pSIPOtherCredentialParameters ) ) != SIP_ERR_SUCCESS )
return FWRetValue ;
pSIPOtherCredentialParameters->AddParameter( strCredentialName, strCredentialValue ) ;
}*/
std::string strCredentialNameMayContainsSpaces = strCredentialName ;
CHHString::TrimAll( strCredentialName ) ;
if( strCredentialName == SIP_PARAM_USERNAME )
SetUserName( strCredentialValue ) ;
else if( strCredentialName == SIP_PARAM_REALM )
SetRealm( strCredentialValue ) ;
else if( strCredentialName == SIP_PARAM_NONCE )
SetNonce( strCredentialValue ) ;
else if( strCredentialName == SIP_PARAM_URI )
SetURI( strCredentialValue ) ;
else if( strCredentialName == SIP_PARAM_RESPONSE )
SetResponse( strCredentialValue ) ;
else if( strCredentialName == SIP_PARAM_ALGORITHM )
SetAlgorithm( strCredentialValue ) ;
else if( strCredentialName == SIP_PARAM_CNONCE )
SetCNonce( strCredentialValue ) ;
else if( strCredentialName == SIP_PARAM_OPAQUE )
SetOpaque( strCredentialValue ) ;
else if( strCredentialName == SIP_PARAM_QOP )
SetMessageQOP( strCredentialValue ) ;
else if( strCredentialName == SIP_PARAM_NONCE_COUNT )
SetNonceCount( strCredentialValue ) ;
else if( strCredentialName == SIP_PARAM_DIGEST )
SetDigest( strCredentialValue ) ;
else
{
FW_RETURN_TYPE FWRetValue = SIP_ERR_SUCCESS ;
CSIPParamListParser *pOtherSIPCredentialParameters = NULL ;
if( ( FWRetValue = QuerySIPOtherCredentialParameters( &pOtherSIPCredentialParameters ) ) != SIP_ERR_SUCCESS )
return FWRetValue ;
pOtherSIPCredentialParameters->AddParameter( strCredentialName, strCredentialValue ) ;
}
}
strSIPCredentialStringToken = strtok_s( NULL, m_strSIPCredentialStringDelimiter.c_str(),
&strNextSIPCredentialStringToken ) ;
}
return SIP_ERR_SUCCESS ;
}
FW_RETURN_TYPE CSIPAuthorizationParser::QuerySIPOtherCredentialParameters( CSIPParamListParser **pOtherSIPCredentialParameters )
{
*pOtherSIPCredentialParameters = NULL ;
if( m_pSIPOtherCredentialParameters == NULL )
{
m_pSIPOtherCredentialParameters = CSIPParamListParser::GetAvailable() ;
if( m_pSIPOtherCredentialParameters == NULL )
return SIP_PARSE_ERR_SIP_PARAM_LIST_PARSER_OBJECT_NOT_CREATED ;
m_pSIPOtherCredentialParameters->SetParametersDelimiter( m_strSIPCredentialStringDelimiter ) ;
m_pSIPOtherCredentialParameters->SetParamAndValueDelimiter( m_strSIPCredentialNameAndValueDelimiter ) ;
}
*pOtherSIPCredentialParameters = m_pSIPOtherCredentialParameters ;
return SIP_ERR_SUCCESS ;
}
std::string CSIPAuthorizationParser::SIPAuthorizationCredentialListToString() const
{
std::string strSIPCredentialListString = "" ;
std::string strUserName = "" ;
if( m_pUserNameData != NULL )
{
strUserName = SIP_PARAM_USERNAME + m_strSIPCredentialNameAndValueDelimiter + GetUserName() + m_strSIPCredentialStringDelimiter ;
}
std::string strRealm = "" ;
if( m_pRealmData != NULL )
{
strRealm = SIP_PARAM_REALM + m_strSIPCredentialNameAndValueDelimiter + GetRealm() + m_strSIPCredentialStringDelimiter ;
}
std::string strNonce = "" ;
if( m_pNonceData != NULL )
{
strNonce = SIP_PARAM_NONCE + m_strSIPCredentialNameAndValueDelimiter + GetNonce() + m_strSIPCredentialStringDelimiter ;
}
std::string strURI = "" ;
if( m_pURIData != NULL )
{
strURI = SIP_PARAM_URI + m_strSIPCredentialNameAndValueDelimiter + GetURI() + m_strSIPCredentialStringDelimiter ;
}
std::string strResponse = "" ;
if( m_pResponseData != NULL )
{
strResponse = SIP_PARAM_RESPONSE + m_strSIPCredentialNameAndValueDelimiter + GetResponse() + m_strSIPCredentialStringDelimiter ;
}
std::string strAlgorithm = "" ;
if( m_pAlgorithmData != NULL )
{
strAlgorithm = SIP_PARAM_ALGORITHM + m_strSIPCredentialNameAndValueDelimiter + GetAlgorithm() + m_strSIPCredentialStringDelimiter ;
}
std::string strCNonce = "" ;
if( m_pCNonceData != NULL )
{
strCNonce = SIP_PARAM_CNONCE + m_strSIPCredentialNameAndValueDelimiter + GetCNonce() + m_strSIPCredentialStringDelimiter ;
}
std::string strOpaque = "" ;
if( m_pOpaqueData != NULL )
{
strOpaque = SIP_PARAM_OPAQUE + m_strSIPCredentialNameAndValueDelimiter + GetOpaque() + m_strSIPCredentialStringDelimiter ;
}
std::string strMessageQOP = "" ;
if( m_pMessageQOPData != NULL )
{
strMessageQOP = SIP_PARAM_QOP + m_strSIPCredentialNameAndValueDelimiter + GetMessageQOP() + m_strSIPCredentialStringDelimiter ;
}
std::string strNonceCount = "" ;
if( m_pNonceCountData != NULL )
{
strNonceCount = SIP_PARAM_NONCE_COUNT + m_strSIPCredentialNameAndValueDelimiter + GetNonceCount() + m_strSIPCredentialStringDelimiter ;
}
std::string strDigest = "" ;
if( m_pDigestData != NULL )
{
strDigest = SIP_PARAM_DIGEST + m_strSIPCredentialNameAndValueDelimiter + GetDigest() + m_strSIPCredentialStringDelimiter ;
}
std::string strOtherAuthorizationCredentialsString = "" ;
if( m_pSIPOtherCredentialParameters != NULL )
{
strOtherAuthorizationCredentialsString = m_pSIPOtherCredentialParameters->ToString() + m_strSIPCredentialStringDelimiter ;
}
strSIPCredentialListString = strUserName + strRealm + strNonce + strURI + strResponse + strAlgorithm
+ strCNonce + strOpaque + strMessageQOP + strNonceCount + strDigest
+ strOtherAuthorizationCredentialsString ;
strSIPCredentialListString = strSIPCredentialListString.substr( 0,
( strSIPCredentialListString.size() - m_strSIPCredentialStringDelimiter.size() ) ) ;
return strSIPCredentialListString ;
}
std::string CSIPAuthorizationParser::ToString() const
{
std::string strSIPAuthorizationString = "" ;
strSIPAuthorizationString = m_strAuthorizationType + SIP_CONST_SPACE + SIPAuthorizationCredentialListToString() ;
return strSIPAuthorizationString ;
}
std::string CSIPAuthorizationParser::GetHeaderName() const
{
return GetRuntimeHeaderName( SIP_HEADER_AUTHORIZATION ) ;
}
} // End namespace