1<?php 2/* Icinga Web 2 | (c) 2016 Icinga Development Team | GPLv2+ */ 3 4namespace Icinga\Authentication; 5 6class Role 7{ 8 /** 9 * Name of the role 10 * 11 * @var string 12 */ 13 protected $name; 14 15 /** 16 * Permissions of the role 17 * 18 * @var string[] 19 */ 20 protected $permissions = array(); 21 22 /** 23 * Restrictions of the role 24 * 25 * @var string[] 26 */ 27 protected $restrictions = array(); 28 29 /** 30 * Get the name of the role 31 * 32 * @return string 33 */ 34 public function getName() 35 { 36 return $this->name; 37 } 38 39 /** 40 * Set the name of the role 41 * 42 * @param string $name 43 * 44 * @return $this 45 */ 46 public function setName($name) 47 { 48 $this->name = $name; 49 return $this; 50 } 51 52 /** 53 * Get the permissions of the role 54 * 55 * @return string[] 56 */ 57 public function getPermissions() 58 { 59 return $this->permissions; 60 } 61 62 /** 63 * Set the permissions of the role 64 * 65 * @param string[] $permissions 66 * 67 * @return $this 68 */ 69 public function setPermissions(array $permissions) 70 { 71 $this->permissions = $permissions; 72 return $this; 73 } 74 75 /** 76 * Get the restrictions of the role 77 * 78 * @param string $name Optional name of the restriction 79 * 80 * @return string[]|null 81 */ 82 public function getRestrictions($name = null) 83 { 84 $restrictions = $this->restrictions; 85 86 if ($name === null) { 87 return $restrictions; 88 } 89 90 if (isset($restrictions[$name])) { 91 return $restrictions[$name]; 92 } 93 94 return null; 95 } 96 97 /** 98 * Set the restrictions of the role 99 * 100 * @param string[] $restrictions 101 * 102 * @return $this 103 */ 104 public function setRestrictions(array $restrictions) 105 { 106 $this->restrictions = $restrictions; 107 return $this; 108 } 109} 110