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

Representation of a Price Certificate corresponds to anon.pay.xml.XMLPriceCertificate in the Java implementation Constructor is private, use the getInstance methods. More...

#include <CAXMLPriceCert.hpp>

Inheritance diagram for CAXMLPriceCert:
[legend]
Collaboration diagram for CAXMLPriceCert:
[legend]

List of all members.

Public Member Functions

 ~CAXMLPriceCert ()
SINT32 toXmlElement (XERCES_CPP_NAMESPACE::DOMDocument *a_doc, DOMElement *&elemRoot)
 Creates the XML structure inside an existing DOM_Document, but does not append it to any node.
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').
UINT8getSubjectKeyIdentifier ()
double getRate ()
UINT8getSignatureTime ()
UINT8getBiID ()
XERCES_CPP_NAMESPACE::DOMDocument * getXMLDocument ()

Static Public Member Functions

static CAXMLPriceCertgetInstance (const UINT8 *strXmlData, UINT32 strXMLDataLength)
 Tries to create a CAXMLPriceCert object from the given XML string.
static CAXMLPriceCertgetInstance (DOMElement *elemRoot)
static const char *const getXMLElementName ()

Private Member Functions

 CAXMLPriceCert ()
SINT32 setValues ()

Private Attributes

UINT8m_StrSubjectKeyIdentifier
double m_lRate
UINT8m_StrSignatureTime
UINT8m_StrBiID
DOMElement * m_signature
XERCES_CPP_NAMESPACE::DOMDocument * m_domDocument

Static Private Attributes

static const char *const ms_pStrElemName = "PriceCertificate"

Detailed Description

Representation of a Price Certificate corresponds to anon.pay.xml.XMLPriceCertificate in the Java implementation Constructor is private, use the getInstance methods.

Author:
Elmar Schraml

Definition at line 41 of file CAXMLPriceCert.hpp.


Constructor & Destructor Documentation

Definition at line 45 of file CAXMLPriceCert.cpp.

References m_domDocument, m_StrBiID, m_StrSignatureTime, and m_StrSubjectKeyIdentifier.

  {
    delete[] m_StrSubjectKeyIdentifier;
    m_StrSubjectKeyIdentifier = NULL;
    
    delete[] m_StrSignatureTime;
    m_StrSignatureTime = NULL;
    
    delete[] m_StrBiID;
    m_StrBiID = NULL;
    
    if(m_domDocument != NULL)
    {
      //CAMsg::printMsg(LOG_DEBUG, "cleaning up internal PriceCert document 0x%x.\n",
      //          m_domDocument);
      m_domDocument->release();
      m_domDocument=NULL; 
    }   
  }

Definition at line 37 of file CAXMLPriceCert.cpp.

References m_domDocument, m_StrBiID, m_StrSignatureTime, and m_StrSubjectKeyIdentifier.

Referenced by getInstance().


Member Function Documentation

UINT8* CAXMLPriceCert::dumpToMem ( UINT32 pLen) [inline]

dumps the XML CC to memory without trailing '0'.

Definition at line 56 of file CAXMLPriceCert.hpp.

References m_domDocument.

      {
        if(m_domDocument==NULL)
          return NULL;
        return DOM_Output::dumpToMem(m_domDocument,pLen);
      }
Returns:
a newly allocated buffer which must be deleted by the caller retval NULL if BiID was not set

Definition at line 109 of file CAXMLPriceCert.hpp.

References m_StrBiID.

    {
      UINT8* pTmpStr = NULL;
      if(m_StrBiID!=NULL)
        {
          pTmpStr = new UINT8[strlen((char*)m_StrBiID)+1];
          strcpy((char*)pTmpStr, (char*)m_StrBiID);
        }
      return pTmpStr; 
    }
CAXMLPriceCert * CAXMLPriceCert::getInstance ( const UINT8 strXmlData,
UINT32  strXMLDataLength 
) [static]

Tries to create a CAXMLPriceCert object from the given XML string.

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

Definition at line 65 of file CAXMLPriceCert.cpp.

References CAXMLPriceCert(), E_SUCCESS, m_domDocument, parseDOMDocument(), and setValues().

Referenced by CACmdLnOptions::setPriceCertificate().

{
  // parse XML
  if(strXmlData==NULL)
    return NULL;
  CAXMLPriceCert* pPC=new CAXMLPriceCert();
  pPC->m_domDocument = parseDOMDocument(strXmlData, strXmlDataLen);
  if(pPC->setValues()!=E_SUCCESS)
    {
      delete pPC;
      pPC = NULL;
    }
  return pPC; 
}

Here is the call graph for this function:

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

Definition at line 80 of file CAXMLPriceCert.cpp.

