|
dolibarr 24.0.0-beta
|
Class to manage Blocked Log. More...
Public Member Functions | |
| __construct (DoliDB $db) | |
| Constructor. | |
| loadTrackedEvents () | |
| Load list of tracked and controlled events into $this->controlled, $this->trackedevents and $this->trackedmodules. | |
| getObjectLink () | |
| Try to retrieve source object (it it still exists). | |
| getUser () | |
| Try to retrieve user author. | |
| setObjectData (&$object, $action, $amounts, $fuser=null, $amounts_taxexcl=null) | |
| Populate properties of an unalterable log entry from object data. | |
| fetch ($id) | |
| Get object from database. | |
| dolEncodeBlockedData ($data, $mode=1) | |
| Encode data. | |
| dolDecodeBlockedData ($data, $mode=0) | |
| Decode data. | |
| setCertified () | |
| Set block certified by an external authority. | |
| create ($user, $forcesignature='') | |
| Create blocked log in database. | |
| getEndOfChainFlagFile () | |
| Return path of end of chain flag file. | |
| checkSignature ($previoushash='', $returnarray=0) | |
| Check if calculated signature still correct compared to the value in the chain. | |
| buildKeyForSignature ($format='') | |
| Return the string for signature (clear data). | |
| saveHMACSecretKey ($hmac_secret_key, $obfuscationmode, $obfuscationkey='') | |
| Save the HMAC secret key into database. | |
| getObfuscationKey () | |
| Return the remote obfuscation key from ping.dolibarr.org (used later to decode HMAC secret key). | |
| getEncodedHMACSecretKey ($nocache=0, $noentity=0) | |
| Get the encoded HMAC secret key. | |
| getClearHMACSecretKey ($hmac_encoded_secret_key) | |
| Get the HMAC secret key. | |
| getPreviousHash ($withlock=0, $beforeid=0) | |
| Get previous signature/hash in chain. | |
| getNextRecord ($rowidafter=0) | |
| Return the last record in blocked log. | |
| getLastRecord () | |
| Return the last record in blocked log. | |
| getLog ($element, $fk_object, $limit=0, $sortfield='', $sortorder='', $search_fk_user=-1, $search_start=-1, $search_end=-1, $search_ref='', $search_amount='', $search_code='', $search_signature='', $search_module_source='', $search_pos_source='', $search_type_code='') | |
| Return array of unalterable log objects (filtered with criteria) | |
| getOrInitFirstSignature () | |
| Return the signature (hash) of the "genesis-block" (Block 0). | |
| alreadyUsed ($ignoresystem=0) | |
| Check if module was already used or not for at least one recording. | |
| canBeEnabled () | |
| Check if module can be enabled. | |
| canBeDisabled () | |
| Check if module can be disabled. | |
| countRecord () | |
| Return current number of records. | |
Private Member Functions | |
| buildFirstPartOfKeyForSignature ($format='') | |
| Return first part of string for signature (clear data) Note: rowid of line not included as it is not a business data and this allow to make backup of a year and restore it into another database with different ids without comprimising checksums. | |
| buildFinalSignatureHash ($clearstring, $format='') | |
| Return a hash that is the signature of a line data $clearstring (hash_hmac SHA256 of data + secret key) | |
Class to manage Blocked Log.
Definition at line 31 of file blockedlog.class.php.
| BlockedLog::__construct | ( | DoliDB | $db | ) |
| BlockedLog::alreadyUsed | ( | $ignoresystem = 0 | ) |
Check if module was already used or not for at least one recording.
| int<0,1> | $ignoresystem Ignore system events for the test |
Definition at line 2383 of file blockedlog.class.php.
References isBlockedLogUsed().
|
private |
Return a hash that is the signature of a line data $clearstring (hash_hmac SHA256 of data + secret key)
| string | $clearstring | Data string to sign |
| string | $format | Force encryption format version to use ('V1', 'V2', ...) |
Definition at line 1769 of file blockedlog.class.php.
References $mysoc, dol_hash(), getClearHMACSecretKey(), getEncodedHMACSecretKey(), getObfuscationKey(), isALNERunningVersion(), and saveHMACSecretKey().
Referenced by checkSignature(), and create().
|
private |
Return first part of string for signature (clear data) Note: rowid of line not included as it is not a business data and this allow to make backup of a year and restore it into another database with different ids without comprimising checksums.
| string | $format | Force format to use |
Definition at line 1709 of file blockedlog.class.php.
Referenced by buildKeyForSignature(), and create().
| BlockedLog::buildKeyForSignature | ( | $format = '' | ) |
Return the string for signature (clear data).
| string | $format | Force format to use |
Definition at line 1744 of file blockedlog.class.php.
References buildFirstPartOfKeyForSignature().
Referenced by checkSignature(), and create().
| BlockedLog::canBeDisabled | ( | ) |
Check if module can be disabled.
Definition at line 2415 of file blockedlog.class.php.
References $mysoc, and isALNEQualifiedVersion().
| BlockedLog::canBeEnabled | ( | ) |
Check if module can be enabled.
Definition at line 2395 of file blockedlog.class.php.
References isALNEQualifiedVersion(), and isHTTPS().
| BlockedLog::checkSignature | ( | $previoushash = '', | |
| $returnarray = 0 ) |
Check if calculated signature still correct compared to the value in the chain.
| string | $previoushash | If previous signature hash is known, we can provide it to avoid to make a search of it in database. |
| int<0,2> | $returnarray 1=Return array of details, 2=Return array of details including keyforsignature, 0=Return a boolean |
Definition at line 1651 of file blockedlog.class.php.
References buildFinalSignatureHash(), buildKeyForSignature(), dol_syslog(), and getPreviousHash().
| BlockedLog::countRecord | ( | ) |
Return current number of records.
Definition at line 2438 of file blockedlog.class.php.
References dol_print_error().
| BlockedLog::create | ( | $user, | |
| $forcesignature = '' ) |
Create blocked log in database.
| User | $user | Object user that create |
| string | $forcesignature | Force signature (for example '0000000000' when we disabled the module, to force a non valid record, for test purpose for example) |
Definition at line 1275 of file blockedlog.class.php.
References $conf, $mysoc, buildFinalSignatureHash(), buildFirstPartOfKeyForSignature(), buildKeyForSignature(), dol_mkdir(), dol_now(), dol_print_date(), dol_syslog(), dolChmod(), dolDecrypt(), dolEncodeBlockedData(), dolEncrypt(), getDolGlobalString(), getEndOfChainFlagFile(), getObfuscationKey(), getPreviousHash(), isALNERunningVersion(), and string.
| BlockedLog::dolDecodeBlockedData | ( | $data, | |
| $mode = 0 ) |
Decode data.
| string | $data | Data to unserialize |
| int | $mode | 0=unserialize, 1=json_decode |
Definition at line 1240 of file blockedlog.class.php.
Referenced by fetch().
| BlockedLog::dolEncodeBlockedData | ( | $data, | |
| $mode = 1 ) |
Encode data.
| ?stdClass | $data | Data to serialize |
| int<0,1> | $mode 0=serialize, 1=json_encode |
Definition at line 1225 of file blockedlog.class.php.
Referenced by create().
| BlockedLog::fetch | ( | $id | ) |
Get object from database.
| int | $id | Id of object to load |
Definition at line 1138 of file blockedlog.class.php.
References dolDecodeBlockedData().
| BlockedLog::getClearHMACSecretKey | ( | $hmac_encoded_secret_key | ) |
Get the HMAC secret key.
| string | $hmac_encoded_secret_key | HMAC encode string retrieved with getEncodedHMACSecretKey() |
Definition at line 2026 of file blockedlog.class.php.
References dolDecrypt(), and getObfuscationKey().
Referenced by buildFinalSignatureHash().
| BlockedLog::getEncodedHMACSecretKey | ( | $nocache = 0, | |
| $noentity = 0 ) |
Get the encoded HMAC secret key.
Use a memory cache to avoid repeated db access.
| int | $nocache | Use 1 to force to not use cache. |
| int | $noentity | Use 1 to search without entity. |
Definition at line 1983 of file blockedlog.class.php.
References $conf.
Referenced by buildFinalSignatureHash(), and saveHMACSecretKey().
| BlockedLog::getEndOfChainFlagFile | ( | ) |
Return path of end of chain flag file.
Definition at line 1635 of file blockedlog.class.php.
References $conf.
Referenced by create().
| BlockedLog::getLastRecord | ( | ) |
Return the last record in blocked log.
Definition at line 2181 of file blockedlog.class.php.
References $conf.
| BlockedLog::getLog | ( | $element, | |
| $fk_object, | |||
| $limit = 0, | |||
| $sortfield = '', | |||
| $sortorder = '', | |||
| $search_fk_user = -1, | |||
| $search_start = -1, | |||
| $search_end = -1, | |||
| $search_ref = '', | |||
| $search_amount = '', | |||
| $search_code = '', | |||
| $search_signature = '', | |||
| $search_module_source = '', | |||
| $search_pos_source = '', | |||
| $search_type_code = '' ) |
Return array of unalterable log objects (filtered with criteria)
| string | $element | Element to search |
| string | int | $fk_object | Id of object to search. Can be a UFS search criteria. |
| int<0,max> | $limit Max number of element, 0 for all | |
| string | $sortfield | Sort field |
| string | $sortorder | Sort order |
| int | $search_fk_user | Id of user(s) |
| int | $search_start | Start time limit |
| int | $search_end | End time limit |
| string | $search_ref | Search ref |
| string | $search_amount | Search amount |
| string | string[] | $search_code | Search code |
| string | $search_signature | Search signature |
| string | $search_module_source | Search on module source |
| string | $search_pos_source | Search on terminal |
| string | $search_type_code | Search on type code |
Definition at line 2222 of file blockedlog.class.php.
References $conf, and natural_search().
| BlockedLog::getNextRecord | ( | $rowidafter = 0 | ) |
Return the last record in blocked log.
| int | $rowidafter | Search record after this one |
Definition at line 2153 of file blockedlog.class.php.
References $conf.
| BlockedLog::getObfuscationKey | ( | ) |
Return the remote obfuscation key from ping.dolibarr.org (used later to decode HMAC secret key).
Use a memory cache to avoid repeated db access. This function can also be called just to store the remote obfuscation key into the cache so all next call will not depends on the obfuscation key server availability. Note: Avoid to call this function if you are not in acontext that need remote obfuscation key.
Definition at line 1931 of file blockedlog.class.php.
References $conf, $mysoc, callApiToGetObfuscationKey(), dol_syslog(), and getHashUniqueIdOfRegistration().
Referenced by buildFinalSignatureHash(), create(), and getClearHMACSecretKey().
| BlockedLog::getObjectLink | ( | ) |
Try to retrieve source object (it it still exists).
Definition at line 361 of file blockedlog.class.php.
| BlockedLog::getOrInitFirstSignature | ( | ) |
Return the signature (hash) of the "genesis-block" (Block 0).
Definition at line 2357 of file blockedlog.class.php.
References $conf, $db, dolibarr_set_const(), and getDolGlobalString().
Referenced by getPreviousHash().
| BlockedLog::getPreviousHash | ( | $withlock = 0, | |
| $beforeid = 0 ) |
Get previous signature/hash in chain.
If there is no previous line, return the init hash.
| int<0,1> | $withlock 1=With a lock (Used in the ->create() transaction) | |
| int | $beforeid | ID of a record |
Definition at line 2071 of file blockedlog.class.php.
References $conf, dol_print_error(), dol_syslog(), and getOrInitFirstSignature().
Referenced by checkSignature(), and create().
| BlockedLog::getUser | ( | ) |
| BlockedLog::loadTrackedEvents | ( | ) |
Load list of tracked and controlled events into $this->controlled, $this->trackedevents and $this->trackedmodules.
Definition at line 226 of file blockedlog.class.php.
References getDolGlobalString(), img_picto(), and isModEnabled().
| BlockedLog::saveHMACSecretKey | ( | $hmac_secret_key, | |
| $obfuscationmode, | |||
| $obfuscationkey = '' ) |
Save the HMAC secret key into database.
| string | $hmac_secret_key | HMAC secret key ('BLOCKEDLOG_HMAC_KEY...') |
| string | $obfuscationmode | Obfuscation mode ('dolcrypt', 'dolobfuscationv1-SIREN') |
| string | $obfuscationkey | Obfuscation key |
Definition at line 1856 of file blockedlog.class.php.
References $conf, dol_syslog(), dolEncrypt(), and getEncodedHMACSecretKey().
Referenced by buildFinalSignatureHash().
| BlockedLog::setCertified | ( | ) |
Set block certified by an external authority.
Definition at line 1258 of file blockedlog.class.php.
| BlockedLog::setObjectData | ( | & | $object, |
| $action, | |||
| $amounts, | |||
| $fuser = null, | |||
| $amounts_taxexcl = null ) |
Populate properties of an unalterable log entry from object data.
This populates ->object_data but also other fields like ->action, ->module_source, ->amounts_taxexcl, ->amounts and ->linktoref and ->linktype It also populates some debug info like ->element and ->fk_object
| CommonObject | stdClass | $object | Object to store |
| string | $action | Action code ('BILL_VALIDATE', 'BILL_SENTBYMAIL', ...) |
| float | int | $amounts | amounts (incl tax) |
| ?User | $fuser | User object (forced) |
| float | int | null | $amounts_taxexcl | amounts (excl tax or null if not relevant) |
var CashControl $object
Definition at line 519 of file blockedlog.class.php.
References $mysoc, $object, dol_getIdFromCode(), dol_syslog(), dol_trunc(), dolGetFirstLineOfText(), getDolEntity(), string, Facture\TYPE_CREDIT_NOTE, and FactureFournisseur\TYPE_CREDIT_NOTE.