Mixe for Privacy and Anonymity in the Internet
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
CAXMLCostConfirmation Class Reference

this class corresponds to anon.pay.xml.XMLEasyCC in the Java implementation More...

#include <CAXMLCostConfirmation.hpp>

Collaboration diagram for CAXMLCostConfirmation:
[legend]

List of all members.

Public Member Functions

 ~CAXMLCostConfirmation ()
UINT32 getNumberOfHashes ()
SINT32 getPosition (UINT32 a_hashNumber)
UINT8getPriceCertHash (UINT32 a_hashNumber)
UINT8getMixId (UINT32 a_hashNumber)
UINT8dumpToMem (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 ()
UINT8getPIID ()
XERCES_CPP_NAMESPACE::DOMDocument * getXMLDocument ()

Static Public Member Functions

static CAXMLCostConfirmationgetInstance (UINT8 *strXmlData, UINT32 strXMlDataLen)
 Tries to create an CAXMLCostConfirmation object from the given XML string.
static CAXMLCostConfirmationgetInstance (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
UINT8m_pStrPIID
XERCES_CPP_NAMESPACE::DOMDocument * m_domDocument

Static Private Attributes

static const char *const ms_pStrElemName = "CC"

Detailed Description

this class corresponds to anon.pay.xml.XMLEasyCC in the Java implementation

Author:
Bastian Voigt

Definition at line 12 of file CAXMLCostConfirmation.hpp.


Constructor & Destructor Documentation

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;
    }
  }

Member Function Documentation

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;
      }

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);
        }

Definition at line 111 of file CAXMLCostConfirmation.hpp.

References m_id.

            {
          return m_id;
        }
CAXMLCostConfirmation * CAXMLCostConfirmation::getInstance ( UINT8 strXmlData,
UINT32  strXMlDataLen 
) [static]

Tries to create an CAXMLCostConfirmation object from the given XML string.

Return values:
NULLif the XML data was wrong
Returns:
a newly allocated CAXMLCostconfirmationObject

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;
  }

Here is the call graph for this function:

CAXMLCostConfirmation * CAXMLCostConfirmation::getInstance ( DOMElement *  elemRoot) [static]

Tries to create an CAXMLCostConfirmation object from the given XML string.

Return values:
NULLif the XML data was wrong
Returns:
a newly allocated CAXMLCostconfirmationObject

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;
  }

Here is the call graph for this function:

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();
      }

Here is the call graph for this function:

Returns:
a newly allocated buffer which must be deleted by the caller

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();
      }

Here is the call graph for this function:

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();
      }

Here is the call graph for this function:

XERCES_CPP_NAMESPACE::DOMDocument* CAXMLCostConfirmation::getXMLDocument ( ) [inline]
static const char* const CAXMLCostConfirmation::getXMLElementName ( ) [inline, static]

Definition at line 136 of file CAXMLCostConfirmation.hpp.

References ms_pStrElemName.

        {
          return ms_pStrElemName;
        }

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;
  }

Here is the call graph for this function:

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;
        }

Here is the call graph for this function:


Member Data Documentation

XERCES_CPP_NAMESPACE::DOMDocument* CAXMLCostConfirmation::m_domDocument [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().

const char *const CAXMLCostConfirmation::ms_pStrElemName = "CC" [static, private]

Definition at line 26 of file CAXMLCostConfirmation.hpp.

Referenced by getXMLElementName(), and setValues().


The documentation for this class was generated from the following files: