|
Mixe for Privacy and Anonymity in the Internet
|
this class corresponds to anon.pay.xml.XMLEasyCC in the Java implementation More...
#include <CAXMLCostConfirmation.hpp>
Public Member Functions | |
| ~CAXMLCostConfirmation () | |
| UINT32 | getNumberOfHashes () |
| SINT32 | getPosition (UINT32 a_hashNumber) |
| UINT8 * | getPriceCertHash (UINT32 a_hashNumber) |
| UINT8 * | getMixId (UINT32 a_hashNumber) |
| UINT8 * | dumpToMem (UINT32 *pLen) |
| dumps the XML CC to memory without trailing '0'. | |
| SINT32 | toXMLString (UINT8 *buff, UINT32 *bufflen) |
| dumps the XML CC to a string (with trailing '0'). | |
| UINT64 | getTransferredBytes () |
| UINT64 | getAccountNumber () |
| UINT32 | getID () |
| UINT8 * | getPIID () |
| XERCES_CPP_NAMESPACE::DOMDocument * | getXMLDocument () |
Static Public Member Functions | |
| static CAXMLCostConfirmation * | getInstance (UINT8 *strXmlData, UINT32 strXMlDataLen) |
| Tries to create an CAXMLCostConfirmation object from the given XML string. | |
| static CAXMLCostConfirmation * | getInstance (DOMElement *elemRoot) |
| Tries to create an CAXMLCostConfirmation object from the given XML string. | |
| static const char *const | getXMLElementName () |
Private Member Functions | |
| SINT32 | setValues () |
| CAXMLCostConfirmation () | |
| SINT32 | checkLen (UINT32 a_hashNumber) |
Private Attributes | |
| UINT64 | m_lTransferredBytes |
| UINT64 | m_lAccountNumber |
| UINT32 | m_id |
| CAPriceInfo ** | m_priceCerts |
| UINT32 | m_priceCertsLen |
| UINT8 * | m_pStrPIID |
| XERCES_CPP_NAMESPACE::DOMDocument * | m_domDocument |
Static Private Attributes | |
| static const char *const | ms_pStrElemName = "CC" |
this class corresponds to anon.pay.xml.XMLEasyCC in the Java implementation
Definition at line 12 of file CAXMLCostConfirmation.hpp.
| CAXMLCostConfirmation::CAXMLCostConfirmation | ( | ) | [private] |
Definition at line 38 of file CAXMLCostConfirmation.cpp.
References m_domDocument, m_priceCerts, and m_pStrPIID.
Referenced by getInstance().
{
m_domDocument = NULL;
m_pStrPIID = NULL;
m_priceCerts = NULL;
}
Definition at line 78 of file CAXMLCostConfirmation.cpp.
References m_domDocument, m_priceCerts, m_priceCertsLen, and m_pStrPIID.
{
delete[] m_pStrPIID;
m_pStrPIID = NULL;
if (m_priceCerts != NULL)
{
for (UINT32 i = 0; i < m_priceCertsLen; i++)
{
if (m_priceCerts[i])
{
delete m_priceCerts[i];
m_priceCerts[i] = NULL;
}
}
delete[] m_priceCerts;
m_priceCerts = NULL;
}
if(m_domDocument != NULL)
{
m_domDocument->release();
m_domDocument=NULL;
}
}
| SINT32 CAXMLCostConfirmation::checkLen | ( | UINT32 | a_hashNumber | ) | [inline, private] |
Definition at line 28 of file CAXMLCostConfirmation.hpp.
References E_SUCCESS, E_UNKNOWN, and m_priceCertsLen.
Referenced by getMixId(), getPosition(), and getPriceCertHash().
{
if (a_hashNumber < 0 || a_hashNumber > m_priceCertsLen - 1)
{
return E_UNKNOWN;
}
return E_SUCCESS;
}
| UINT8* CAXMLCostConfirmation::dumpToMem | ( | UINT32 * | pLen | ) | [inline] |
dumps the XML CC to memory without trailing '0'.
Definition at line 84 of file CAXMLCostConfirmation.hpp.
References m_domDocument.
Referenced by CAAccountingBIInterface::settle().
{
if(m_domDocument==NULL)
return NULL;
return DOM_Output::dumpToMem(m_domDocument,pLen);
}
| UINT64 CAXMLCostConfirmation::getAccountNumber | ( | ) | [inline] |
Definition at line 105 of file CAXMLCostConfirmation.hpp.
References m_lAccountNumber.
Referenced by CAAccountingInstance::__handleSettleResult(), CAAccountingDBInterface::__storeCostConfirmation(), CAAccountingInstance::handleCostConfirmation_internal(), and CAAccountingInstance::settlementTransaction().
{
return m_lAccountNumber;
}
| UINT32 CAXMLCostConfirmation::getID | ( | ) | [inline] |
| CAXMLCostConfirmation * CAXMLCostConfirmation::getInstance | ( | UINT8 * | strXmlData, |
| UINT32 | strXMlDataLen | ||
| ) | [static] |
Tries to create an CAXMLCostConfirmation object from the given XML string.
| NULL | if the XML data was wrong |
Definition at line 46 of file CAXMLCostConfirmation.cpp.
References CAXMLCostConfirmation(), E_SUCCESS, m_domDocument, parseDOMDocument(), and setValues().
Referenced by CAAccountingDBInterface::__getCostConfirmation(), CAAccountingDBInterface::__getUnsettledCostConfirmations(), CAAccountingInstance::handleCostConfirmation_internal(), and CAXMLErrorMessage::setValues().
{
// parse XML
if(strXmlData==NULL)
return NULL;
CAXMLCostConfirmation* pCC=new CAXMLCostConfirmation();
pCC->m_domDocument = parseDOMDocument(strXmlData, strXmlDataLen);
if(pCC->setValues()!=E_SUCCESS)
{
delete pCC;
pCC = NULL;
}
return pCC;
}
| CAXMLCostConfirmation * CAXMLCostConfirmation::getInstance | ( | DOMElement * | elemRoot | ) | [static] |
Tries to create an CAXMLCostConfirmation object from the given XML string.
| NULL | if the XML data was wrong |
Definition at line 61 of file CAXMLCostConfirmation.cpp.
References CAXMLCostConfirmation(), createDOMDocument(), E_SUCCESS, m_domDocument, and setValues().
{
if(elemRoot==NULL)
return NULL;
CAXMLCostConfirmation* pCC=new CAXMLCostConfirmation();
pCC->m_domDocument=createDOMDocument();
pCC->m_domDocument->appendChild(pCC->m_domDocument->importNode(elemRoot,true));
if(pCC->setValues()!=E_SUCCESS)
{
delete pCC;
pCC = NULL;
}
return pCC;
}
| UINT8* CAXMLCostConfirmation::getMixId | ( | UINT32 | a_hashNumber | ) | [inline] |
Definition at line 74 of file CAXMLCostConfirmation.hpp.
References checkLen(), E_SUCCESS, CAPriceInfo::getMixId(), and m_priceCerts.
{
if (checkLen(a_hashNumber) != E_SUCCESS)
{
return NULL;
}
return m_priceCerts[a_hashNumber]->getMixId();
}
| UINT32 CAXMLCostConfirmation::getNumberOfHashes | ( | ) | [inline] |
Definition at line 50 of file CAXMLCostConfirmation.hpp.
References m_priceCertsLen.
Referenced by CAAccountingInstance::cascadeMatchesCC(), and CAAccountingInstance::handleCostConfirmation_internal().
{
return m_priceCertsLen;
}
| UINT8* CAXMLCostConfirmation::getPIID | ( | ) | [inline] |
Definition at line 125 of file CAXMLCostConfirmation.hpp.
References m_pStrPIID.
{
UINT8* pTmpStr = NULL;
if(m_pStrPIID!=NULL)
{
pTmpStr = new UINT8[strlen((char*)m_pStrPIID)+1];
strcpy((char*)pTmpStr, (char*)m_pStrPIID);
}
return pTmpStr;
}
| SINT32 CAXMLCostConfirmation::getPosition | ( | UINT32 | a_hashNumber | ) | [inline] |
Definition at line 55 of file CAXMLCostConfirmation.hpp.
References checkLen(), E_SUCCESS, E_UNKNOWN, CAPriceInfo::getPosition(), and m_priceCerts.
{
if (checkLen(a_hashNumber) != E_SUCCESS)
{
return E_UNKNOWN;
}
return m_priceCerts[a_hashNumber]->getPosition();
}
| UINT8* CAXMLCostConfirmation::getPriceCertHash | ( | UINT32 | a_hashNumber | ) | [inline] |
Definition at line 65 of file CAXMLCostConfirmation.hpp.
References checkLen(), E_SUCCESS, CAPriceInfo::getPriceCertHash(), and m_priceCerts.
Referenced by CAAccountingInstance::cascadeMatchesCC().
{
if (checkLen(a_hashNumber) != E_SUCCESS)
{
return NULL;
}
return m_priceCerts[a_hashNumber]->getPriceCertHash();
}
| UINT64 CAXMLCostConfirmation::getTransferredBytes | ( | ) | [inline] |
Definition at line 100 of file CAXMLCostConfirmation.hpp.
References m_lTransferredBytes.
Referenced by CAAccountingInstance::__handleSettleResult(), CAAccountingDBInterface::__storeCostConfirmation(), CAAccountingInstance::handleChallengeResponse_internal(), CAAccountingInstance::handleCostConfirmation_internal(), and CAAccountingInstance::settlementTransaction().
{
return m_lTransferredBytes;
}
| XERCES_CPP_NAMESPACE::DOMDocument* CAXMLCostConfirmation::getXMLDocument | ( | ) | [inline] |
Definition at line 141 of file CAXMLCostConfirmation.hpp.
References m_domDocument.
Referenced by CAAccountingInstance::handleChallengeResponse_internal(), CAAccountingInstance::handleJapPacket_internal(), CAAccountingInstance::makeInitialCCRequest(), and CAAccountingBIInterface::settleAll().
{
return m_domDocument;
}
| static const char* const CAXMLCostConfirmation::getXMLElementName | ( | ) | [inline, static] |
Definition at line 136 of file CAXMLCostConfirmation.hpp.
References ms_pStrElemName.
{
return ms_pStrElemName;
}
| SINT32 CAXMLCostConfirmation::setValues | ( | ) | [private] |
we do not use the price cert hashes for anything in the AI except storing them as part of the xml string in the db
if you need them, make sure the destructor deletes them (and initialize certArray with new(), otherwise it, and m_priceCerts with it, will be gone by the end of this method!!!)
Definition at line 106 of file CAXMLCostConfirmation.cpp.
References E_SUCCESS, E_UNKNOWN, equals(), getDOMChildByName(), getDOMElementAttribute(), getDOMElementValue(), getElementsByTagName(), len, m_domDocument, m_lAccountNumber, m_lTransferredBytes, m_priceCerts, m_priceCertsLen, m_pStrPIID, and ms_pStrElemName.
Referenced by getInstance().
{
if(m_domDocument==NULL)
return E_UNKNOWN;
DOMElement* elemRoot=m_domDocument->getDocumentElement();
if (elemRoot == NULL)
{
return E_UNKNOWN;
}
DOMElement* elem=NULL;
if( !equals(elemRoot->getTagName(),ms_pStrElemName) )
{
return E_UNKNOWN;
}
// parse accountnumber
getDOMChildByName(elemRoot, "AccountNumber", elem, false);
if(getDOMElementValue(elem, m_lAccountNumber)!=E_SUCCESS)
return E_UNKNOWN;
// parse transferredBytes
getDOMChildByName(elemRoot, "TransferredBytes", elem, false);
if(getDOMElementValue(elem, m_lTransferredBytes)!=E_SUCCESS)
return E_UNKNOWN;
// parse PIID
delete[] m_pStrPIID;
m_pStrPIID=NULL;
UINT8 strGeneral[256];
UINT32 strGeneralLen = 256;
strGeneralLen=255;
getDOMChildByName(elemRoot, "PIID", elem, false);
if(getDOMElementValue(elem, strGeneral, &strGeneralLen)==E_SUCCESS)
{
m_pStrPIID = new UINT8[strGeneralLen+1];
memcpy(m_pStrPIID, strGeneral,strGeneralLen+1);
}
else
{
return E_UNKNOWN;
}
//CAMsg::printMsg(LOG_DEBUG, "Parsing PriceCertificates\n");
//parse PriceCertHash elements
//currently does not check syntax, e.g. whether <PriceCertHash> is within <PriceCertificates>
if (getDOMChildByName(elemRoot, "PriceCertificates", elem, false) != E_SUCCESS)
{
return E_UNKNOWN;
}
//CAMsg::printMsg(LOG_DEBUG, "Looking for PriceCertHash\n");
// one last test if the tag is really in the right XML layer; throw away elemRoot here...
if (getDOMChildByName(elem, "PriceCertHash", elemRoot, false) != E_SUCCESS)
{
return E_UNKNOWN;
}
//CAMsg::printMsg(LOG_DEBUG, "Parsing PriceCertHash\n");
DOMNodeList* theNodes = getElementsByTagName(elem,"PriceCertHash");
if (theNodes->getLength() <= 0)
{
return E_UNKNOWN;
}
//determine size and build array
m_priceCertsLen = theNodes->getLength();
m_priceCerts = new CAPriceInfo*[m_priceCertsLen];
//loop through nodes
const DOMNode* curNode=NULL;
UINT8* curId;
UINT8* curHash;
UINT32 len;
SINT32 curPosition;
for (UINT32 i = 0; i < m_priceCertsLen; i++ )
{
m_priceCerts[i] = NULL;
}
for (UINT32 i = 0; i < m_priceCertsLen; i++ )
{
//get single node
curNode = theNodes->item(i);
//CAMsg::printMsg(LOG_DEBUG, "Parsing id\n");
//extract strings for mixid and pricecerthash, and check isAI attribute
curId = new UINT8[100];
len = 100;
if (getDOMElementAttribute(curNode, "id", curId, &len) != E_SUCCESS)
{
delete[] curId;
curId = NULL;
return E_UNKNOWN;
}
//CAMsg::printMsg(LOG_DEBUG, "Parsing hash\n");
curHash = new UINT8[100];
len = 100;
if (getDOMElementValue(curNode, curHash, &len) != E_SUCCESS)
{
delete[] curId;
curId = NULL;
delete[] curHash;
curHash = NULL;
return E_UNKNOWN;
}
//CAMsg::printMsg(LOG_DEBUG, "Parsing position\n");
if (getDOMElementAttribute(curNode, "position", &curPosition) != E_SUCCESS)
{
curPosition = -1;
}
//CAMsg::printMsg(LOG_DEBUG, "Adding cert info\n");
m_priceCerts[i] = new CAPriceInfo(curId, curHash, curPosition);
}
return E_SUCCESS;
}
| SINT32 CAXMLCostConfirmation::toXMLString | ( | UINT8 * | buff, |
| UINT32 * | bufflen | ||
| ) | [inline] |
dumps the XML CC to a string (with trailing '0').
Definition at line 92 of file CAXMLCostConfirmation.hpp.
References DOM_Output::dumpToMem(), E_SUCCESS, E_UNKNOWN, and m_domDocument.
Referenced by CAAccountingDBInterface::__storeCostConfirmation().
{
if(DOM_Output::dumpToMem(m_domDocument,buff,bufflen)!=E_SUCCESS)
return E_UNKNOWN;
buff[*bufflen]=0;
return E_SUCCESS;
}
XERCES_CPP_NAMESPACE::DOMDocument* CAXMLCostConfirmation::m_domDocument [private] |
Definition at line 25 of file CAXMLCostConfirmation.hpp.
Referenced by CAXMLCostConfirmation(), dumpToMem(), getInstance(), getXMLDocument(), setValues(), toXMLString(), and ~CAXMLCostConfirmation().
UINT32 CAXMLCostConfirmation::m_id [private] |
Definition at line 21 of file CAXMLCostConfirmation.hpp.
Referenced by getID().
Definition at line 20 of file CAXMLCostConfirmation.hpp.
Referenced by getAccountNumber(), and setValues().
Definition at line 19 of file CAXMLCostConfirmation.hpp.
Referenced by getTransferredBytes(), and setValues().
CAPriceInfo** CAXMLCostConfirmation::m_priceCerts [private] |
Definition at line 22 of file CAXMLCostConfirmation.hpp.
Referenced by CAXMLCostConfirmation(), getMixId(), getPosition(), getPriceCertHash(), setValues(), and ~CAXMLCostConfirmation().
UINT32 CAXMLCostConfirmation::m_priceCertsLen [private] |
Definition at line 23 of file CAXMLCostConfirmation.hpp.
Referenced by checkLen(), getNumberOfHashes(), setValues(), and ~CAXMLCostConfirmation().
UINT8* CAXMLCostConfirmation::m_pStrPIID [private] |
Definition at line 24 of file CAXMLCostConfirmation.hpp.
Referenced by CAXMLCostConfirmation(), getPIID(), setValues(), and ~CAXMLCostConfirmation().
const char *const CAXMLCostConfirmation::ms_pStrElemName = "CC" [static, private] |
Definition at line 26 of file CAXMLCostConfirmation.hpp.
Referenced by getXMLElementName(), and setValues().
1.7.6.1