|
Mixe for Privacy and Anonymity in the Internet
|
This class encapsulates an error or success message. More...
#include <CAXMLErrorMessage.hpp>
Public Member Functions | |
| CAXMLErrorMessage (const UINT32 errorCode, UINT8 *message) | |
| Creates an errorMessage object. | |
| CAXMLErrorMessage (UINT32 errorCode) | |
| Uses a default description String. | |
| CAXMLErrorMessage (const UINT32 errorCode, UINT8 *message, CAAbstractXMLEncodable *messageObject) | |
| attaches an object to the error message | |
| CAXMLErrorMessage (UINT8 *strXmlData) | |
| Parses the string XML representation. | |
| CAXMLErrorMessage (DOMElement *elemRoot) | |
| ~CAXMLErrorMessage () | |
| 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. | |
| UINT32 | getErrorCode () |
| UINT8 * | getDescription () |
| void * | getMessageObject () |
Static Public Attributes | |
| static const UINT32 | ERR_OK = 0 |
| static const UINT32 | ERR_INTERNAL_SERVER_ERROR = 1 |
| static const UINT32 | ERR_WRONG_FORMAT = 2 |
| static const UINT32 | ERR_WRONG_DATA = 3 |
| static const UINT32 | ERR_KEY_NOT_FOUND = 4 |
| static const UINT32 | ERR_BAD_SIGNATURE = 5 |
| static const UINT32 | ERR_BAD_REQUEST = 6 |
| static const UINT32 | ERR_NO_ACCOUNTCERT = 7 |
| static const UINT32 | ERR_NO_BALANCE = 8 |
| static const UINT32 | ERR_NO_CONFIRMATION = 9 |
| static const UINT32 | ERR_ACCOUNT_EMPTY = 10 |
| static const UINT32 | ERR_CASCADE_LENGTH = 11 |
| static const UINT32 | ERR_DATABASE_ERROR = 12 |
| static const UINT32 | ERR_INSUFFICIENT_BALANCE = 13 |
| static const UINT32 | ERR_NO_FLATRATE_OFFERED = 14 |
| static const UINT32 | ERR_INVALID_CODE = 15 |
| static const UINT32 | ERR_OUTDATED_CC = 16 |
| static const UINT32 | ERR_INVALID_PRICE_CERT = 17 |
| static const UINT32 | ERR_MULTIPLE_LOGIN = 18 |
| static const UINT32 | ERR_NO_RECORD_FOUND = 19 |
| static const UINT32 | ERR_SUCCESS_BUT_WITH_ERRORS = 20 |
| static const UINT32 | ERR_BLOCKED = 21 |
| static const UINT32 | ERR_NO_ERROR_GIVEN = 100 |
Private Member Functions | |
| SINT32 | setValues (DOMElement *elemRoot) |
Private Attributes | |
| UINT32 | m_iErrorCode |
| UINT8 * | m_strErrMsg |
| void * | m_messageObject |
This class encapsulates an error or success message.
In order to be independent from the HTTP protocol on the higher layer, this is now used instead of http errorcodes.
Definition at line 44 of file CAXMLErrorMessage.hpp.
| CAXMLErrorMessage::CAXMLErrorMessage | ( | const UINT32 | errorCode, |
| UINT8 * | message | ||
| ) |
Creates an errorMessage object.
The errorcode should be one of the above ERR_* constants.
| errorCode | UINT32 one of the above constants |
| message | String a human-readable description of the error |
Definition at line 33 of file CAXMLErrorMessage.cpp.
References m_iErrorCode, m_messageObject, and m_strErrMsg.
: CAAbstractXMLEncodable() { m_iErrorCode = errorCode; m_strErrMsg = new UINT8[strlen((char *)message)+1]; strcpy((char *)m_strErrMsg, (char *)message); m_messageObject = NULL; }
| CAXMLErrorMessage::CAXMLErrorMessage | ( | UINT32 | errorCode | ) |
Uses a default description String.
| errorCode | UINT32 |
Definition at line 44 of file CAXMLErrorMessage.cpp.
References m_iErrorCode, m_messageObject, and m_strErrMsg.
: CAAbstractXMLEncodable() { UINT8 *errors[] = { (UINT8*)"Success", (UINT8*)"Internal Server Error", (UINT8*)"Wrong format", (UINT8*)"Wrong Data", (UINT8*)"Key not found", (UINT8*)"Bad Signature", (UINT8*)"Bad request", (UINT8*)"You refused to send an account certificate. I will close the connection.", (UINT8*)"You refused to send a current balance. I will close the connection.", (UINT8*)"You refused to send a cost confirmation. I will close the connection.", (UINT8*)"Your account is empty.", (UINT8*)"Cascade is too long", (UINT8*)"Database error", (UINT8*)"Insufficient balance", (UINT8*)"No flatrate offered", (UINT8*)"Invalid code", (UINT8*)"Costconfirmation is not valid, possible attempt at doublespending!", (UINT8*)"One or more price certificates are invalid!", (UINT8*)"User is logged in more than once!", (UINT8*)"No database record for this cost confirmation was found!", (UINT8*)"Operation may have succeded, but this is not clear!", (UINT8*)"Account is blocked!" }; m_iErrorCode = errorCode; if (m_iErrorCode < 0 || m_iErrorCode >= 19) { UINT8 defaultMsg[] = "Unknown Error"; m_strErrMsg = new UINT8[strlen((char *)defaultMsg)+1]; strcpy((char *)m_strErrMsg, (char *)defaultMsg); } else { m_strErrMsg = new UINT8[strlen((char *)errors[errorCode])+1]; strcpy((char *)m_strErrMsg, (char *)errors[errorCode]); } m_messageObject = NULL; }
| CAXMLErrorMessage::CAXMLErrorMessage | ( | const UINT32 | errorCode, |
| UINT8 * | message, | ||
| CAAbstractXMLEncodable * | messageObject | ||
| ) |
attaches an object to the error message
Definition at line 88 of file CAXMLErrorMessage.cpp.
References m_iErrorCode, m_messageObject, and m_strErrMsg.
{
m_iErrorCode = errorCode;
m_strErrMsg = new UINT8[strlen((char *)message)+1];
strcpy((char *)m_strErrMsg, (char *)message);
m_messageObject = messageObject;
}
| CAXMLErrorMessage::CAXMLErrorMessage | ( | UINT8 * | strXmlData | ) |
Parses the string XML representation.
Definition at line 116 of file CAXMLErrorMessage.cpp.
References E_SUCCESS, ERR_NO_ERROR_GIVEN, m_iErrorCode, m_messageObject, m_strErrMsg, parseDOMDocument(), and setValues().
: CAAbstractXMLEncodable() { m_strErrMsg=NULL; m_messageObject = NULL; XERCES_CPP_NAMESPACE::DOMDocument* doc = parseDOMDocument(strXmlData,strlen((char*)strXmlData)); if(doc != NULL) { DOMElement* elemRoot = doc->getDocumentElement(); if (setValues(elemRoot) != E_SUCCESS) { m_iErrorCode = ERR_NO_ERROR_GIVEN; } if(doc != NULL) { doc->release(); doc = NULL; } } else { m_iErrorCode = ERR_NO_ERROR_GIVEN; } }
| CAXMLErrorMessage::CAXMLErrorMessage | ( | DOMElement * | elemRoot | ) |
Definition at line 97 of file CAXMLErrorMessage.cpp.
References E_SUCCESS, ERR_NO_ERROR_GIVEN, m_iErrorCode, m_messageObject, m_strErrMsg, and setValues().
: CAAbstractXMLEncodable() { m_strErrMsg=NULL; m_messageObject = NULL; if(elemRoot != NULL) { if (setValues(elemRoot) != E_SUCCESS) { m_iErrorCode = ERR_NO_ERROR_GIVEN; } } else { m_iErrorCode = ERR_NO_ERROR_GIVEN; } }
Definition at line 219 of file CAXMLErrorMessage.cpp.
References m_messageObject, and m_strErrMsg.
{
if(m_strErrMsg)
{
delete [] m_strErrMsg;
m_strErrMsg = NULL;
}
if (m_messageObject != NULL)
{
delete m_messageObject;
m_messageObject = NULL;
}
}
| UINT8* CAXMLErrorMessage::getDescription | ( | ) | [inline] |
Definition at line 109 of file CAXMLErrorMessage.hpp.
References m_strErrMsg.
Referenced by CAAccountingInstance::__handleSettleResult(), and CAAccountingInstance::settlementTransaction().
{
return m_strErrMsg;
}
| UINT32 CAXMLErrorMessage::getErrorCode | ( | ) | [inline] |
Definition at line 104 of file CAXMLErrorMessage.hpp.
References m_iErrorCode.
Referenced by CAAccountingInstance::__handleSettleResult(), and CAAccountingInstance::settlementTransaction().
{
return m_iErrorCode;
}
| void* CAXMLErrorMessage::getMessageObject | ( | ) | [inline] |
Definition at line 114 of file CAXMLErrorMessage.hpp.
References m_messageObject.
Referenced by CAAccountingInstance::__handleSettleResult(), and CAAccountingInstance::settlementTransaction().
{
return m_messageObject;
}
| SINT32 CAXMLErrorMessage::setValues | ( | DOMElement * | elemRoot | ) | [private] |
Definition at line 144 of file CAXMLErrorMessage.cpp.
References DOM_Output::dumpToMem(), DOM_Output::dumpToString(), E_SUCCESS, ERR_ACCOUNT_EMPTY, ERR_OUTDATED_CC, getDOMChildByName(), getDOMElementAttribute(), getDOMElementValue(), CAXMLCostConfirmation::getInstance(), len, m_iErrorCode, m_messageObject, m_strErrMsg, and CAMsg::printMsg().
Referenced by CAXMLErrorMessage().
{
UINT8 strGeneral[256];
UINT32 strGeneralLen = 256;
SINT32 tmp;
SINT32 rc;
if( ((rc=getDOMElementAttribute(elemRoot, "code", &tmp)) !=E_SUCCESS) ||
((rc=getDOMElementValue(elemRoot, strGeneral, &strGeneralLen)) !=E_SUCCESS)
)
{
UINT8 buff[8192];
UINT32 len=8192;
DOM_Output::dumpToMem(elemRoot,buff,&len);
CAMsg::printMsg(LOG_DEBUG,(char*)buff);
return rc;
}
m_iErrorCode = (UINT32)tmp;
delete [] m_strErrMsg;
m_strErrMsg = NULL;
m_strErrMsg = new UINT8[strGeneralLen+1];
strcpy((char*)m_strErrMsg, (char*)strGeneral);
/*if((rc=getDOMElementAttribute(elemRoot, "expires", (UINT8*) strExp, &strExpLen)) ==E_SUCCESS)
{
if(m_strExpires != NULL)
{
strncpy(m_strExpires, strExp, 10);
}
}*/
DOMElement* objectRootElem=NULL;
getDOMChildByName(elemRoot, "MessageObject", objectRootElem, false);
//due to lack of RTTI, we need to hardcode how to deal with each specific object type
if (ERR_OUTDATED_CC == m_iErrorCode)
{
DOMElement* ccElem=NULL;
if (getDOMChildByName(objectRootElem,"CC",ccElem,true) == E_SUCCESS)
{
m_messageObject = CAXMLCostConfirmation::getInstance(ccElem);
}
}
else if (ERR_ACCOUNT_EMPTY == m_iErrorCode)
{
if (objectRootElem != NULL)
{
CAMsg::printMsg(LOG_INFO, "XMLErrorMessage: appended object found...\n");
UINT8* buff = DOM_Output::dumpToString(objectRootElem, true);
CAMsg::printMsg(LOG_DEBUG,(char*)buff);
delete[] buff;
}
DOMElement* confirmedElem=NULL;
if (getDOMChildByName(objectRootElem,"GenericText",confirmedElem,true) == E_SUCCESS)
{
m_messageObject = new UINT64;
if(getDOMElementValue(confirmedElem, (*(UINT64*)m_messageObject)) != E_SUCCESS)
{
delete (UINT64*)m_messageObject;
m_messageObject = NULL;
}
}
}
else
{
m_messageObject = NULL;
}
//add code to parse other types of objects here when adding new error codes with corresponding objects
return E_SUCCESS;
}
| SINT32 CAXMLErrorMessage::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.
| a_doc | an existing DOM_Document |
| elemRoot | on 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 234 of file CAXMLErrorMessage.cpp.
References createDOMElement(), E_SUCCESS, m_iErrorCode, m_messageObject, m_strErrMsg, setDOMElementAttribute(), setDOMElementValue(), CAAbstractXMLEncodable::toXmlElement(), and XML_ELEMENT_ERROR_MSG.
{
elemRoot = createDOMElement(a_doc, XML_ELEMENT_ERROR_MSG);
setDOMElementAttribute(elemRoot, "code", m_iErrorCode);
/*if(m_strExpires != NULL)
{
if(m_strExpires[0] != 0)
{
setDOMElementAttribute(elemRoot, "expires", (UINT8*)m_strExpires);
}
}*/
setDOMElementValue(elemRoot, m_strErrMsg);
if (m_messageObject)
{
DOMElement* objectRoot = createDOMElement(a_doc,"MessageObject");
DOMElement* objectElem=NULL;
//WARNING: this will fail for CAXMLCostConfirmation!!! (since it is not a subclass of CAAbstractXMLEncodable)
CAAbstractXMLEncodable* encodableObject = (CAAbstractXMLEncodable*) m_messageObject;
encodableObject->toXmlElement(a_doc,objectElem);
objectRoot->appendChild(objectElem);
elemRoot->appendChild(objectRoot);
}
return E_SUCCESS;
}
const UINT32 CAXMLErrorMessage::ERR_ACCOUNT_EMPTY = 10 [static] |
Definition at line 58 of file CAXMLErrorMessage.hpp.
Referenced by CAAccountingInstance::__commitSettlementToDatabase(), CAAccountingInstance::__handleSettleResult(), CAAccountingInstance::finishLoginProcess(), CAAccountingInstance::handleChallengeResponse_internal(), CAAccountingInstance::handleJapPacket_internal(), CAAccountingInstance::settlementTransaction(), and setValues().
const UINT32 CAXMLErrorMessage::ERR_BAD_REQUEST = 6 [static] |
Definition at line 54 of file CAXMLErrorMessage.hpp.
Referenced by CAAccountingInstance::handleAccountCertificate_internal(), and CAAccountingInstance::handleCostConfirmation_internal().
const UINT32 CAXMLErrorMessage::ERR_BAD_SIGNATURE = 5 [static] |
Definition at line 53 of file CAXMLErrorMessage.hpp.
Referenced by CAAccountingInstance::handleAccountCertificate_internal(), CAAccountingInstance::handleChallengeResponse_internal(), and CAAccountingInstance::handleCostConfirmation_internal().
const UINT32 CAXMLErrorMessage::ERR_BLOCKED = 21 [static] |
Definition at line 69 of file CAXMLErrorMessage.hpp.
Referenced by CAAccountingInstance::__commitSettlementToDatabase(), CAAccountingInstance::__handleSettleResult(), CAAccountingInstance::finishLoginProcess(), CAAccountingInstance::handleChallengeResponse_internal(), CAAccountingInstance::handleJapPacket_internal(), and CAAccountingInstance::settlementTransaction().
const UINT32 CAXMLErrorMessage::ERR_CASCADE_LENGTH = 11 [static] |
Definition at line 59 of file CAXMLErrorMessage.hpp.
const UINT32 CAXMLErrorMessage::ERR_DATABASE_ERROR = 12 [static] |
Definition at line 60 of file CAXMLErrorMessage.hpp.
Referenced by CAAccountingInstance::__handleSettleResult(), CAAccountingInstance::handleJapPacket_internal(), and CAAccountingInstance::settlementTransaction().
const UINT32 CAXMLErrorMessage::ERR_INSUFFICIENT_BALANCE = 13 [static] |
Definition at line 61 of file CAXMLErrorMessage.hpp.
const UINT32 CAXMLErrorMessage::ERR_INTERNAL_SERVER_ERROR = 1 [static] |
Definition at line 49 of file CAXMLErrorMessage.hpp.
Referenced by CAAccountingInstance::__handleSettleResult(), CAAccountingInstance::handleAccountCertificate_internal(), CAAccountingInstance::handleChallengeResponse_internal(), CAAccountingInstance::handleCostConfirmation_internal(), CAAccountingInstance::handleJapPacket_internal(), CAAccountingInstance::processJapMessageLoginHelper(), CAAccountingBIInterface::settleAll(), and CAAccountingInstance::settlementTransaction().
const UINT32 CAXMLErrorMessage::ERR_INVALID_CODE = 15 [static] |
Definition at line 63 of file CAXMLErrorMessage.hpp.
const UINT32 CAXMLErrorMessage::ERR_INVALID_PRICE_CERT = 17 [static] |
Definition at line 65 of file CAXMLErrorMessage.hpp.
const UINT32 CAXMLErrorMessage::ERR_KEY_NOT_FOUND = 4 [static] |
Definition at line 52 of file CAXMLErrorMessage.hpp.
Referenced by CAAccountingInstance::__commitSettlementToDatabase(), CAAccountingInstance::__handleSettleResult(), CAAccountingInstance::handleAccountCertificate_internal(), CAAccountingInstance::handleChallengeResponse_internal(), CAAccountingInstance::handleJapPacket_internal(), and CAAccountingInstance::settlementTransaction().
const UINT32 CAXMLErrorMessage::ERR_MULTIPLE_LOGIN = 18 [static] |
Definition at line 66 of file CAXMLErrorMessage.hpp.
Referenced by CAAccountingInstance::handleChallengeResponse_internal(), CAAccountingInstance::handleJapPacket_internal(), and CAAccountingInstance::processJapMessageLoginHelper().
const UINT32 CAXMLErrorMessage::ERR_NO_ACCOUNTCERT = 7 [static] |
Definition at line 55 of file CAXMLErrorMessage.hpp.
const UINT32 CAXMLErrorMessage::ERR_NO_BALANCE = 8 [static] |
Definition at line 56 of file CAXMLErrorMessage.hpp.
Referenced by CAAccountingInstance::finishLoginProcess().
const UINT32 CAXMLErrorMessage::ERR_NO_CONFIRMATION = 9 [static] |
Definition at line 57 of file CAXMLErrorMessage.hpp.
Referenced by CAAccountingInstance::handleJapPacket_internal().
const UINT32 CAXMLErrorMessage::ERR_NO_ERROR_GIVEN = 100 [static] |
Definition at line 70 of file CAXMLErrorMessage.hpp.
Referenced by CAXMLErrorMessage(), CAAccountingInstance::finishLoginProcess(), CAAccountingInstance::handleAccountCertificate_internal(), CAAccountingInstance::handleChallengeResponse_internal(), and CAAccountingInstance::handleCostConfirmation_internal().
const UINT32 CAXMLErrorMessage::ERR_NO_FLATRATE_OFFERED = 14 [static] |
Definition at line 62 of file CAXMLErrorMessage.hpp.
const UINT32 CAXMLErrorMessage::ERR_NO_RECORD_FOUND = 19 [static] |
Definition at line 67 of file CAXMLErrorMessage.hpp.
Referenced by CAAccountingInstance::handleAccountCertificate_internal(), CAAccountingInstance::handleChallengeResponse_internal(), and CAAccountingInstance::handleCostConfirmation_internal().
const UINT32 CAXMLErrorMessage::ERR_OK = 0 [static] |
Definition at line 48 of file CAXMLErrorMessage.hpp.
Referenced by CAAccountingDBInterface::__getAccountStatus(), CAAccountingInstance::__handleSettleResult(), CAAccountingInstance::finishLoginProcess(), CAAccountingInstance::handleAccountCertificate_internal(), CAAccountingInstance::handleChallengeResponse_internal(), CAAccountingInstance::handleCostConfirmation_internal(), CAAccountingInstance::processJapMessage(), CAAccountingInstance::processJapMessageLoginHelper(), and CAAccountingInstance::settlementTransaction().
const UINT32 CAXMLErrorMessage::ERR_OUTDATED_CC = 16 [static] |
Definition at line 64 of file CAXMLErrorMessage.hpp.
Referenced by CAAccountingInstance::__handleSettleResult(), CAAccountingInstance::settlementTransaction(), and setValues().
const UINT32 CAXMLErrorMessage::ERR_SUCCESS_BUT_WITH_ERRORS = 20 [static] |
Definition at line 68 of file CAXMLErrorMessage.hpp.
Referenced by CAAccountingInstance::__handleSettleResult(), and CAAccountingInstance::settlementTransaction().
const UINT32 CAXMLErrorMessage::ERR_WRONG_DATA = 3 [static] |
Definition at line 51 of file CAXMLErrorMessage.hpp.
Referenced by CAAccountingInstance::handleCostConfirmation_internal().
const UINT32 CAXMLErrorMessage::ERR_WRONG_FORMAT = 2 [static] |
Definition at line 50 of file CAXMLErrorMessage.hpp.
Referenced by CAAccountingInstance::handleAccountCertificate_internal(), CAAccountingInstance::handleChallengeResponse_internal(), and CAAccountingInstance::handleCostConfirmation_internal().
UINT32 CAXMLErrorMessage::m_iErrorCode [private] |
Definition at line 121 of file CAXMLErrorMessage.hpp.
Referenced by CAXMLErrorMessage(), getErrorCode(), setValues(), and toXmlElement().
void* CAXMLErrorMessage::m_messageObject [private] |
Definition at line 123 of file CAXMLErrorMessage.hpp.
Referenced by CAXMLErrorMessage(), getMessageObject(), setValues(), toXmlElement(), and ~CAXMLErrorMessage().
UINT8* CAXMLErrorMessage::m_strErrMsg [private] |
Definition at line 122 of file CAXMLErrorMessage.hpp.
Referenced by CAXMLErrorMessage(), getDescription(), setValues(), toXmlElement(), and ~CAXMLErrorMessage().
1.7.6.1