Commit 3a81a953 authored by Cyril Vazquez's avatar Cyril Vazquez
Browse files

Merge branch 'fix/14879_hash_deposit_verification' into 'develop'

Fix/14879 hash deposit verification

See merge request !15
parents c6534c86 52b07278
......@@ -87,29 +87,6 @@ class digitalSafe
$account = $this->accountController->get($accountToken->accountId);
$replyMessage->accountName = $account->accountName;
foreach ($archive->digitalResources as $resource) {
if ((isset($resource->hash) && !is_null($resource->hash))
&& (isset($resource->hashAlgorithm)
&& !is_null($resource->hashAlgorithm))
) {
try {
$this->checkHash($resource->handler, $resource->hash, $resource->hashAlgorithm);
} catch (\Exception $e) {
throw $this->getThrowable($e->getMessage(), 400, $replyMessage);
}
$this->getHash($resource);
continue;
}
if (!isset($resource->hash) && !isset($resource->hashAlgorithm)) {
$this->getHash($resource);
continue;
}
throw $this->getThrowable("Hash or hash algorithm missing", 401, $replyMessage);
}
try {
$archive = \laabs::castMessage($archive, 'recordsManagement/archive');
$archiveId = $this->archiveController->receive($archive, false);
......@@ -679,32 +656,6 @@ class digitalSafe
}
}
/**
* Calculate hash if necessary
*
* @param object $resource
*/
protected function getHash($resource)
{
$hashAlgorithm = \laabs::configuration('recordsManagement')['hashAlgorithm'];
if ($resource->hashAlgorithm == $hashAlgorithm) {
return;
}
$resource->hashAlgorithm = $hashAlgorithm;
if (is_string($resource->handler)) {
$resource->hash = strtolower(hash($hashAlgorithm, base64_decode($resource->handler)));
} else {
$tmpfile = \laabs::getTmpDir().DIRECTORY_SEPARATOR.rand();
file_put_contents($tmpfile, base64_decode(stream_get_contents($resource->handler)));
rewind($resource->handler);
$resource->hash = strtolower(hash_file($hashAlgorithm, $tmpfile));
unlink($tmpfile);
}
}
/**
* log event in lifecycle journal
*
......
......@@ -5,7 +5,7 @@
@include menu.ini
; Default max result in search screens
maxResults = 200
maxResults = 500
; Public archive mode
publicArchives = false
......@@ -185,7 +185,7 @@ blacklistUserStories = "[
; 'lifeTime' Token validity in seconds (defaults 3600)
csrfWhiteList = "['user/login', 'user/password', 'user/prompt', 'user/logout']"
csrfConfig = '{
"cookieName" : "CSRF",
"cookieName" : "Csrf",
"tokenLength" : 32
}'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment