From b764993091455da7a96554668ac0036482068345 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Fri, 22 Aug 2014 10:59:52 +0200 Subject: [PATCH] AuthenticationException: extend IcingaException refs #6931 --- .../Authentication/Backend/DbUserBackend.php | 11 +++---- .../Backend/LdapUserBackend.php | 32 +++++++------------ .../Exception/AuthenticationException.php | 4 +-- 3 files changed, 16 insertions(+), 31 deletions(-) diff --git a/library/Icinga/Authentication/Backend/DbUserBackend.php b/library/Icinga/Authentication/Backend/DbUserBackend.php index 5961028b3..95c99c346 100644 --- a/library/Icinga/Authentication/Backend/DbUserBackend.php +++ b/library/Icinga/Authentication/Backend/DbUserBackend.php @@ -73,12 +73,9 @@ class DbUserBackend extends UserBackend return ($row !== false) ? true : false; } catch (Exception $e) { throw new AuthenticationException( - sprintf( - 'Failed to authenticate user "%s" against backend "%s". An exception was thrown:', - $user->getUsername(), - $this->getName() - ), - 0, + 'Failed to authenticate user "%s" against backend "%s". An exception was thrown:', + $user->getUsername(), + $this->getName(), $e ); } @@ -125,4 +122,4 @@ class DbUserBackend extends UserBackend return ($row !== false) ? $row->count : 0; } -} \ No newline at end of file +} diff --git a/library/Icinga/Authentication/Backend/LdapUserBackend.php b/library/Icinga/Authentication/Backend/LdapUserBackend.php index fe80e900a..23a79781d 100644 --- a/library/Icinga/Authentication/Backend/LdapUserBackend.php +++ b/library/Icinga/Authentication/Backend/LdapUserBackend.php @@ -68,21 +68,17 @@ class LdapUserBackend extends UserBackend $result = $q->fetchRow(); if (! isset($result)) { throw new AuthenticationException( - sprintf( - 'No objects with objectClass="%s" in DN="%s" found.', - $this->userClass, - $this->conn->getDN() - ) + 'No objects with objectClass="%s" in DN="%s" found.', + $this->userClass, + $this->conn->getDN() ); } if (! isset($result->{$this->userNameAttribute})) { throw new AuthenticationException( - sprintf( - 'UserNameAttribute "%s" not existing in objectClass="%s"', - $this->userNameAttribute, - $this->userClass - ) + 'UserNameAttribute "%s" not existing in objectClass="%s"', + $this->userNameAttribute, + $this->userClass ); } } @@ -121,11 +117,8 @@ class LdapUserBackend extends UserBackend } catch (AuthenticationException $e) { // Authentication not possible throw new AuthenticationException( - sprintf( - 'Authentication against backend "%s" not possible: ', - $this->getName() - ), - 0, + 'Authentication against backend "%s" not possible: ', + $this->getName(), $e ); } @@ -141,12 +134,9 @@ class LdapUserBackend extends UserBackend } catch (LdapException $e) { // Error during authentication of this specific user throw new AuthenticationException( - sprintf( - 'Failed to authenticate user "%s" against backend "%s". An exception was thrown:', - $user->getUsername(), - $this->getName() - ), - 0, + 'Failed to authenticate user "%s" against backend "%s". An exception was thrown:', + $user->getUsername(), + $this->getName(), $e ); } diff --git a/library/Icinga/Exception/AuthenticationException.php b/library/Icinga/Exception/AuthenticationException.php index 91180b796..ebed296e4 100644 --- a/library/Icinga/Exception/AuthenticationException.php +++ b/library/Icinga/Exception/AuthenticationException.php @@ -4,11 +4,9 @@ namespace Icinga\Exception; -use RuntimeException; - /** * Exception thrown if an error occurs during authentication */ -class AuthenticationException extends RuntimeException +class AuthenticationException extends IcingaException { }