AuthenticationException: extend IcingaException

refs #6931
This commit is contained in:
Alexander Klimov 2014-08-22 10:59:52 +02:00
parent b55a313146
commit b764993091
3 changed files with 16 additions and 31 deletions

View File

@ -73,12 +73,9 @@ class DbUserBackend extends UserBackend
return ($row !== false) ? true : false; return ($row !== false) ? true : false;
} catch (Exception $e) { } catch (Exception $e) {
throw new AuthenticationException( throw new AuthenticationException(
sprintf( 'Failed to authenticate user "%s" against backend "%s". An exception was thrown:',
'Failed to authenticate user "%s" against backend "%s". An exception was thrown:', $user->getUsername(),
$user->getUsername(), $this->getName(),
$this->getName()
),
0,
$e $e
); );
} }
@ -125,4 +122,4 @@ class DbUserBackend extends UserBackend
return ($row !== false) ? $row->count : 0; return ($row !== false) ? $row->count : 0;
} }
} }

View File

@ -68,21 +68,17 @@ class LdapUserBackend extends UserBackend
$result = $q->fetchRow(); $result = $q->fetchRow();
if (! isset($result)) { if (! isset($result)) {
throw new AuthenticationException( throw new AuthenticationException(
sprintf( 'No objects with objectClass="%s" in DN="%s" found.',
'No objects with objectClass="%s" in DN="%s" found.', $this->userClass,
$this->userClass, $this->conn->getDN()
$this->conn->getDN()
)
); );
} }
if (! isset($result->{$this->userNameAttribute})) { if (! isset($result->{$this->userNameAttribute})) {
throw new AuthenticationException( throw new AuthenticationException(
sprintf( 'UserNameAttribute "%s" not existing in objectClass="%s"',
'UserNameAttribute "%s" not existing in objectClass="%s"', $this->userNameAttribute,
$this->userNameAttribute, $this->userClass
$this->userClass
)
); );
} }
} }
@ -121,11 +117,8 @@ class LdapUserBackend extends UserBackend
} catch (AuthenticationException $e) { } catch (AuthenticationException $e) {
// Authentication not possible // Authentication not possible
throw new AuthenticationException( throw new AuthenticationException(
sprintf( 'Authentication against backend "%s" not possible: ',
'Authentication against backend "%s" not possible: ', $this->getName(),
$this->getName()
),
0,
$e $e
); );
} }
@ -141,12 +134,9 @@ class LdapUserBackend extends UserBackend
} catch (LdapException $e) { } catch (LdapException $e) {
// Error during authentication of this specific user // Error during authentication of this specific user
throw new AuthenticationException( throw new AuthenticationException(
sprintf( 'Failed to authenticate user "%s" against backend "%s". An exception was thrown:',
'Failed to authenticate user "%s" against backend "%s". An exception was thrown:', $user->getUsername(),
$user->getUsername(), $this->getName(),
$this->getName()
),
0,
$e $e
); );
} }

View File

@ -4,11 +4,9 @@
namespace Icinga\Exception; namespace Icinga\Exception;
use RuntimeException;
/** /**
* Exception thrown if an error occurs during authentication * Exception thrown if an error occurs during authentication
*/ */
class AuthenticationException extends RuntimeException class AuthenticationException extends IcingaException
{ {
} }