References CAXMLPriceCert(), createDOMDocument(), E_SUCCESS, m_domDocument, CAMsg::printMsg(), and setValues().

  {
    if(elemRoot==NULL)
      {
        CAMsg::printMsg(LOG_DEBUG,"CAXMLPriceCert::getInstance: root element is null\n");
        return NULL;
      } 
    CAXMLPriceCert* pPC=new CAXMLPriceCert();
    pPC->m_domDocument=createDOMDocument();
    pPC->m_domDocument->appendChild(pPC->m_domDocument->importNode(elemRoot,true));
    if(pPC->setValues()!=E_SUCCESS)
      {
        delete pPC;
        pPC = NULL;
        CAMsg::printMsg(LOG_DEBUG,"CAXMLPriceCert::getInstance.setValues() FAILED \n");
      }
    return pPC; 
  }

Here is the call graph for this function:

double CAXMLPriceCert::getRate ( ) [inline]

Definition at line 87 of file CAXMLPriceCert.hpp.

References m_lRate.

    {
      return m_lRate;
    }
Returns:
a newly allocated buffer which must be deleted by the caller retval NULL if creation time was not set

Definition at line 95 of file CAXMLPriceCert.hpp.

References m_StrSignatureTime.

    {
      UINT8* pTmpStr = NULL;
      if(m_StrSignatureTime!=NULL)
        {
          pTmpStr = new UINT8[strlen((char*)m_StrSignatureTime)+1];
          strcpy((char*)pTmpStr, (char*)m_StrSignatureTime);
        }
      return pTmpStr;       
    }
Returns:
a newly allocated buffer which must be deleted by the caller retval NULL if hash of mix cert was not set

Definition at line 75 of file CAXMLPriceCert.hpp.

References m_StrSubjectKeyIdentifier.

Referenced by CACmdLnOptions::setPriceCertificate().

    {
      UINT8* pTmpStr = NULL;
      if(m_StrSubjectKeyIdentifier!=NULL)
        {
          pTmpStr = new UINT8[strlen((char*)m_StrSubjectKeyIdentifier)+1];
          strcpy((char*)pTmpStr, (char*)m_StrSubjectKeyIdentifier);
        }
      return pTmpStr; 
      
    } 
XERCES_CPP_NAMESPACE::DOMDocument* CAXMLPriceCert::getXMLDocument ( ) [inline]

Definition at line 125 of file CAXMLPriceCert.hpp.

References m_domDocument.

    {
      return m_domDocument;
    }
static const char* const CAXMLPriceCert::getXMLElementName ( ) [inline, static]

Definition at line 120 of file CAXMLPriceCert.hpp.

References ms_pStrElemName.

    {
      return ms_pStrElemName;
    }

Definition at line 133 of file CAXMLPriceCert.cpp.

References E_SUCCESS, E_UNKNOWN, equals(), getDOMChildByName(), getDOMElementValue(), m_domDocument, m_lRate, m_signature, m_StrBiID, m_StrSignatureTime, m_StrSubjectKeyIdentifier, ms_pStrElemName, and CAMsg::printMsg().

Referenced by getInstance().

{
  CAMsg::printMsg(LOG_DEBUG,"Parsing price certificate.\n");

  if(m_domDocument==NULL)
  {
    CAMsg::printMsg(LOG_CRIT,"Price certificate is no valid document!\n");
    return E_UNKNOWN;
  }
  DOMElement* elemRoot=m_domDocument->getDocumentElement();
  DOMElement* elem=NULL;
  
  if(!equals(elemRoot->getTagName(),ms_pStrElemName))
    {
      CAMsg::printMsg(LOG_CRIT,"Failed to get root elem tagname of price certificate!\n");
      return E_UNKNOWN;
    }
  //TODO: parsing Strings could be generalized instead of copy-and-paste code for each element
  UINT8 strGeneral[512];
  UINT32 strGeneralLen = 512;
  // parse subjectkeyidentifier(UINT8*)
  delete[] m_StrSubjectKeyIdentifier;
  m_StrSubjectKeyIdentifier=NULL;

  getDOMChildByName(elemRoot, "SubjectKeyIdentifier", elem, false);
  if(getDOMElementValue(elem, strGeneral, &strGeneralLen)==E_SUCCESS)
    {
      m_StrSubjectKeyIdentifier = new UINT8[strGeneralLen+1];
      memcpy(m_StrSubjectKeyIdentifier, strGeneral,strGeneralLen+1);
      //CAMsg::printMsg(LOG_DEBUG,"setValues(): parsing subjectkeyidentifier OK\n");
    }
  else
    {
      delete[] m_StrSubjectKeyIdentifier;
      m_StrSubjectKeyIdentifier=NULL;
      CAMsg::printMsg(LOG_CRIT,"Failed to parse subjectkeyidentifier of price certificate!\n");
      return E_UNKNOWN;
    }
  
  // parse rate (double)
  getDOMChildByName(elemRoot, "Rate", elem, false);
  if(getDOMElementValue(elem, &m_lRate)!=E_SUCCESS)
  {
    CAMsg::printMsg(LOG_CRIT,"Could not parse rate of price certificate!\n");
    return E_UNKNOWN;
  }
  



  // parse creation time (UINT8*)
  delete[] m_StrSignatureTime;
  m_StrSignatureTime=NULL;
  getDOMChildByName(elemRoot, "SignatureTime", elem, false);
  
  if(getDOMElementValue(elem, strGeneral, &strGeneralLen)==E_SUCCESS)
    {
      m_StrSignatureTime = new UINT8[strGeneralLen+1];
      memcpy(m_StrSignatureTime, strGeneral,strGeneralLen+1);
    }
  else
    {
      delete[] m_StrSignatureTime;
      m_StrSignatureTime=NULL;
      CAMsg::printMsg(LOG_CRIT,"Could not parse SignatureTime of price certificate!\n");
      return E_UNKNOWN;
    }
  
  UINT8 strGeneral2[512];
  UINT32 strGeneralLen2 = 512;  
  
  // parse BiID (UINT8*)
  delete[] m_StrBiID;
  m_StrBiID=NULL;
  getDOMChildByName(elemRoot, "BiID", elem, false);
  if(getDOMElementValue(elem, strGeneral2, &strGeneralLen2)==E_SUCCESS)
    {
      m_StrBiID = new UINT8[strGeneralLen2+1];
      memcpy(m_StrBiID, strGeneral2,strGeneralLen2+1);
    }
  else
    {
      delete[] m_StrBiID;
      m_StrBiID=NULL;
      CAMsg::printMsg(LOG_CRIT,"Could not parse parse BiID of price certificate!\n");
      return E_UNKNOWN;
    }
    
    
  //if present, store signature node as element 
  getDOMChildByName(elemRoot, "Signature", m_signature, true);
  //returns E_UNKNOWN if no signature node present, right now we dont care 
  
  
  
    
  
  //CAMsg::printMsg(LOG_DEBUG,"setValues(): finished\n");
  return E_SUCCESS;
}

