From 8193955ccad4e252469aa909469ce9bb2a1e23e6 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Thu, 15 Mar 2012 13:31:30 +0000 Subject: [PATCH] consent: Handle errors when accessing from consent database. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3046 44740490-163a-0410-bde0-09ae8108e29a --- modules/consent/lib/Auth/Process/Consent.php | 27 ++++++++++++-------- modules/consent/www/getconsent.php | 6 ++++- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/modules/consent/lib/Auth/Process/Consent.php b/modules/consent/lib/Auth/Process/Consent.php index eff89c438..6e87ca038 100644 --- a/modules/consent/lib/Auth/Process/Consent.php +++ b/modules/consent/lib/Auth/Process/Consent.php @@ -216,19 +216,24 @@ class sspmod_consent_Auth_Process_Consent extends SimpleSAML_Auth_ProcessingFilt 'Consent: hasConsent() [' . $userId . '|' . $targetedId . '|' . $attributeSet . ']' ); - - if ($this->_store->hasConsent($userId, $targetedId, $attributeSet)) { - // Consent already given - SimpleSAML_Logger::stats('Consent: Consent found'); - return; - } - SimpleSAML_Logger::stats('Consent: Consent notfound'); + try { + if ($this->_store->hasConsent($userId, $targetedId, $attributeSet)) { + // Consent already given + SimpleSAML_Logger::stats('Consent: Consent found'); + return; + } - $state['consent:store'] = $this->_store; - $state['consent:store.userId'] = $userId; - $state['consent:store.destination'] = $targetedId; - $state['consent:store.attributeSet'] = $attributeSet; + SimpleSAML_Logger::stats('Consent: Consent notfound'); + + $state['consent:store'] = $this->_store; + $state['consent:store.userId'] = $userId; + $state['consent:store.destination'] = $targetedId; + $state['consent:store.attributeSet'] = $attributeSet; + } catch (Exception $e) { + SimpleSAML_Logger::error('Consent: Error reading from storage: ' . $e->getMessage()); + SimpleSAML_Logger::stats('Consent: Failed'); + } } else { SimpleSAML_Logger::stats('Consent: No storage'); } diff --git a/modules/consent/www/getconsent.php b/modules/consent/www/getconsent.php index 949630dfe..84acd064f 100644 --- a/modules/consent/www/getconsent.php +++ b/modules/consent/www/getconsent.php @@ -56,7 +56,11 @@ if (array_key_exists('yes', $_REQUEST)) { 'Consent - saveConsent() : [' . $userId . '|' . $targetedId . '|' . $attributeSet . ']' ); - $store->saveConsent($userId, $targetedId, $attributeSet); + try { + $store->saveConsent($userId, $targetedId, $attributeSet); + } catch (Exception $e) { + SimpleSAML_Logger::error('Consent: Error writing to storage: ' . $e->getMessage()); + } } SimpleSAML_Auth_ProcessingChain::resumeProcessing($state); -- GitLab