diff --git a/www/saml2/idp/SSOService.php b/www/saml2/idp/SSOService.php
index 08583925d5c802744dff5fc8bef90a49d2fb2f56..c96c3531711df4a222bc0e4cc8beb506e047a431 100644
--- a/www/saml2/idp/SSOService.php
+++ b/www/saml2/idp/SSOService.php
@@ -297,7 +297,7 @@ if($needAuth && !$isPassive) {
 				}
 				$t->data['sppp'] = $privacypolicy;
 
-				switch($config->getString('consent_autofocus', NULL)) {
+				switch($config->getValueValidate('consent_autofocus', array(NULL, 'yes', 'no'), NULL)) {
 				case NULL:
 					break;
 				case 'yes':
@@ -306,9 +306,6 @@ if($needAuth && !$isPassive) {
 				case 'no':
 					$t->data['autofocus'] = 'nobutton';
 					break;
-				default:
-					throw new Exception('Invalid value for the consent_autofocus option.' .
-						' Should be one of NULL, \'yes\' or \'no\'.');
 				}
 
 				$t->show();
diff --git a/www/shib13/idp/SSOService.php b/www/shib13/idp/SSOService.php
index 7a0456fa05f754c50cb8d3b98598e0525cb72ada..34baa010eace07d34e6b3f7d4bf000ebf1b159a3 100644
--- a/www/shib13/idp/SSOService.php
+++ b/www/shib13/idp/SSOService.php
@@ -209,7 +209,7 @@ if (!$session->isAuthenticated($authority) ) {
 				}
 				$t->data['sppp'] = $privacypolicy;
 
-				switch($config->getString('consent_autofocus', NULL)) {
+				switch($config->getValueValidate('consent_autofocus', array(NULL, 'yes', 'no'), NULL)) {
 				case NULL:
 					break;
 				case 'yes':
@@ -218,9 +218,6 @@ if (!$session->isAuthenticated($authority) ) {
 				case 'no':
 					$t->data['autofocus'] = 'nobutton';
 					break;
-				default:
-					throw new Exception('Invalid value for the consent_autofocus option.' .
-						' Should be one of NULL, \'yes\' or \'no\'.');
 				}
 
 				$t->show();