Here is the call graph for this function:

SINT32 CAXMLPriceCert::toXmlElement ( XERCES_CPP_NAMESPACE::DOMDocument *  a_pDoc,
DOMElement *&  pElemRoot 
) [virtual]

Creates the XML structure inside an existing DOM_Document, but does not append it to any node.

Parameters:
a_docan existing DOM_Document
elemRooton return contains the root element of the created XML structure. Note that the element is not appended to any node in the document

Implements CAAbstractXMLEncodable.

Definition at line 99 of file CAXMLPriceCert.cpp.

References createDOMElement(), E_SUCCESS, m_lRate, m_signature, m_StrBiID, m_StrSignatureTime, m_StrSubjectKeyIdentifier, CAMsg::printMsg(), setDOMElementAttribute(), and setDOMElementValue().

  {
    elemRoot = createDOMElement(a_doc,"PriceCertificate");
  
    setDOMElementAttribute(elemRoot,"version",(UINT8*)"1.1"); 

    DOMElement* elemHashOfMixCert = createDOMElement(a_doc,"SubjectKeyIdentifier");
    setDOMElementValue(elemHashOfMixCert,m_StrSubjectKeyIdentifier);
    elemRoot->appendChild(elemHashOfMixCert);
  
    DOMElement* elemRate = createDOMElement(a_doc,"Rate");
    setDOMElementValue(elemRate,m_lRate);
    elemRoot->appendChild(elemRate);
  
    DOMElement* elemCreationTime = createDOMElement(a_doc,"SignatureTime");
    setDOMElementValue(elemCreationTime,m_StrSignatureTime);
    elemRoot->appendChild(elemCreationTime);
  
    DOMElement* elemBiID = createDOMElement(a_doc,"BiID");
    setDOMElementValue(elemBiID,m_StrBiID);
    elemRoot->appendChild(elemBiID);
  
    //append signature node
    if (m_signature != NULL)
    {     
      elemRoot->appendChild(a_doc->importNode(m_signature,true));
    }
    else
      {
        CAMsg::printMsg(LOG_DEBUG,"Could not import PI signature node!\n");
      }
    return E_SUCCESS;
  }

Here is the call graph for this function:

SINT32 CAXMLPriceCert::toXMLString ( UINT8 buff,
UINT32 bufflen 
) [inline]

dumps the XML CC to a string (with trailing '0').

Definition at line 64 of file CAXMLPriceCert.hpp.

References DOM_Output::dumpToMem(), E_SUCCESS, E_UNKNOWN, and m_domDocument.

      {
        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* CAXMLPriceCert::m_domDocument [private]
double CAXMLPriceCert::m_lRate [private]

Definition at line 138 of file CAXMLPriceCert.hpp.

Referenced by getRate(), setValues(), and toXmlElement().

DOMElement* CAXMLPriceCert::m_signature [private]

Definition at line 141 of file CAXMLPriceCert.hpp.

Referenced by setValues(), and toXmlElement().

Definition at line 140 of file CAXMLPriceCert.hpp.

Referenced by CAXMLPriceCert(), getBiID(), setValues(), toXmlElement(), and ~CAXMLPriceCert().

const char *const CAXMLPriceCert::ms_pStrElemName = "PriceCertificate" [static, private]

Definition at line 143 of file CAXMLPriceCert.hpp.

Referenced by getXMLElementName(), and setValues().


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