icingaweb2-module-director/library/Director/Util.php

45 lines
857 B
PHP
Raw Normal View History

2015-06-23 14:37:23 +02:00
<?php
namespace Icinga\Module\Director;
2015-07-30 09:04:42 +02:00
use Icinga\Authentication\Manager;
2015-06-23 14:37:23 +02:00
use Zend_Db_Expr;
class Util
{
2015-07-30 09:04:42 +02:00
protected static $auth;
2015-06-23 14:37:23 +02:00
public static function pgBinEscape($binary)
{
2015-06-23 16:45:25 +02:00
return new \Zend_Db_Expr("'\\x" . bin2hex($binary) . "'");
2015-06-23 14:37:23 +02:00
}
public static function hex2binary($bin)
{
return pack('H*', $bin);
}
public static function binary2hex($hex)
{
2015-06-23 14:38:37 +02:00
return current(unpack('H*', $hex));
2015-06-23 14:37:23 +02:00
}
2015-07-30 09:04:42 +02:00
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);
}
2015-06-23 14:37:23 +02:00
}