From bbcf369347f3af4300927994e36db18ee6cf4c4b Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Fri, 21 Sep 2018 20:26:03 +0200 Subject: [PATCH] Added security draft --- .../Facade/Security/AbstractSourceFasade.php | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 application/src/Structur/Facade/Security/AbstractSourceFasade.php diff --git a/application/src/Structur/Facade/Security/AbstractSourceFasade.php b/application/src/Structur/Facade/Security/AbstractSourceFasade.php new file mode 100644 index 0000000..2a99960 --- /dev/null +++ b/application/src/Structur/Facade/Security/AbstractSourceFasade.php @@ -0,0 +1,71 @@ +source = $source; + } + + public function setId(int $id): void + { + throw \Exception("The id can't be changed!"); + } + + public function setNode(NodeInterface $node): void + { + throw \Exception("The node can't be changed!"); + } + + public function getId(): int + { + if($this->isGranted(RightType::READ)){ + return $source->getId(); + } + } + + public function getNode(): NodeInterface + { + if($this->isGranted(RightType::READ,LayerType::NODE)){ + return $source->getId(); + } + } + + protected function isGranted(string $right,string $layer): bool + { + return $this->getNode() + ->getLaw() + ->isGranted(self::$user->getSource() + ->getNode(), self::$layer, $right); + } +} +