Util: add auth helper methods

This commit is contained in:
Thomas Gelf 2015-07-30 09:04:42 +02:00
parent 3c5a825f04
commit 0bc2fbe9c7

View File

@ -2,10 +2,13 @@
namespace Icinga\Module\Director;
use Icinga\Authentication\Manager;
use Zend_Db_Expr;
class Util
{
protected static $auth;
public static function pgBinEscape($binary)
{
return new \Zend_Db_Expr("'\\x" . bin2hex($binary) . "'");
@ -20,4 +23,22 @@ class Util
{
return current(unpack('H*', $hex));
}
public static function auth()
{
if (self::$auth === null) {
self::$auth = Manager::getInstance();
}
return self::$auth;
}
public static function hasPermission($name)
{
return self::auth()->hasPermission($name);
}
public static function getRestrictions($name)
{
return self::auth()->getRestrictions($name);
}
}