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;
} 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;
}
}
}

View File

@ -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
);
}

View File

@ -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
{
}