diff --git a/application/src/Domain/SecureLoadManagement/SecureSourceLoader.php b/application/src/Domain/SecureLoadManagement/SecureSourceLoader.php index 81b0965..fef0caf 100644 --- a/application/src/Domain/SecureLoadManagement/SecureSourceLoader.php +++ b/application/src/Domain/SecureLoadManagement/SecureSourceLoader.php @@ -4,9 +4,9 @@ namespace App\Domain\SecureLoadManagement; use App\Entity\Source\SourceInterface; use App\Entity\Meta\RightInterface; -use App\Domain\LawManagement\LawPermissionCheckerService; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Doctrine\Common\Persistence\ObjectRepository; +use App\Domain\SecureManagement\SecureSourceChecker; /** * @author kevinfrantz @@ -52,14 +52,6 @@ final class SecureSourceLoader implements SecureSourceLoaderInterface } } - private function hasPermission(SourceInterface $source): bool - { - $requestedRight = $this->getClonedRightWithModifiedSource($source); - $law = new LawPermissionCheckerService($source->getLaw()); - - return $law->hasPermission($requestedRight); - } - public function __construct(ObjectRepository $sourceRepository, RightInterface $requestedRight) { $this->sourceRepository = $sourceRepository; @@ -74,7 +66,9 @@ final class SecureSourceLoader implements SecureSourceLoaderInterface public function getSource(): SourceInterface { $source = $this->loadSource(); - if ($this->hasPermission($source)) { + $requestedRight = $this->getClonedRightWithModifiedSource($source); + $secureSourceChecker = new SecureSourceChecker($source); + if ($secureSourceChecker->hasPermission($requestedRight)) { return $source; } throw new AccessDeniedHttpException(); diff --git a/application/src/Domain/SecureManagement/SecureSourceChecker.php b/application/src/Domain/SecureManagement/SecureSourceChecker.php new file mode 100644 index 0000000..90ebd9f --- /dev/null +++ b/application/src/Domain/SecureManagement/SecureSourceChecker.php @@ -0,0 +1,33 @@ +source = $source; + } + + public function hasPermission(RightInterface $requestedRight): bool + { + $law = new LawPermissionCheckerService($this->source->getLaw()); + + return $law->hasPermission($requestedRight); + } +} diff --git a/application/src/Domain/SecureManagement/SecureSourceCheckerInterface.php b/application/src/Domain/SecureManagement/SecureSourceCheckerInterface.php new file mode 100644 index 0000000..4738901 --- /dev/null +++ b/application/src/Domain/SecureManagement/SecureSourceCheckerInterface.php @@ -0,0 +1,18 @@ +