2016-03-24 15:29:39 +01:00
|
|
|
<?php
|
|
|
|
/* Icinga Web 2 | (c) 2016 Icinga Development Team | GPLv2+ */
|
|
|
|
|
|
|
|
namespace Icinga\Authentication;
|
|
|
|
|
|
|
|
class Role
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Name of the role
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $name;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Permissions of the role
|
|
|
|
*
|
|
|
|
* @var string[]
|
|
|
|
*/
|
|
|
|
protected $permissions = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restrictions of the role
|
|
|
|
*
|
|
|
|
* @var string[]
|
|
|
|
*/
|
|
|
|
protected $restrictions = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the name of the role
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the name of the role
|
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
*
|
|
|
|
* @return $this
|
|
|
|
*/
|
|
|
|
public function setName($name)
|
|
|
|
{
|
|
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2016-03-24 16:11:31 +01:00
|
|
|
/**
|
2016-03-29 11:19:03 +02:00
|
|
|
* Get the permissions of the role
|
2016-03-24 16:11:31 +01:00
|
|
|
*
|
2016-03-29 11:19:03 +02:00
|
|
|
* @return string[]
|
2016-03-24 16:11:31 +01:00
|
|
|
*/
|
2016-03-29 11:19:03 +02:00
|
|
|
public function getPermissions()
|
2016-03-24 16:11:31 +01:00
|
|
|
{
|
2016-03-29 11:19:03 +02:00
|
|
|
return $this->permissions;
|
2016-03-24 16:11:31 +01:00
|
|
|
}
|
|
|
|
|
2016-03-24 15:29:39 +01:00
|
|
|
/**
|
2016-03-29 11:19:03 +02:00
|
|
|
* Set the permissions of the role
|
2016-03-24 15:29:39 +01:00
|
|
|
*
|
2016-03-29 11:19:03 +02:00
|
|
|
* @param string[] $permissions
|
|
|
|
*
|
|
|
|
* @return $this
|
2016-03-24 15:29:39 +01:00
|
|
|
*/
|
2016-03-29 11:19:03 +02:00
|
|
|
public function setPermissions(array $permissions)
|
2016-03-24 15:29:39 +01:00
|
|
|
{
|
2016-03-29 11:19:03 +02:00
|
|
|
$this->permissions = $permissions;
|
|
|
|
return $this;
|
2016-03-24 15:29:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the restrictions of the role
|
|
|
|
*
|
|
|
|
* @param string $name Optional name of the restriction
|
|
|
|
*
|
|
|
|
* @return string[]|null
|
|
|
|
*/
|
|
|
|
public function getRestrictions($name = null)
|
|
|
|
{
|
|
|
|
$restrictions = $this->restrictions;
|
|
|
|
|
|
|
|
if ($name === null) {
|
|
|
|
return $restrictions;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($restrictions[$name])) {
|
|
|
|
return $restrictions[$name];
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2016-03-29 11:19:03 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the restrictions of the role
|
|
|
|
*
|
|
|
|
* @param string[] $restrictions
|
|
|
|
*
|
|
|
|
* @return $this
|
|
|
|
*/
|
|
|
|
public function setRestrictions(array $restrictions)
|
|
|
|
{
|
|
|
|
$this->restrictions = $restrictions;
|
|
|
|
return $this;
|
|
|
|
}
|
2016-03-24 15:29:39 +01:00
|
|
|
}
|