Mixes for Privacy and Anonymity in the Internet
|
This is the AI (accounting instance or abrechnungsinstanz in german) class. More...
Classes | |
struct | t_aiqueueitem |
Static Public Member Functions | |
static SINT32 | init (CAFirstMix *callingMix) |
Returns a reference to the Singleton instance. More... | |
static SINT32 | clean () |
static UINT32 | getAuthFlags (fmHashTableEntry *pHashEntry) |
static SINT32 | cleanupTableEntry (fmHashTableEntry *pHashEntry) |
This should always be called when closing a JAP connection to cleanup the data structures. More... | |
static SINT32 | initTableEntry (fmHashTableEntry *pHashEntry) |
This must be called whenever a JAP is connecting to init our per-user data structures. More... | |
static SINT32 | handleJapPacket (fmHashTableEntry *pHashEntry, bool a_bControlMessage, bool a_bMessageToJAP) |
This should be called by the FirstMix for every incoming Jap packet. More... | |
static SINT32 | isIPAddressBlocked (const UINT8 ip[4]) |
Check if an IP address is temporarily blocked by the accounting instance. More... | |
static SINT32 | processJapMessage (fmHashTableEntry *pHashEntry, const XERCES_CPP_NAMESPACE::DOMDocument *a_DomDoc) |
Handle a user (xml) message sent to us by the Jap through the ControlChannel. More... | |
static UINT32 | getNrOfUsers () |
static SINT32 | loginProcessStatus (fmHashTableEntry *pHashEntry) |
static SINT32 | finishLoginProcess (fmHashTableEntry *pHashEntry) |
this method is for the corresponding CAFirstMix login thread to verify the result of the settlement. More... | |
static SINT32 | settlementTransaction () |
static SettleEntry * | __handleSettleResult (CAXMLCostConfirmation *pCC, CAXMLErrorMessage *pErrMsg, CAAccountingDBInterface *dbInterface, UINT64 a_iSettlementTransactionNr) |
static void | __commitSettlementToDatabase (SettleEntry *entryList, CAAccountingDBInterface *dbInterface) |
only for internal use during the settleTransaction because the global settlement lock is not acquired More... | |
static void | __commitSettlementToLoginTable (SettleEntry *entryList) |
only for internal use during the settleTransaction because no login table locks are acquired More... | |
static SINT32 | newSettlementTransaction () |
static SINT32 | __newSettlementTransaction (UINT32 *nrOfSettledCCs) |
Static Public Attributes | |
static const SINT32 | HANDLE_PACKET_CONNECTION_OK = 1 |
static const SINT32 | HANDLE_PACKET_CONNECTION_UNCHECKED = 4 |
static const SINT32 | HANDLE_PACKET_HOLD_CONNECTION = 0 |
static const SINT32 | HANDLE_PACKET_PREPARE_FOR_CLOSING_CONNECTION = 2 |
static const SINT32 | HANDLE_PACKET_CLOSE_CONNECTION = 3 |
static const UINT32 | MAX_SETTLED_CCS = 10 |
Private Types | |
typedef struct t_aiqueueitem | aiQueueItem |
Private Member Functions | |
CAAccountingInstance (CAFirstMix *callingMix) | |
private Constructor More... | |
~CAAccountingInstance () | |
private destructor More... | |
UINT32 | handleCostConfirmation (tAiAccountingInfo *pAccInfo, DOMElement *root) |
Handles a cost confirmation sent by a jap. More... | |
UINT32 | handleCostConfirmation_internal (tAiAccountingInfo *pAccInfo, DOMElement *root) |
Handles a cost confirmation sent by a jap. More... | |
UINT32 | handleAccountCertificate (tAiAccountingInfo *pAccInfo, DOMElement *root) |
Handles an account certificate of a newly connected Jap. More... | |
UINT32 | handleAccountCertificate_internal (tAiAccountingInfo *pAccInfo, DOMElement *root) |
Handles an account certificate of a newly connected Jap. More... | |
UINT32 | handleChallengeResponse (tAiAccountingInfo *pAccInfo, DOMElement *root) |
Checks the response of the challenge-response auth. More... | |
UINT32 | handleChallengeResponse_internal (tAiAccountingInfo *pAccInfo, DOMElement *root) |
Handles the response to our challenge. More... | |
bool | cascadeMatchesCC (CAXMLCostConfirmation *pCC) |
SINT32 | prepareCCRequest (CAMix *callingMix, UINT8 *a_AiName) |
creating the xml of a new CC is really the responsability of the CAXMLCostConfirmation class knowledge about the structure of a CC's XML should be encapsulated in it TODO: add constructor to that class that takes accountnumber, transferredbytes etc as params (should use a template internally into which it only inserts accNumber and bytes,to speed things up TODO: add toXMLElement method then replace manually building the xml here with contructing a CAXMLCostConfirmation and just add the xml returned by its toXMLElement method More... | |
Static Private Member Functions | |
static SINT32 | handleJapPacket_internal (fmHashTableEntry *pHashEntry, bool a_bControlMessage, bool a_bMessageToJAP) |
Called by FirstMix for each incoming JAP packet. More... | |
static UINT64 | unlockLogin (fmHashTableEntry *ownerRef) |
release login (particularly for use in error case) this function is thread-safe. More... | |
static void | processJapMessageLoginHelper (fmHashTableEntry *pHashEntry, UINT32 handlerReturnvalue, bool finishLogin) |
static SINT32 | getPrepaidBytes (tAiAccountingInfo *pAccInfos) |
static SINT32 | makeInitialCCRequest (CAXMLCostConfirmation *pCC, XERCES_CPP_NAMESPACE::DOMDocument *&doc, SINT32 prepaidBytes) |
new initialCCRequest containing the last CC and the prepaid bytes (this is a replacement for sending the prepaid with the challenge which is now deprecated). More... | |
static SINT32 | makeCCRequest (const UINT64 accountNumber, const UINT64 transferredBytes, XERCES_CPP_NAMESPACE::DOMDocument *&doc) |
static SINT32 | sendInitialCCRequest (tAiAccountingInfo *pAccInfo, CAXMLCostConfirmation *pCC, SINT32 prepaidBytes) |
static SINT32 | sendCCRequest (tAiAccountingInfo *pAccInfo) |
static SINT32 | makeAccountRequest (XERCES_CPP_NAMESPACE::DOMDocument *&doc) |
static SINT32 | sendAILoginConfirmation (tAiAccountingInfo *pAccInfo, const UINT32 code, UINT8 *message) |
static SINT32 | returnKickout (tAiAccountingInfo *pAccInfo) |
When receiving this message, the Mix should kick the user out immediately. More... | |
static SINT32 | returnPrepareKickout (tAiAccountingInfo *pAccInfo, CAXMLErrorMessage *a_error) |
static void | setPrepaidBytesToZero (tAiAccountingInfo *pAccInfo) |
static void | setPrepaidBytesToZero_internal (tAiAccountingInfo *pAccInfo) |
static THREAD_RETURN | processThread (void *a_param) |
The main loop of the AI thread - reads messages from the queue and starts process threads for these messages. More... | |
Private Attributes | |
CAThreadPool * | m_aiThreadPool |
reads messages from the queue and processes them More... | |
CAMutex * | m_pMutex |
this is for synchronizing the write access to the HashEntries More... | |
Hashtable * | m_certHashCC |
Hashtable * | m_currentAccountsHashtable |
Stores the account number of all users currently logged in. More... | |
CAFirstMix * | m_mix |
UINT8 * | m_AiName |
the name of this accounting instance More... | |
UINT8 * | m_currentCascade |
current cascade (identified by the concatenated hash values of the price certificates) More... | |
UINT8 ** | m_allHashes |
The hash values of the Mixes ordered beginning with the AI Mix. More... | |
UINT32 | m_allHashesLen |
CAAccountingBIInterface * | m_pPiInterface |
the interface to the database More... | |
UINT32 | m_iSoftLimitBytes |
UINT32 | m_iHardLimitBytes |
CATempIPBlockList * | m_pIPBlockList |
Users that get kicked out because they sent no authentication certificate get their IP appended to this list. More... | |
CAAccountingSettleThread * | m_pSettleThread |
Signature verifying instance for BI signatures. More... | |
bool | m_bThreadRunning |
volatile UINT64 | m_nextSettleNr |
volatile UINT64 | m_settleWaitNr |
CAConditionVariable * | m_pSettlementMutex |
volatile UINT32 | m_seqBIConnErrors |
Static Private Attributes | |
static const UINT64 | PACKETS_BEFORE_NEXT_CHECK = 100 |
static const UINT32 | MAX_TOLERATED_MULTIPLE_LOGINS = 10 |
static XERCES_CPP_NAMESPACE::DOMDocument * | m_preparedCCRequest |
static CAAccountingInstance * | ms_pInstance = NULL |
Singleton: This is the reference to the only instance of this class. More... | |
static SINT32 | m_prepaidBytesMinimum = 0 |
static volatile UINT64 | m_iCurrentSettleTransactionNr = 0 |
Friends | |
class | CAFirstMixA |
class | CAFirstMix |
This is the AI (accounting instance or abrechnungsinstanz in german) class.
Its purpose is to count packets for every user and to decide wether the connection should be closed (e.g. when a user is betraying us, or simply when the account is empty and the user refuses to charge it).
It is a singleton class, only one instance exists at a time. On the first call to getInstance() the initialization is performed.
|
private |
|
private |
private Constructor
References CACmdLnOptions::getAiID(), CALibProxytest::getOptions(), CACmdLnOptions::getPaymentHardLimit(), CACmdLnOptions::getPaymentSoftLimit(), m_AiName, m_aiThreadPool, m_allHashes, m_allHashesLen, m_certHashCC, m_currentAccountsHashtable, m_currentCascade, m_iHardLimitBytes, m_iSoftLimitBytes, m_mix, m_nextSettleNr, m_pMutex, m_pPiInterface, m_pSettlementMutex, m_pSettleThread, m_seqBIConnErrors, m_settleWaitNr, MAX_LOGIN_QUEUE, NUM_LOGIN_WORKER_TRHEADS, prepareCCRequest(), CAMsg::printMsg(), and CAAccountingBIInterface::setPIServerConfiguration().
Referenced by init().
|
private |
private destructor
References BEGIN_STACK, FINISH_STACK, INIT_STACK, CAMutex::lock(), m_AiName, m_aiThreadPool, m_allHashes, m_allHashesLen, m_certHashCC, m_currentAccountsHashtable, m_currentCascade, m_pMutex, m_pPiInterface, m_pSettlementMutex, m_pSettleThread, CAMsg::printMsg(), and CAMutex::unlock().
|
static |
only for internal use during the settleTransaction because the global settlement lock is not acquired
References SettleEntry::accountNumber, AUTH_ACCOUNT_EMPTY, AUTH_BLOCKED, AUTH_INVALID_ACCOUNT, AUTH_UNKNOWN, SettleEntry::authFlags, SettleEntry::authRemoveFlags, CAAccountingDBInterface::clearAccountStatus(), SettleEntry::diffBytes, CAXMLErrorMessage::ERR_ACCOUNT_EMPTY, CAXMLErrorMessage::ERR_BLOCKED, CAXMLErrorMessage::ERR_KEY_NOT_FOUND, CAAccountingDBInterface::getPrepaidAmount(), m_currentCascade, ms_pInstance, SettleEntry::nextEntry, CAMsg::printMsg(), SettleEntry::storedStatus, and CAAccountingDBInterface::storePrepaidAmount().
Referenced by __newSettlementTransaction().
|
static |
only for internal use during the settleTransaction because no login table locks are acquired
References SettleEntry::accountNumber, AccountLoginHashEntry::authFlags, SettleEntry::authFlags, AccountLoginHashEntry::authRemoveFlags, SettleEntry::authRemoveFlags, AccountLoginHashEntry::confirmedBytes, SettleEntry::confirmedBytes, m_currentAccountsHashtable, ms_pInstance, and SettleEntry::nextEntry.
Referenced by __newSettlementTransaction().
|
static |
References SettleEntry::accountNumber, AUTH_ACCOUNT_EMPTY, AUTH_BLOCKED, AUTH_INVALID_ACCOUNT, AUTH_OUTDATED_CC, AUTH_SETTLED_ONCE, AUTH_UNKNOWN, AUTH_WAITING_FOR_FIRST_SETTLED_CC, SettleEntry::authFlags, SettleEntry::authRemoveFlags, SettleEntry::confirmedBytes, CAAccountingDBInterface::deleteCC(), SettleEntry::diffBytes, E_SUCCESS, CAXMLErrorMessage::ERR_ACCOUNT_EMPTY, CAXMLErrorMessage::ERR_BLOCKED, CAXMLErrorMessage::ERR_DATABASE_ERROR, CAXMLErrorMessage::ERR_INTERNAL_SERVER_ERROR, CAXMLErrorMessage::ERR_KEY_NOT_FOUND, CAXMLErrorMessage::ERR_OK, CAXMLErrorMessage::ERR_OUTDATED_CC, CAXMLErrorMessage::ERR_SUCCESS_BUT_WITH_ERRORS, CAAccountingDBInterface::getAccountStatus(), CAXMLErrorMessage::getDescription(), CAXMLErrorMessage::getErrorCode(), CAXMLErrorMessage::getMessageObject(), m_currentCascade, CAAccountingDBInterface::markAsSettled(), ms_pInstance, print64(), CAMsg::printMsg(), CAAccountingDBInterface::storeAccountStatus(), CAAccountingDBInterface::storeCostConfirmation(), and SettleEntry::storedStatus.
Referenced by __newSettlementTransaction().
References __commitSettlementToDatabase(), __commitSettlementToLoginTable(), __handleSettleResult(), cleanup(), CRITICAL_SUBSEQUENT_BI_CONN_ERRORS, E_NOT_CONNECTED, E_SUCCESS, E_UNKNOWN, CAAccountingDBInterface::getConnection(), CAAccountingDBInterface::getUnsettledCostConfirmations(), CAAccountingBIInterface::initBIConnection(), CAMutex::lock(), m_currentAccountsHashtable, m_currentCascade, m_iCurrentSettleTransactionNr, m_nextSettleNr, m_pPiInterface, m_pSettlementMutex, m_seqBIConnErrors, m_settleWaitNr, MAX_SETTLED_CCS, MONITORING_FIRE_PAY_EVENT, ms_pInstance, SettleEntry::nextEntry, CAMsg::printMsg(), CAAccountingDBInterface::releaseConnection(), CAAccountingBIInterface::settleAll(), CAConditionVariable::signal(), CAAccountingBIInterface::terminateBIConnection(), CAMutex::unlock(), and CAConditionVariable::wait().
Referenced by newSettlementTransaction().
|
private |
References m_allHashesLen, m_certHashCC, and CAMsg::printMsg().
Referenced by handleChallengeResponse_internal(), and handleCostConfirmation_internal().
|
static |
References E_SUCCESS, m_preparedCCRequest, MONITORING_FIRE_PAY_EVENT, and ms_pInstance.
Referenced by CAFirstMix::clean().
|
static |
This should always be called when closing a JAP connection to cleanup the data structures.
This should always be called when closing a JAP connection to cleanup the payment data structures and store prepaid bytes.
(pAccInfo->authFlags & AUTH_WAITING_FOR_FIRST_SETTLED_CC))
References t_accountinginfo::accountNumber, AUTH_ACCOUNT_EMPTY, AUTH_ACCOUNT_OK, AUTH_DELETE_ENTRY, AccountLoginHashEntry::authFlags, t_accountinginfo::authFlags, BEGIN_STACK, t_accountinginfo::clientVersion, AccountLoginHashEntry::confirmedBytes, t_accountinginfo::confirmedBytes, E_SUCCESS, E_UNKNOWN, FINISH_STACK, CAAccountingDBInterface::getConnection(), CALibProxytest::getOptions(), getPrepaidBytes(), CACmdLnOptions::getPrepaidInterval(), INIT_STACK, isLoginOngoing(), m_currentAccountsHashtable, m_currentCascade, ms_pInstance, t_accountinginfo::mutex, t_accountinginfo::nrInQueue, AccountLoginHashEntry::ownerLock, AccountLoginHashEntry::ownerRef, t_fmhashtableentry::pAccountingInfo, t_accountinginfo::pChallenge, t_fmhashtableentry::peerIP, t_accountinginfo::pPublicKey, print64(), CAMsg::printMsg(), t_accountinginfo::pstrBIID, CAAccountingDBInterface::releaseConnection(), SAVE_STACK, CAAccountingDBInterface::storePrepaidAmount(), and testLoginEntryOwner().
Referenced by CAAccountingControlChannel::~CAAccountingControlChannel().
|
static |
this method is for the corresponding CAFirstMix login thread to verify the result of the settlement.
References t_accountinginfo::accountNumber, AUTH_ACCOUNT_EMPTY, AUTH_BLOCKED, AUTH_INVALID_ACCOUNT, AUTH_LOGIN_FAILED, AUTH_LOGIN_NOT_FINISHED, AUTH_LOGIN_SKIP_SETTLEMENT, AUTH_SETTLED_ONCE, AUTH_UNKNOWN, AccountLoginHashEntry::authFlags, t_accountinginfo::authFlags, AccountLoginHashEntry::authRemoveFlags, AccountLoginHashEntry::confirmedBytes, t_accountinginfo::confirmedBytes, CRITICAL_SETTLE_FLAGS, E_SUCCESS, CAXMLErrorMessage::ERR_ACCOUNT_EMPTY, CAXMLErrorMessage::ERR_BLOCKED, CAXMLErrorMessage::ERR_NO_BALANCE, CAXMLErrorMessage::ERR_NO_ERROR_GIVEN, CAXMLErrorMessage::ERR_OK, CAAccountingDBInterface::getAccountStatus(), CAAccountingDBInterface::getConnection(), getPrepaidBytes(), CAMutex::lock(), m_currentAccountsHashtable, ms_pInstance, t_accountinginfo::mutex, t_fmhashtableentry::pAccountingInfo, t_accountinginfo::pControlChannel, CAMsg::printMsg(), CAAccountingDBInterface::releaseConnection(), sendAILoginConfirmation(), CAAbstractControlChannel::sendXMLMessage(), CAAbstractXMLEncodable::toXmlDocument(), t_accountinginfo::transferredBytes, and CAMutex::unlock().
Referenced by CAFirstMix::doUserLogin_internal().
|
static |
References t_accountinginfo::authFlags, and t_fmhashtableentry::pAccountingInfo.
Referenced by CAFirstMixA::checkUserConnections().
|
static |
References CAMutex::lock(), m_currentAccountsHashtable, m_pMutex, ms_pInstance, CAMsg::printMsg(), and CAMutex::unlock().
Referenced by CAFirstMix::getNrOfUsers().
|
staticprivate |
|
private |
Handles an account certificate of a newly connected Jap.
References FINISH_STACK, handleAccountCertificate_internal(), and INIT_STACK.
Referenced by processJapMessage().
|
private |
Handles an account certificate of a newly connected Jap.
Parses accountnumber and publickey, checks the signature and generates and sends a challenge XML structure to the Jap. TODO: think about switching account without changing mixcascade (receive a new acc.cert. though we already have one)
References t_accountinginfo::accountNumber, AUTH_CHALLENGE_SENT, AUTH_DELETE_ENTRY, AUTH_FAKE, AUTH_GOT_ACCOUNTCERT, AUTH_TIMEOUT_STARTED, t_accountinginfo::authFlags, BEGIN_STACK, t_accountinginfo::challengeSentSeconds, createDOMDocument(), createDOMElement(), DOM_Output::dumpToMem(), E_SUCCESS, CABase64::encode(), CAXMLErrorMessage::ERR_BAD_REQUEST, CAXMLErrorMessage::ERR_BAD_SIGNATURE, CAXMLErrorMessage::ERR_INTERNAL_SERVER_ERROR, CAXMLErrorMessage::ERR_KEY_NOT_FOUND, CAXMLErrorMessage::ERR_NO_ERROR_GIVEN, CAXMLErrorMessage::ERR_NO_RECORD_FOUND, CAXMLErrorMessage::ERR_OK, CAXMLErrorMessage::ERR_WRONG_FORMAT, CAAccountingDBInterface::getConnection(), getcurrentTime(), getDOMChildByName(), getDOMElementValue(), CALibProxytest::getOptions(), CAAccountingDBInterface::getPrepaidAmount(), getRandom(), INIT_STACK, len, CAMutex::lock(), m_currentCascade, t_accountinginfo::mutex, t_accountinginfo::pChallenge, t_accountinginfo::pControlChannel, t_accountinginfo::pPublicKey, CAMsg::printMsg(), t_accountinginfo::pstrBIID, CAAccountingDBInterface::releaseConnection(), CAAbstractControlChannel::sendXMLMessage(), setDOMElementAttribute(), setDOMElementValue(), CASignature::setVerifyKey(), CAAbstractXMLEncodable::toXmlDocument(), CAMutex::unlock(), and CAMultiSignature::verifyXML().
Referenced by handleAccountCertificate().
|
private |
Checks the response of the challenge-response auth.
References FINISH_STACK, handleChallengeResponse_internal(), and INIT_STACK.
Referenced by processJapMessage().
|
private |
Handles the response to our challenge.
Checks the validity of the response and sets the user's authFlags Also gets the last CC of the user, and sends it to the JAP accordingly.
References AccountLoginHashEntry::accountNumber, t_accountinginfo::accountNumber, AUTH_ACCOUNT_EMPTY, AUTH_ACCOUNT_OK, AUTH_BLOCKED, AUTH_CHALLENGE_SENT, AUTH_DELETE_ENTRY, AUTH_FAKE, AUTH_GOT_ACCOUNTCERT, AUTH_INVALID_ACCOUNT, AUTH_MULTIPLE_LOGIN, AUTH_WAITING_FOR_FIRST_SETTLED_CC, AccountLoginHashEntry::authFlags, t_accountinginfo::authFlags, AccountLoginHashEntry::authRemoveFlags, BEGIN_STACK, t_accountinginfo::bytesToConfirm, cascadeMatchesCC(), t_fmhashtableentry::cleanupNotifier, CLIENT_VERSION_STR_LEN, t_accountinginfo::clientVersion, AccountLoginHashEntry::confirmedBytes, t_accountinginfo::confirmedBytes, AccountLoginHashEntry::count, CABase64::decode(), E_SUCCESS, CAXMLErrorMessage::ERR_ACCOUNT_EMPTY, CAXMLErrorMessage::ERR_BAD_SIGNATURE, CAXMLErrorMessage::ERR_BLOCKED, CAXMLErrorMessage::ERR_INTERNAL_SERVER_ERROR, CAXMLErrorMessage::ERR_KEY_NOT_FOUND, CAXMLErrorMessage::ERR_MULTIPLE_LOGIN, CAXMLErrorMessage::ERR_NO_ERROR_GIVEN, CAXMLErrorMessage::ERR_NO_RECORD_FOUND, CAXMLErrorMessage::ERR_OK, CAXMLErrorMessage::ERR_WRONG_FORMAT, CAFirstMix::forceKickout(), CAAccountingDBInterface::getAccountStatus(), CAAccountingDBInterface::getConnection(), CAAccountingDBInterface::getCostConfirmation(), getDOMChildByName(), getDOMElementValue(), CAFirstMix::getLoginMutex(), CALibProxytest::getOptions(), CAAccountingDBInterface::getPrepaidAmount(), CACmdLnOptions::getPrepaidInterval(), INIT_STACK, CAMutex::lock(), AccountLoginHashEntry::loginOngoing, m_currentAccountsHashtable, m_currentCascade, m_mix, ms_pInstance, t_accountinginfo::mutex, AccountLoginHashEntry::ownerLock, AccountLoginHashEntry::ownerRef, t_accountinginfo::ownerRef, t_accountinginfo::pChallenge, t_accountinginfo::pControlChannel, t_accountinginfo::pPublicKey, PREPAID_PROTO_CLIENT_VERSION, print64(), CAMsg::printMsg(), CAAccountingDBInterface::releaseConnection(), sendCCRequest(), sendInitialCCRequest(), CAAbstractControlChannel::sendXMLMessage(), testAndSetLoginOwner(), CAAbstractXMLEncodable::toXmlDocument(), t_accountinginfo::transferredBytes, CAMutex::unlock(), AccountLoginHashEntry::userID, t_accountinginfo::userID, CASignature::verifyDER(), and CAConditionVariable::wait().
Referenced by handleChallengeResponse().
|
private |
Handles a cost confirmation sent by a jap.
References FINISH_STACK, handleCostConfirmation_internal(), and INIT_STACK.
Referenced by processJapMessage().
|
private |
Handles a cost confirmation sent by a jap.
References t_accountinginfo::accountNumber, AUTH_ACCOUNT_EMPTY, AUTH_ACCOUNT_OK, AUTH_DATABASE, AUTH_DELETE_ENTRY, AUTH_FAKE, AUTH_GOT_ACCOUNTCERT, AUTH_HARD_LIMIT_REACHED, AUTH_LOGIN_NOT_FINISHED, AUTH_LOGIN_SKIP_SETTLEMENT, AUTH_SENT_CC_REQUEST, AUTH_WAITING_FOR_FIRST_SETTLED_CC, t_accountinginfo::authFlags, BEGIN_STACK, t_accountinginfo::bytesToConfirm, cascadeMatchesCC(), t_accountinginfo::confirmedBytes, E_SUCCESS, E_UNKNOWN, CAXMLErrorMessage::ERR_BAD_REQUEST, CAXMLErrorMessage::ERR_BAD_SIGNATURE, CAXMLErrorMessage::ERR_INTERNAL_SERVER_ERROR, CAXMLErrorMessage::ERR_NO_ERROR_GIVEN, CAXMLErrorMessage::ERR_NO_RECORD_FOUND, CAXMLErrorMessage::ERR_OK, CAXMLErrorMessage::ERR_WRONG_DATA, CAXMLErrorMessage::ERR_WRONG_FORMAT, CAAccountingDBInterface::getConnection(), getcurrentTimeMillis(), CALibProxytest::getOptions(), getPrepaidBytes(), CACmdLnOptions::getPrepaidInterval(), INIT_STACK, t_accountinginfo::lastHardLimitSeconds, CAMutex::lock(), m_allHashesLen, m_currentCascade, m_pSettleThread, t_accountinginfo::mutex, t_accountinginfo::pControlChannel, t_accountinginfo::pPublicKey, print64(), CAMsg::printMsg(), CAAccountingDBInterface::releaseConnection(), CAAbstractControlChannel::sendXMLMessage(), CAAccountingSettleThread::settle(), CAAccountingDBInterface::storeCostConfirmation(), CAAbstractXMLEncodable::toXmlDocument(), t_accountinginfo::transferredBytes, CAMutex::unlock(), and CASignature::verifyXML().
Referenced by handleCostConfirmation().
|
static |
This should be called by the FirstMix for every incoming Jap packet.
References FINISH_STACK, handleJapPacket_internal(), and INIT_STACK.
Referenced by CAFirstMixA::accountTrafficDownstream(), CAFirstMixA::accountTrafficUpstream(), and CAFirstMixB::loop().
|
staticprivate |
Called by FirstMix for each incoming JAP packet.
Determines whether the packet should be let through or not
Possible return values, and FirstMix's reaction:
Do not make further checkings. Let the client use the remaining prepaid bytes, and then disconnect him afterwards. As the confirmedBytes are set to zero when the client connects and the account has been empty before, no other (unauthenticated) client may use these bytes.
References t_accountinginfo::accountNumber, AUTH_ACCOUNT_EMPTY, AUTH_BLOCKED, AUTH_DATABASE, AUTH_DELETE_ENTRY, AUTH_FATAL_ERROR, AUTH_HARD_LIMIT_REACHED, AUTH_INVALID_ACCOUNT, AUTH_LOGIN_NOT_FINISHED, AUTH_MULTIPLE_LOGIN, AUTH_OUTDATED_CC, AUTH_SENT_CC_REQUEST, AUTH_TIMEOUT_STARTED, AUTH_UNKNOWN, AUTH_WAITING_FOR_FIRST_SETTLED_CC, AccountLoginHashEntry::authFlags, t_accountinginfo::authFlags, AccountLoginHashEntry::authRemoveFlags, BEGIN_STACK, AccountLoginHashEntry::confirmedBytes, t_accountinginfo::confirmedBytes, CAXMLErrorMessage::ERR_ACCOUNT_EMPTY, CAXMLErrorMessage::ERR_BLOCKED, CAXMLErrorMessage::ERR_DATABASE_ERROR, CAXMLErrorMessage::ERR_INTERNAL_SERVER_ERROR, CAXMLErrorMessage::ERR_KEY_NOT_FOUND, CAXMLErrorMessage::ERR_MULTIPLE_LOGIN, CAXMLErrorMessage::ERR_NO_CONFIRMATION, CAAccountingDBInterface::getConnection(), CAAccountingDBInterface::getCostConfirmation(), CALibProxytest::getOptions(), getPrepaidBytes(), CACmdLnOptions::getPrepaidInterval(), HANDLE_PACKET_CLOSE_CONNECTION, HANDLE_PACKET_CONNECTION_OK, HANDLE_PACKET_CONNECTION_UNCHECKED, HANDLE_PACKET_PREPARE_FOR_CLOSING_CONNECTION, HARD_LIMIT_TIMEOUT, INIT_STACK, t_accountinginfo::lastHardLimitSeconds, CAMutex::lock(), m_currentAccountsHashtable, m_currentCascade, m_iHardLimitBytes, m_iSoftLimitBytes, MIXPACKET_SIZE, ms_pInstance, t_accountinginfo::mutex, t_accountinginfo::ownerRef, t_fmhashtableentry::pAccountingInfo, PACKETS_BEFORE_NEXT_CHECK, t_accountinginfo::pControlChannel, print64(), CAMsg::printMsg(), CAAccountingDBInterface::releaseConnection(), returnKickout(), returnPrepareKickout(), SAVE_STACK, sendCCRequest(), CAAbstractControlChannel::sendXMLMessage(), t_accountinginfo::sessionPackets, t_accountinginfo::transferredBytes, and CAMutex::unlock().
Referenced by handleJapPacket().
|
static |
Returns a reference to the Singleton instance.
References CAAccountingInstance(), E_SUCCESS, MONITORING_FIRE_PAY_EVENT, and ms_pInstance.
Referenced by CAFirstMix::init().
|
static |
This must be called whenever a JAP is connecting to init our per-user data structures.
References AUTH_HARD_LIMIT_REACHED, AUTH_LOGIN_NOT_FINISHED, AUTH_SENT_ACCOUNT_REQUEST, AUTH_SENT_CC_REQUEST, AUTH_TIMEOUT_STARTED, AUTH_WAITING_FOR_FIRST_SETTLED_CC, t_accountinginfo::authFlags, t_accountinginfo::authTimeoutStartSeconds, BEGIN_STACK, t_accountinginfo::bytesToConfirm, t_accountinginfo::clientVersion, t_accountinginfo::confirmedBytes, E_SUCCESS, E_UNKNOWN, FINISH_STACK, t_fmhashtableentry::id, INIT_STACK, t_accountinginfo::lastHardLimitSeconds, t_accountinginfo::mutex, t_accountinginfo::nrInQueue, t_accountinginfo::ownerRef, t_fmhashtableentry::pAccountingInfo, SAVE_STACK, t_accountinginfo::sessionPackets, t_accountinginfo::transferredBytes, and t_accountinginfo::userID.
Referenced by CAAccountingControlChannel::CAAccountingControlChannel().
Check if an IP address is temporarily blocked by the accounting instance.
This should be called by the FirstMix when a JAP is connecting.
1 | if the given IP is blocked |
0 | if it is not blocked |
|
static |
|
staticprivate |
|
staticprivate |
References BEGIN_STACK, createDOMDocument(), createDOMElement(), E_SUCCESS, FINISH_STACK, getDOMChildByName(), INIT_STACK, m_preparedCCRequest, and setDOMElementValue().
Referenced by sendCCRequest().
|
staticprivate |
new initialCCRequest containing the last CC and the prepaid bytes (this is a replacement for sending the prepaid with the challenge which is now deprecated).
References createDOMDocument(), createDOMElement(), E_SUCCESS, E_UNKNOWN, getDOMChildByName(), m_preparedCCRequest, CAMsg::printMsg(), setDOMElementAttribute(), and setDOMElementValue().
Referenced by sendInitialCCRequest().
|
static |
References __newSettlementTransaction(), E_SUCCESS, and MAX_SETTLED_CCS.
Referenced by CAFirstMix::doUserLogin_internal(), and CAAccountingSettleThread::mainLoop().
creating the xml of a new CC is really the responsability of the CAXMLCostConfirmation class knowledge about the structure of a CC's XML should be encapsulated in it TODO: add constructor to that class that takes accountnumber, transferredbytes etc as params (should use a template internally into which it only inserts accNumber and bytes,to speed things up TODO: add toXMLElement method then replace manually building the xml here with contructing a CAXMLCostConfirmation and just add the xml returned by its toXMLElement method
callingMix | the Mix instance to which the AI belongs (needed to get cascadeInfo to extract the price certificates to include in cost confirmations) |
References createDOMDocument(), createDOMElement(), E_SUCCESS, E_UNKNOWN, CABase64::encode(), getDOMChildByName(), getElementsByTagName(), CAMix::getMixCascadeInfo(), len, m_allHashes, m_allHashesLen, m_currentCascade, m_preparedCCRequest, DOM_Output::makeCanonical(), CAMsg::printMsg(), setDOMElementAttribute(), setDOMElementValue(), and strtrim().
Referenced by CAAccountingInstance().
|
static |
Handle a user (xml) message sent to us by the Jap through the ControlChannel.
Handle a user (xml) message sent to us by the Jap.
This function determines what type of message we have and sends the appropriate handle...() function to the ai thread.
This function is running inside the AiThread. It determines what type of message we have and calls the appropriate handle...() function
pHashEntry->pAccountingInfo->mutex->lock(); pItem->pAccInfo->nrInQueue++; ret = ms_pInstance->m_aiThreadPool->addRequest(processThread, pItem); if (ret !=E_SUCCESS) { pItem->pAccInfo->nrInQueue–; CAMsg::printMsg(LOG_CRIT, "CAAccountingInstance: Process could not add to AI thread pool!\n" ); delete pItem->pDomDoc; delete pItem; } pHashEntry->pAccountingInfo->mutex->unlock(); return ret; }
References AUTH_ACCOUNT_EMPTY, AUTH_BLOCKED, AUTH_INVALID_ACCOUNT, AUTH_LOGIN_SKIP_SETTLEMENT, t_accountinginfo::authFlags, BEGIN_STACK, E_SUCCESS, E_UNKNOWN, CAXMLErrorMessage::ERR_OK, FINISH_STACK, getPrepaidBytes(), handleAccountCertificate(), handleChallengeResponse(), handleCostConfirmation(), INIT_STACK, ms_pInstance, t_fmhashtableentry::pAccountingInfo, CAMsg::printMsg(), processJapMessageLoginHelper(), and SAVE_STACK.
Referenced by CAAccountingControlChannel::processXMLMessage().
|
staticprivate |
References AUTH_FAKE, AUTH_LOGIN_FAILED, AUTH_LOGIN_NOT_FINISHED, AUTH_MULTIPLE_LOGIN, t_accountinginfo::authFlags, CAXMLErrorMessage::ERR_INTERNAL_SERVER_ERROR, CAXMLErrorMessage::ERR_MULTIPLE_LOGIN, CAXMLErrorMessage::ERR_OK, CAMutex::lock(), t_accountinginfo::mutex, t_fmhashtableentry::pAccountingInfo, t_accountinginfo::pControlChannel, CAAbstractControlChannel::sendXMLMessage(), CAAbstractXMLEncodable::toXmlDocument(), and CAMutex::unlock().
Referenced by processJapMessage().
|
staticprivate |
The main loop of the AI thread - reads messages from the queue and starts process threads for these messages.
Processes JAP messages asynchronously by calls to the appropriate handlers.
References AUTH_DELETE_ENTRY, t_accountinginfo::authFlags, BEGIN_STACK, FINISH_STACK, CAAccountingInstance::t_aiqueueitem::handleFunc, INIT_STACK, CAMutex::lock(), ms_pInstance, t_accountinginfo::mutex, t_accountinginfo::nrInQueue, CAAccountingInstance::t_aiqueueitem::pAccInfo, CAAccountingInstance::t_aiqueueitem::pDomDoc, CAMsg::printMsg(), THREAD_RETURN_SUCCESS, and CAMutex::unlock().
|
staticprivate |
When receiving this message, the Mix should kick the user out immediately.
References t_accountinginfo::accountNumber, HANDLE_PACKET_CLOSE_CONNECTION, t_accountinginfo::mutex, print64(), CAMsg::printMsg(), setPrepaidBytesToZero_internal(), and CAMutex::unlock().
Referenced by handleJapPacket_internal().
|
staticprivate |
References AUTH_FATAL_ERROR, t_accountinginfo::authFlags, HANDLE_PACKET_PREPARE_FOR_CLOSING_CONNECTION, t_accountinginfo::mutex, t_accountinginfo::pControlChannel, CAMsg::printMsg(), CAAbstractControlChannel::sendXMLMessage(), CAAbstractXMLEncodable::toXmlDocument(), and CAMutex::unlock().
Referenced by handleJapPacket_internal().
|
staticprivate |
|
staticprivate |
References t_accountinginfo::accountNumber, AUTH_ACCOUNT_EMPTY, AUTH_SENT_CC_REQUEST, t_accountinginfo::authFlags, BEGIN_STACK, t_accountinginfo::bytesToConfirm, DOM_Output::dumpToMem(), E_SUCCESS, CALibProxytest::getOptions(), CACmdLnOptions::getPrepaidInterval(), INIT_STACK, makeCCRequest(), t_accountinginfo::pControlChannel, CAMsg::printMsg(), CAAbstractControlChannel::sendXMLMessage(), and t_accountinginfo::transferredBytes.
Referenced by handleChallengeResponse_internal(), and handleJapPacket_internal().
|
staticprivate |
|
staticprivate |
References CAMutex::lock(), t_accountinginfo::mutex, setPrepaidBytesToZero_internal(), and CAMutex::unlock().
|
staticprivate |
References t_accountinginfo::confirmedBytes, and t_accountinginfo::transferredBytes.
Referenced by returnKickout(), and setPrepaidBytesToZero().
|
static |
References SettleEntry::accountNumber, AUTH_ACCOUNT_EMPTY, AUTH_BLOCKED, AUTH_INVALID_ACCOUNT, AUTH_OUTDATED_CC, AUTH_SETTLED_ONCE, AUTH_UNKNOWN, AUTH_WAITING_FOR_FIRST_SETTLED_CC, AccountLoginHashEntry::authFlags, SettleEntry::authFlags, AccountLoginHashEntry::authRemoveFlags, SettleEntry::authRemoveFlags, BEGIN_STACK, CAAccountingDBInterface::clearAccountStatus(), AccountLoginHashEntry::confirmedBytes, SettleEntry::confirmedBytes, CRITICAL_SUBSEQUENT_BI_CONN_ERRORS, CAAccountingDBInterface::deleteCC(), SettleEntry::diffBytes, E_NOT_CONNECTED, E_SUCCESS, E_UNKNOWN, CAXMLErrorMessage::ERR_ACCOUNT_EMPTY, CAXMLErrorMessage::ERR_BLOCKED, CAXMLErrorMessage::ERR_DATABASE_ERROR, CAXMLErrorMessage::ERR_INTERNAL_SERVER_ERROR, CAXMLErrorMessage::ERR_KEY_NOT_FOUND, CAXMLErrorMessage::ERR_OK, CAXMLErrorMessage::ERR_OUTDATED_CC, CAXMLErrorMessage::ERR_SUCCESS_BUT_WITH_ERRORS, FINISH_STACK, CAAccountingDBInterface::getAccountStatus(), CAAccountingDBInterface::getConnection(), CAXMLErrorMessage::getDescription(), CAXMLErrorMessage::getErrorCode(), CAXMLErrorMessage::getMessageObject(), CAAccountingDBInterface::getPrepaidAmount(), CAAccountingDBInterface::getUnsettledCostConfirmations(), INIT_STACK, CAAccountingBIInterface::initBIConnection(), CAMutex::lock(), m_currentAccountsHashtable, m_currentCascade, m_nextSettleNr, m_pPiInterface, m_pSettlementMutex, m_seqBIConnErrors, m_settleWaitNr, CAAccountingDBInterface::markAsSettled(), MAX_SETTLED_CCS, MONITORING_FIRE_PAY_EVENT, ms_pInstance, SettleEntry::nextEntry, print64(), CAMsg::printMsg(), CAAccountingDBInterface::releaseConnection(), SAVE_STACK, CAAccountingBIInterface::settle(), CAConditionVariable::signal(), CAAccountingDBInterface::storeAccountStatus(), CAAccountingDBInterface::storeCostConfirmation(), SettleEntry::storedStatus, CAAccountingDBInterface::storePrepaidAmount(), CAAccountingBIInterface::terminateBIConnection(), CAMutex::unlock(), and CAConditionVariable::wait().
|
staticprivate |
release login (particularly for use in error case) this function is thread-safe.
References t_accountinginfo::accountNumber, m_currentAccountsHashtable, ms_pInstance, t_fmhashtableentry::pAccountingInfo, and resetLoginOngoing().
Referenced by CAFirstMix::doUserLogin_internal().
|
friend |
|
friend |
|
static |
|
static |
|
static |
Referenced by handleJapPacket_internal().
|
static |
|
static |
|
private |
the name of this accounting instance
Referenced by CAAccountingInstance(), and ~CAAccountingInstance().
|
private |
reads messages from the queue and processes them
Referenced by CAAccountingInstance(), and ~CAAccountingInstance().
|
private |
The hash values of the Mixes ordered beginning with the AI Mix.
Referenced by CAAccountingInstance(), prepareCCRequest(), and ~CAAccountingInstance().
|
private |
|
private |
|
private |
Referenced by CAAccountingInstance(), cascadeMatchesCC(), and ~CAAccountingInstance().
|
private |
Stores the account number of all users currently logged in.
Referenced by __commitSettlementToLoginTable(), __newSettlementTransaction(), CAAccountingInstance(), cleanupTableEntry(), finishLoginProcess(), getNrOfUsers(), handleChallengeResponse_internal(), handleJapPacket_internal(), settlementTransaction(), unlockLogin(), and ~CAAccountingInstance().
|
private |
current cascade (identified by the concatenated hash values of the price certificates)
Referenced by __commitSettlementToDatabase(), __handleSettleResult(), __newSettlementTransaction(), CAAccountingInstance(), cleanupTableEntry(), handleAccountCertificate_internal(), handleChallengeResponse_internal(), handleCostConfirmation_internal(), handleJapPacket_internal(), prepareCCRequest(), settlementTransaction(), and ~CAAccountingInstance().
|
staticprivate |
Referenced by __newSettlementTransaction().
|
private |
Referenced by CAAccountingInstance(), and handleJapPacket_internal().
|
private |
Referenced by CAAccountingInstance(), and handleJapPacket_internal().
|
private |
Referenced by CAAccountingInstance(), and handleChallengeResponse_internal().
|
private |
Referenced by __newSettlementTransaction(), CAAccountingInstance(), and settlementTransaction().
|
private |
Users that get kicked out because they sent no authentication certificate get their IP appended to this list.
Connections from IP Addresses contained in this list get blocked, so that evil JAP users can't use the mix cascade without paying
|
private |
this is for synchronizing the write access to the HashEntries
Referenced by CAAccountingInstance(), getNrOfUsers(), and ~CAAccountingInstance().
|
private |
the interface to the database
Referenced by __newSettlementTransaction(), CAAccountingInstance(), settlementTransaction(), and ~CAAccountingInstance().
|
staticprivate |
|
staticprivate |
Referenced by clean(), makeCCRequest(), makeInitialCCRequest(), and prepareCCRequest().
|
private |
Referenced by __newSettlementTransaction(), CAAccountingInstance(), settlementTransaction(), and ~CAAccountingInstance().
|
private |
Signature verifying instance for BI signatures.
this thread sends cost confirmations to the BI in regular intervals
Referenced by CAAccountingInstance(), handleCostConfirmation_internal(), and ~CAAccountingInstance().
|
private |
Referenced by __newSettlementTransaction(), CAAccountingInstance(), and settlementTransaction().
|
private |
Referenced by __newSettlementTransaction(), CAAccountingInstance(), and settlementTransaction().
|
static |
Referenced by __newSettlementTransaction(), newSettlementTransaction(), and settlementTransaction().
|
staticprivate |
|
staticprivate |
Singleton: This is the reference to the only instance of this class.
Referenced by __commitSettlementToDatabase(), __commitSettlementToLoginTable(), __handleSettleResult(), __newSettlementTransaction(), clean(), cleanupTableEntry(), finishLoginProcess(), getNrOfUsers(), handleChallengeResponse_internal(), handleJapPacket_internal(), init(), processJapMessage(), processThread(), settlementTransaction(), and unlockLogin().
|
staticprivate |
Referenced by handleJapPacket_internal().