Changes due to continue development effort.
This commit is contained in:
@@ -60,7 +60,7 @@ typedef struct _AuthRespParse
|
||||
{
|
||||
XML_Parser p;
|
||||
int state;
|
||||
int tokenDataProcessed;
|
||||
int elementDataProcessed;
|
||||
AuthenticateResp *pAuthenticateResp;
|
||||
CasaStatus status;
|
||||
|
||||
@@ -85,7 +85,7 @@ BuildAuthenticateMsg(
|
||||
//
|
||||
// Notes:
|
||||
//
|
||||
// L0
|
||||
// L2
|
||||
//=======================================================================--
|
||||
{
|
||||
char *pMsg = NULL;
|
||||
@@ -184,7 +184,7 @@ AuthRespStartElementHandler(
|
||||
//
|
||||
// Notes:
|
||||
//
|
||||
// L0
|
||||
// L2
|
||||
//=======================================================================--
|
||||
{
|
||||
DbgTrace(2, "-AuthRespStartElementHandler- Start\n", 0);
|
||||
@@ -278,6 +278,95 @@ AuthRespStartElementHandler(
|
||||
}
|
||||
|
||||
|
||||
//++=======================================================================
|
||||
static
|
||||
CasaStatus
|
||||
ConsumeElementData(
|
||||
IN AuthRespParse *pAuthRespParse,
|
||||
IN const XML_Char *s,
|
||||
IN int len,
|
||||
INOUT char **ppElementData,
|
||||
INOUT int *pElementDataLen)
|
||||
//
|
||||
// Arguments:
|
||||
//
|
||||
// Returns:
|
||||
//
|
||||
// Abstract:
|
||||
//
|
||||
// Notes:
|
||||
//
|
||||
// L2
|
||||
//=======================================================================--
|
||||
{
|
||||
CasaStatus retStatus = CASA_STATUS_SUCCESS;
|
||||
|
||||
DbgTrace(3, "-ConsumeElementData- Start\n", 0);
|
||||
|
||||
// Proceed based on whether or not we have already consumed data
|
||||
// for this element.
|
||||
if (*ppElementData == NULL)
|
||||
{
|
||||
// We have not yet consumed data for this element
|
||||
pAuthRespParse->elementDataProcessed = len;
|
||||
|
||||
// Allocate a buffer to hold this element data (null terminated).
|
||||
*ppElementData = (char*) malloc(len + 1);
|
||||
if (*ppElementData)
|
||||
{
|
||||
memset(*ppElementData, 0, len + 1);
|
||||
memcpy(*ppElementData, s, len);
|
||||
|
||||
// Return the length of the element data buffer
|
||||
*pElementDataLen = pAuthRespParse->elementDataProcessed + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgTrace(0, "-ConsumeElementData- Buffer allocation failure\n", 0);
|
||||
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
|
||||
CASA_FACILITY_AUTHTOKEN,
|
||||
CASA_STATUS_INSUFFICIENT_RESOURCES);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char *pNewBuf;
|
||||
|
||||
// We have already received token data, append this data to it.
|
||||
pNewBuf = (char*) malloc(pAuthRespParse->elementDataProcessed + len + 1);
|
||||
if (pNewBuf)
|
||||
{
|
||||
memset(pNewBuf,
|
||||
0,
|
||||
pAuthRespParse->elementDataProcessed + len + 1);
|
||||
memcpy(pNewBuf,
|
||||
*ppElementData,
|
||||
pAuthRespParse->elementDataProcessed);
|
||||
memcpy(pNewBuf + pAuthRespParse->elementDataProcessed, s, len);
|
||||
pAuthRespParse->elementDataProcessed += len;
|
||||
|
||||
// Swap the buffers
|
||||
free(*ppElementData);
|
||||
*ppElementData = pNewBuf;
|
||||
|
||||
// Return the length of the element data buffer
|
||||
*pElementDataLen = pAuthRespParse->elementDataProcessed + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgTrace(0, "-ConsumeElementData- Buffer allocation failure\n", 0);
|
||||
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
|
||||
CASA_FACILITY_AUTHTOKEN,
|
||||
CASA_STATUS_INSUFFICIENT_RESOURCES);
|
||||
}
|
||||
}
|
||||
|
||||
DbgTrace(3, "-ConsumeElementData- End, retStatus = %08X\n", retStatus);
|
||||
|
||||
return retStatus;
|
||||
}
|
||||
|
||||
|
||||
//++=======================================================================
|
||||
static
|
||||
void XMLCALL
|
||||
@@ -294,7 +383,7 @@ AuthRespCharDataHandler(
|
||||
//
|
||||
// Notes:
|
||||
//
|
||||
// L0
|
||||
// L2
|
||||
//=======================================================================--
|
||||
{
|
||||
DbgTrace(2, "-AuthRespCharDataHandler- Start\n", 0);
|
||||
@@ -310,8 +399,10 @@ AuthRespCharDataHandler(
|
||||
switch (pAuthRespParse->state)
|
||||
{
|
||||
case AWAITING_DESCRIPTION_DATA:
|
||||
case AWAITING_DESCRIPTION_ELEMENT_END:
|
||||
|
||||
// Ignore the status description data for now.
|
||||
// tbd
|
||||
|
||||
// Advanced to the next state
|
||||
pAuthRespParse->state = AWAITING_DESCRIPTION_ELEMENT_END;
|
||||
@@ -361,58 +452,20 @@ AuthRespCharDataHandler(
|
||||
case AWAITING_SESSION_TOKEN_DATA:
|
||||
case AWAITING_SESSION_TOKEN_ELEMENT_END:
|
||||
|
||||
// Check if we have already processed token data
|
||||
if (pAuthRespParse->tokenDataProcessed == 0)
|
||||
// Consume the data
|
||||
pAuthRespParse->status = ConsumeElementData(pAuthRespParse,
|
||||
s,
|
||||
len,
|
||||
&pAuthRespParse->pAuthenticateResp->pToken,
|
||||
&pAuthRespParse->pAuthenticateResp->tokenLen);
|
||||
if (CASA_SUCCESS(pAuthRespParse->status))
|
||||
{
|
||||
// Keep a copy of the session token (null terminated)
|
||||
pAuthRespParse->pAuthenticateResp->pToken = (char*) malloc(len + 1);
|
||||
if (pAuthRespParse->pAuthenticateResp->pToken)
|
||||
{
|
||||
memset(pAuthRespParse->pAuthenticateResp->pToken, 0, len + 1);
|
||||
memcpy(pAuthRespParse->pAuthenticateResp->pToken, s, len);
|
||||
pAuthRespParse->tokenDataProcessed = len;
|
||||
|
||||
// Advanced to the next state
|
||||
pAuthRespParse->state = AWAITING_SESSION_TOKEN_ELEMENT_END;
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgTrace(0, "-AuthRespCharDataHandler- Buffer allocation failure\n", 0);
|
||||
pAuthRespParse->status = CasaStatusBuild(CASA_SEVERITY_ERROR,
|
||||
CASA_FACILITY_AUTHTOKEN,
|
||||
CASA_STATUS_INSUFFICIENT_RESOURCES);
|
||||
XML_StopParser(pAuthRespParse->p, XML_FALSE);
|
||||
}
|
||||
// Advanced to the next state
|
||||
pAuthRespParse->state = AWAITING_SESSION_TOKEN_ELEMENT_END;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *pNewBuf;
|
||||
|
||||
// We have already received token data, append this data to it.
|
||||
pNewBuf = (char*) malloc(pAuthRespParse->tokenDataProcessed + len + 1);
|
||||
if (pNewBuf)
|
||||
{
|
||||
memset(pNewBuf,
|
||||
0,
|
||||
pAuthRespParse->tokenDataProcessed + len + 1);
|
||||
memcpy(pNewBuf,
|
||||
pAuthRespParse->pAuthenticateResp->pToken,
|
||||
pAuthRespParse->tokenDataProcessed);
|
||||
memcpy(pNewBuf + pAuthRespParse->tokenDataProcessed, s, len);
|
||||
pAuthRespParse->tokenDataProcessed += len;
|
||||
|
||||
// Swap the buffers
|
||||
free(pAuthRespParse->pAuthenticateResp->pToken);
|
||||
pAuthRespParse->pAuthenticateResp->pToken = pNewBuf;
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgTrace(0, "-AuthRespCharDataHandler- Buffer allocation failure\n", 0);
|
||||
pAuthRespParse->status = CasaStatusBuild(CASA_SEVERITY_ERROR,
|
||||
CASA_FACILITY_AUTHTOKEN,
|
||||
CASA_STATUS_INSUFFICIENT_RESOURCES);
|
||||
XML_StopParser(pAuthRespParse->p, XML_FALSE);
|
||||
}
|
||||
XML_StopParser(pAuthRespParse->p, XML_FALSE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -443,7 +496,7 @@ AuthRespEndElementHandler(
|
||||
//
|
||||
// Notes:
|
||||
//
|
||||
// L0
|
||||
// L2
|
||||
//=======================================================================--
|
||||
{
|
||||
DbgTrace(2, "-AuthRespEndElementHandler- Start\n", 0);
|
||||
@@ -560,7 +613,7 @@ CreateAuthenticateResp(
|
||||
//
|
||||
// Notes:
|
||||
//
|
||||
// L0
|
||||
// L2
|
||||
//=======================================================================--
|
||||
{
|
||||
CasaStatus retStatus = CASA_STATUS_SUCCESS;
|
||||
@@ -580,7 +633,7 @@ CreateAuthenticateResp(
|
||||
* </auth_resp>
|
||||
*
|
||||
* When an authentication request fails to be successfully processed, the server
|
||||
* responds with an error and a error description string. The message format of
|
||||
* responds with an error and an error description string. The message format of
|
||||
* an unsuccessful reply is as follows:
|
||||
*
|
||||
* <?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
@@ -709,7 +762,7 @@ RelAuthenticateResp(
|
||||
//
|
||||
// Notes:
|
||||
//
|
||||
// L0
|
||||
// L2
|
||||
//=======================================================================--
|
||||
{
|
||||
DbgTrace(1, "-RelAuthenticateResp- Start\n", 0);
|
||||
@@ -723,3 +776,8 @@ RelAuthenticateResp(
|
||||
DbgTrace(1, "-RelAuthenticateResp- End\n", 0);
|
||||
}
|
||||
|
||||
|
||||
//++=======================================================================
|
||||
//++=======================================================================
|
||||
//++=======================================================================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user