From 7ad85181143a1de51f1ca929a1419d3f0e18fc95 Mon Sep 17 00:00:00 2001 From: Netkas Date: Mon, 21 Aug 2023 20:46:00 -0400 Subject: [PATCH] - Removed unused exception `AccessDeniedException` in `\ncc\Exceptions` in favor of `AuthenticationException` --- CHANGELOG.md | 1 + src/ncc/CLI/HelpMenu.php | 2 - src/ncc/CLI/Management/ConfigMenu.php | 2 - .../ComposerSourceBuiltin.php | 8 +--- .../Classes/NccExtension/PackageCompiler.php | 3 -- src/ncc/Classes/NccExtension/Runner.php | 8 ++-- src/ncc/Classes/PerlExtension/PerlRunner.php | 4 +- src/ncc/Classes/PhpExtension/PhpCompiler.php | 5 +-- src/ncc/Classes/PhpExtension/PhpInstaller.php | 1 - src/ncc/Classes/PhpExtension/PhpRunner.php | 2 - .../Classes/PythonExtension/Python2Runner.php | 2 - .../Classes/PythonExtension/Python3Runner.php | 4 +- .../Classes/PythonExtension/PythonRunner.php | 2 - src/ncc/Enums/ExceptionCodes.php | 6 --- src/ncc/Exceptions/AccessDeniedException.php | 39 ----------------- .../Exceptions/AuthenticationException.php | 42 +++++++++---------- src/ncc/Interfaces/CompilerInterface.php | 5 --- src/ncc/Interfaces/RunnerInterface.php | 2 - src/ncc/Managers/ConfigurationManager.php | 6 +-- src/ncc/Managers/CredentialManager.php | 9 ++-- src/ncc/Managers/ExecutionPointerManager.php | 12 ++---- src/ncc/Managers/PackageLockManager.php | 9 ++-- src/ncc/Managers/PackageManager.php | 12 ++---- src/ncc/Managers/ProjectManager.php | 2 - src/ncc/Managers/SymlinkManager.php | 34 ++++++++++----- src/ncc/Utilities/Functions.php | 5 +-- src/ncc/ncc.php | 4 -- 27 files changed, 72 insertions(+), 159 deletions(-) delete mode 100644 src/ncc/Exceptions/AccessDeniedException.php diff --git a/CHANGELOG.md b/CHANGELOG.md index a2976aa..411c7bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -147,6 +147,7 @@ features. - Removed unused exception `ProjectConfigurationNotFoundException` in `\ncc\Exceptions` in favor of `ConfigurationException` - Removed unused exception `UndefinedExecutionPolicyExpection` in `\ncc\Exceptions` in favor of `ConfigurationException` - Removed unused exception `InvalidExecutionPolicyName` in `\ncc\Exceptions` (not used) + - Removed unused exception `AccessDeniedException` in `\ncc\Exceptions` in favor of `AuthenticationException` diff --git a/src/ncc/CLI/HelpMenu.php b/src/ncc/CLI/HelpMenu.php index 2efd9c8..a1eb9b9 100644 --- a/src/ncc/CLI/HelpMenu.php +++ b/src/ncc/CLI/HelpMenu.php @@ -22,7 +22,6 @@ namespace ncc\CLI; - use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\IOException; use ncc\Objects\CliHelpSection; use ncc\Utilities\Console; @@ -35,7 +34,6 @@ * * @param $args * @return void - * @throws AccessDeniedException * @throws IOException */ public static function start($args): void diff --git a/src/ncc/CLI/Management/ConfigMenu.php b/src/ncc/CLI/Management/ConfigMenu.php index be365bb..5e4a203 100644 --- a/src/ncc/CLI/Management/ConfigMenu.php +++ b/src/ncc/CLI/Management/ConfigMenu.php @@ -24,7 +24,6 @@ use JsonException; use ncc\Enums\Scopes; - use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\IOException; use ncc\Managers\ConfigurationManager; use ncc\Objects\CliHelpSection; @@ -40,7 +39,6 @@ * * @param $args * @return void - * @throws AccessDeniedException * @throws IOException */ public static function start($args): void diff --git a/src/ncc/Classes/ComposerExtension/ComposerSourceBuiltin.php b/src/ncc/Classes/ComposerExtension/ComposerSourceBuiltin.php index d6c891b..9dc7e60 100644 --- a/src/ncc/Classes/ComposerExtension/ComposerSourceBuiltin.php +++ b/src/ncc/Classes/ComposerExtension/ComposerSourceBuiltin.php @@ -32,7 +32,6 @@ use ncc\Enums\LogLevel; use ncc\Enums\Scopes; use ncc\CLI\Main; - use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\BuildException; use ncc\Exceptions\ComposerDisabledException; use ncc\Exceptions\ComposerException; @@ -79,7 +78,6 @@ * * @param RemotePackageInput $packageInput * @return string - * @throws AccessDeniedException * @throws BuildException * @throws ComposerDisabledException * @throws ComposerException @@ -119,7 +117,6 @@ * * @param string $path * @return string - * @throws AccessDeniedException * @throws BuildException * @throws ComposerDisabledException * @throws ComposerException @@ -194,15 +191,14 @@ /** * @param string $composer_lock_path * @return array - * @throws AccessDeniedException * @throws BuildException + * @throws ConfigurationException * @throws IOException * @throws MalformedJsonException + * @throws NotSupportedException * @throws PackageNotFoundException * @throws PackagePreparationFailedException * @throws PathNotFoundException - * @throws ConfigurationException - * @throws NotSupportedException */ private static function compilePackages(string $composer_lock_path): array { diff --git a/src/ncc/Classes/NccExtension/PackageCompiler.php b/src/ncc/Classes/NccExtension/PackageCompiler.php index 3f18be3..cbd6bb6 100644 --- a/src/ncc/Classes/NccExtension/PackageCompiler.php +++ b/src/ncc/Classes/NccExtension/PackageCompiler.php @@ -31,7 +31,6 @@ use ncc\Classes\ComposerExtension\ComposerSourceBuiltin; use ncc\Classes\PhpExtension\PhpCompiler; use ncc\CLI\Main; - use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\BuildException; use ncc\Exceptions\ConfigurationException; use ncc\Exceptions\IOException; @@ -58,7 +57,6 @@ * @param ProjectManager $manager * @param string $build_configuration * @return string - * @throws AccessDeniedException * @throws BuildException * @throws ConfigurationException * @throws IOException @@ -155,7 +153,6 @@ * @param string $path * @param ProjectConfiguration $configuration * @return array - * @throws AccessDeniedException * @throws IOException * @throws PathNotFoundException * @throws RunnerExecutionException diff --git a/src/ncc/Classes/NccExtension/Runner.php b/src/ncc/Classes/NccExtension/Runner.php index a2b3739..de39aa3 100644 --- a/src/ncc/Classes/NccExtension/Runner.php +++ b/src/ncc/Classes/NccExtension/Runner.php @@ -23,7 +23,7 @@ namespace ncc\Classes\NccExtension; use ncc\Enums\Scopes; - use ncc\Exceptions\AccessDeniedException; + use ncc\Exceptions\AuthenticationException; use ncc\Exceptions\IOException; use ncc\Exceptions\NoAvailableUnitsException; use ncc\Exceptions\PathNotFoundException; @@ -41,17 +41,17 @@ * @param string $version * @param ExecutionUnit $unit * @return void - * @throws AccessDeniedException + * @throws AuthenticationException * @throws IOException * @throws NoAvailableUnitsException - * @throws RunnerExecutionException * @throws PathNotFoundException + * @throws RunnerExecutionException */ public static function temporaryExecute(string $package, string $version, ExecutionUnit $unit): void { if(Resolver::resolveScope() !== Scopes::SYSTEM) { - throw new AccessDeniedException('Cannot temporarily execute a unit with insufficient permissions'); + throw new AuthenticationException('Cannot temporarily execute a unit with insufficient permissions'); } $ExecutionPointerManager = new ExecutionPointerManager(); diff --git a/src/ncc/Classes/PerlExtension/PerlRunner.php b/src/ncc/Classes/PerlExtension/PerlRunner.php index 5269c86..96f5d0e 100644 --- a/src/ncc/Classes/PerlExtension/PerlRunner.php +++ b/src/ncc/Classes/PerlExtension/PerlRunner.php @@ -22,7 +22,6 @@ namespace ncc\Classes\PerlExtension; - use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\IOException; use ncc\Exceptions\PathNotFoundException; use ncc\Interfaces\RunnerInterface; @@ -38,9 +37,8 @@ * @param string $path * @param ExecutionPolicy $policy * @return ExecutionUnit - * @throws PathNotFoundException - * @throws AccessDeniedException * @throws IOException + * @throws PathNotFoundException */ public static function processUnit(string $path, ExecutionPolicy $policy): ExecutionUnit { diff --git a/src/ncc/Classes/PhpExtension/PhpCompiler.php b/src/ncc/Classes/PhpExtension/PhpCompiler.php index 8f9a0c6..5e6a0da 100644 --- a/src/ncc/Classes/PhpExtension/PhpCompiler.php +++ b/src/ncc/Classes/PhpExtension/PhpCompiler.php @@ -32,7 +32,6 @@ use ncc\Enums\DependencySourceType; use ncc\Enums\Options\BuildConfigurationValues; use ncc\Classes\NccExtension\PackageCompiler; - use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\BuildException; use ncc\Exceptions\ConfigurationException; use ncc\Exceptions\IOException; @@ -330,7 +329,6 @@ * Executes the compile process in the correct order and returns the finalized Package object * * @return Package|null - * @throws AccessDeniedException * @throws BuildException * @throws IOException * @throws PathNotFoundException @@ -474,10 +472,9 @@ /** * @return void - * @throws AccessDeniedException * @throws IOException - * @throws RunnerExecutionException * @throws PathNotFoundException + * @throws RunnerExecutionException */ public function compileExecutionPolicies(): void { diff --git a/src/ncc/Classes/PhpExtension/PhpInstaller.php b/src/ncc/Classes/PhpExtension/PhpInstaller.php index 45451aa..b65847b 100644 --- a/src/ncc/Classes/PhpExtension/PhpInstaller.php +++ b/src/ncc/Classes/PhpExtension/PhpInstaller.php @@ -29,7 +29,6 @@ use Exception; use ncc\Enums\ComponentDataType; use ncc\Enums\ComponentFileExtensions; - use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\ComponentChecksumException; use ncc\Exceptions\ComponentDecodeException; use ncc\Exceptions\IOException; diff --git a/src/ncc/Classes/PhpExtension/PhpRunner.php b/src/ncc/Classes/PhpExtension/PhpRunner.php index 2e184df..a740a09 100644 --- a/src/ncc/Classes/PhpExtension/PhpRunner.php +++ b/src/ncc/Classes/PhpExtension/PhpRunner.php @@ -22,7 +22,6 @@ namespace ncc\Classes\PhpExtension; - use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\IOException; use ncc\Exceptions\PathNotFoundException; use ncc\Interfaces\RunnerInterface; @@ -36,7 +35,6 @@ * @param string $path * @param ExecutionPolicy $policy * @return ExecutionUnit - * @throws AccessDeniedException * @throws IOException * @throws PathNotFoundException */ diff --git a/src/ncc/Classes/PythonExtension/Python2Runner.php b/src/ncc/Classes/PythonExtension/Python2Runner.php index ab85c4e..9b366fb 100644 --- a/src/ncc/Classes/PythonExtension/Python2Runner.php +++ b/src/ncc/Classes/PythonExtension/Python2Runner.php @@ -22,7 +22,6 @@ namespace ncc\Classes\PythonExtension; - use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\IOException; use ncc\Exceptions\PathNotFoundException; use ncc\Interfaces\RunnerInterface; @@ -38,7 +37,6 @@ * @param string $path * @param ExecutionPolicy $policy * @return ExecutionUnit - * @throws AccessDeniedException * @throws IOException * @throws PathNotFoundException */ diff --git a/src/ncc/Classes/PythonExtension/Python3Runner.php b/src/ncc/Classes/PythonExtension/Python3Runner.php index 03e8b82..54515cf 100644 --- a/src/ncc/Classes/PythonExtension/Python3Runner.php +++ b/src/ncc/Classes/PythonExtension/Python3Runner.php @@ -22,7 +22,6 @@ namespace ncc\Classes\PythonExtension; - use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\IOException; use ncc\Exceptions\PathNotFoundException; use ncc\Interfaces\RunnerInterface; @@ -38,9 +37,8 @@ * @param string $path * @param ExecutionPolicy $policy * @return ExecutionUnit - * @throws PathNotFoundException - * @throws AccessDeniedException * @throws IOException + * @throws PathNotFoundException */ public static function processUnit(string $path, ExecutionPolicy $policy): ExecutionUnit { diff --git a/src/ncc/Classes/PythonExtension/PythonRunner.php b/src/ncc/Classes/PythonExtension/PythonRunner.php index c37b044..eba68ca 100644 --- a/src/ncc/Classes/PythonExtension/PythonRunner.php +++ b/src/ncc/Classes/PythonExtension/PythonRunner.php @@ -22,7 +22,6 @@ namespace ncc\Classes\PythonExtension; - use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\IOException; use ncc\Exceptions\PathNotFoundException; use ncc\Interfaces\RunnerInterface; @@ -38,7 +37,6 @@ * @param string $path * @param ExecutionPolicy $policy * @return ExecutionUnit - * @throws AccessDeniedException * @throws IOException * @throws PathNotFoundException */ diff --git a/src/ncc/Enums/ExceptionCodes.php b/src/ncc/Enums/ExceptionCodes.php index a52354c..6a792cd 100644 --- a/src/ncc/Enums/ExceptionCodes.php +++ b/src/ncc/Enums/ExceptionCodes.php @@ -28,11 +28,6 @@ */ final class ExceptionCodes { - /** - * @see AccessDeniedException - */ - public const ACCESS_DENIED = -1704; - /** * @see MalformedJsonException */ @@ -212,7 +207,6 @@ * All the exception codes from NCC */ public const All = [ - self::ACCESS_DENIED, self::MALFORMED_JSON, self::RUNTIME, self::CONSTANT_READ_ONLY, diff --git a/src/ncc/Exceptions/AccessDeniedException.php b/src/ncc/Exceptions/AccessDeniedException.php deleted file mode 100644 index b809199..0000000 --- a/src/ncc/Exceptions/AccessDeniedException.php +++ /dev/null @@ -1,39 +0,0 @@ -configuration === null) @@ -142,7 +141,6 @@ * @param string $property * @param $value * @return bool - * @throws AccessDeniedException * @throws IOException */ public function updateProperty(string $property, $value): bool diff --git a/src/ncc/Managers/CredentialManager.php b/src/ncc/Managers/CredentialManager.php index e761cb9..d651b8a 100644 --- a/src/ncc/Managers/CredentialManager.php +++ b/src/ncc/Managers/CredentialManager.php @@ -27,7 +27,7 @@ use Exception; use ncc\Enums\Scopes; use ncc\Enums\Versions; - use ncc\Exceptions\AccessDeniedException; + use ncc\Exceptions\AuthenticationException; use ncc\Exceptions\IOException; use ncc\Exceptions\RuntimeException; use ncc\Objects\Vault; @@ -76,7 +76,6 @@ * Constructs the store file if it doesn't exist on the system (First initialization) * * @return void - * @throws AccessDeniedException * @throws IOException */ public function constructStore(): void @@ -92,7 +91,7 @@ if(Resolver::resolveScope() !== Scopes::SYSTEM) { - throw new AccessDeniedException('Cannot construct credentials store without system permissions'); + throw new AuthenticationException('Cannot construct credentials store without system permissions'); } $VaultObject = new Vault(); @@ -105,7 +104,6 @@ * Loads the vault from the disk * * @return void - * @throws AccessDeniedException * @throws IOException * @throws RuntimeException */ @@ -139,7 +137,6 @@ * Saves the vault to the disk * * @return void - * @throws AccessDeniedException * @throws IOException */ public function saveVault(): void @@ -148,7 +145,7 @@ if(Resolver::resolveScope() !== Scopes::SYSTEM) { - throw new AccessDeniedException('Cannot save credentials store without system permissions'); + throw new AuthenticationException('Cannot save credentials store without system permissions'); } IO::fwrite($this->store_path, ZiProto::encode($this->vault->toArray()), 0744); diff --git a/src/ncc/Managers/ExecutionPointerManager.php b/src/ncc/Managers/ExecutionPointerManager.php index ab0c9e3..a753499 100644 --- a/src/ncc/Managers/ExecutionPointerManager.php +++ b/src/ncc/Managers/ExecutionPointerManager.php @@ -35,7 +35,7 @@ use ncc\Classes\PythonExtension\Python2Runner; use ncc\Classes\PythonExtension\Python3Runner; use ncc\Classes\PythonExtension\PythonRunner; - use ncc\Exceptions\AccessDeniedException; + use ncc\Exceptions\AuthenticationException; use ncc\Exceptions\IOException; use ncc\Exceptions\NoAvailableUnitsException; use ncc\Exceptions\PathNotFoundException; @@ -165,7 +165,6 @@ * @param ExecutionUnit $unit * @param bool $temporary * @return void - * @throws AccessDeniedException * @throws IOException * @throws RunnerExecutionException * @throws PathNotFoundException @@ -174,7 +173,7 @@ { if(Resolver::resolveScope() !== Scopes::SYSTEM) { - throw new AccessDeniedException('Cannot add new ExecutionUnit \'' . $unit->execution_policy->name .'\' for ' . $package . ', insufficient permissions'); + throw new AuthenticationException('Cannot add new ExecutionUnit \'' . $unit->execution_policy->name .'\' for ' . $package . ', insufficient permissions'); } Console::outVerbose(sprintf('Adding new ExecutionUnit \'%s\' for %s', $unit->execution_policy->name, $package)); @@ -266,14 +265,13 @@ * @param string $version * @param string $name * @return bool - * @throws AccessDeniedException * @throws IOException */ public function removeUnit(string $package, string $version, string $name): bool { if(Resolver::resolveScope() !== Scopes::SYSTEM) { - throw new AccessDeniedException('Cannot remove ExecutionUnit \'' . $name .'\' for ' . $package . ', insufficient permissions'); + throw new AuthenticationException('Cannot remove ExecutionUnit \'' . $name .'\' for ' . $package . ', insufficient permissions'); } Console::outVerbose(sprintf('Removing ExecutionUnit \'%s\' for %s', $name, $package)); @@ -327,7 +325,6 @@ * @param string $package * @param string $version * @return array - * @throws AccessDeniedException * @throws IOException */ public function getUnits(string $package, string $version): array @@ -365,7 +362,6 @@ * @param string $name * @param array $args * @return int - * @throws AccessDeniedException * @throws IOException * @throws NoAvailableUnitsException * @throws RunnerExecutionException @@ -520,7 +516,6 @@ * @param Package $package * @param string $unit_name * @return void - * @throws AccessDeniedException * @throws IOException * @throws NoAvailableUnitsException * @throws PathNotFoundException @@ -581,7 +576,6 @@ * @param ExitHandle $exit_handler * @param Process|null $process * @return bool - * @throws AccessDeniedException * @throws IOException * @throws NoAvailableUnitsException * @throws RunnerExecutionException diff --git a/src/ncc/Managers/PackageLockManager.php b/src/ncc/Managers/PackageLockManager.php index 0032e32..90c087b 100644 --- a/src/ncc/Managers/PackageLockManager.php +++ b/src/ncc/Managers/PackageLockManager.php @@ -26,7 +26,7 @@ use Exception; use ncc\Enums\Scopes; - use ncc\Exceptions\AccessDeniedException; + use ncc\Exceptions\AuthenticationException; use ncc\Exceptions\IOException; use ncc\Exceptions\PackageLockException; use ncc\Objects\PackageLock; @@ -117,7 +117,7 @@ * Saves the PackageLock to disk * * @return void - * @throws AccessDeniedException + * @throws AuthenticationException * @throws PackageLockException */ public function save(): void @@ -132,7 +132,9 @@ } if(Resolver::resolveScope() !== Scopes::SYSTEM) - throw new AccessDeniedException('Cannot write to PackageLock, insufficient permissions'); + { + throw new AuthenticationException('Cannot write to PackageLock, insufficient permissions'); + } try { @@ -161,7 +163,6 @@ * Constructs the package lock file if it doesn't exist * * @return void - * @throws AccessDeniedException * @throws PackageLockException */ public function constructLockFile(): void diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index 018ca10..84f4dd0 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -38,7 +38,7 @@ use ncc\Classes\NccExtension\PackageCompiler; use ncc\Classes\PhpExtension\PhpInstaller; use ncc\CLI\Main; - use ncc\Exceptions\AccessDeniedException; + use ncc\Exceptions\AuthenticationException; use ncc\Exceptions\InstallationException; use ncc\Exceptions\IOException; use ncc\Exceptions\MissingDependencyException; @@ -103,7 +103,6 @@ * @param Entry|null $entry * @param array $options * @return string - * @throws AccessDeniedException * @throws IOException * @throws InstallationException * @throws MissingDependencyException @@ -121,7 +120,7 @@ { if(Resolver::resolveScope() !== Scopes::SYSTEM) { - throw new AccessDeniedException('Insufficient permission to install packages'); + throw new AuthenticationException('Insufficient permission to install packages'); } if(!file_exists($package_path) || !is_file($package_path) || !is_readable($package_path)) @@ -648,7 +647,6 @@ * @param Entry|null $entry * @param array $options * @return void - * @throws AccessDeniedException * @throws IOException * @throws InstallationException * @throws MissingDependencyException @@ -889,7 +887,6 @@ * @param string $package * @param string $version * @return void - * @throws AccessDeniedException * @throws IOException * @throws PackageLockException * @throws PackageNotFoundException @@ -900,7 +897,7 @@ { if(Resolver::resolveScope() !== Scopes::SYSTEM) { - throw new AccessDeniedException('Insufficient permission to uninstall packages'); + throw new AuthenticationException('Insufficient permission to uninstall packages'); } $version_entry = $this->getPackageVersion($package, $version); @@ -969,7 +966,6 @@ * * @param string $package * @return void - * @throws AccessDeniedException * @throws PackageLockException * @throws PackageNotFoundException * @throws VersionNotFoundException @@ -978,7 +974,7 @@ { if(Resolver::resolveScope() !== Scopes::SYSTEM) { - throw new AccessDeniedException('Insufficient permission to uninstall packages'); + throw new AuthenticationException('Insufficient permission to uninstall packages'); } $package_entry = $this->getPackage($package); diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index 9066e75..4ec17e0 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -28,7 +28,6 @@ use ncc\Enums\Options\BuildConfigurationValues; use ncc\Enums\Options\InitializeProjectOptions; use ncc\Classes\NccExtension\PackageCompiler; - use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\BuildException; use ncc\Exceptions\ConfigurationException; use ncc\Exceptions\IOException; @@ -279,7 +278,6 @@ * * @param string $build_configuration * @return string - * @throws AccessDeniedException * @throws BuildException * @throws ConfigurationException * @throws IOException diff --git a/src/ncc/Managers/SymlinkManager.php b/src/ncc/Managers/SymlinkManager.php index c34643a..0cc704e 100644 --- a/src/ncc/Managers/SymlinkManager.php +++ b/src/ncc/Managers/SymlinkManager.php @@ -26,7 +26,7 @@ use Exception; use ncc\Enums\Scopes; - use ncc\Exceptions\AccessDeniedException; + use ncc\Exceptions\AuthenticationException; use ncc\Exceptions\SymlinkException; use ncc\Objects\SymlinkDictionary\SymlinkEntry; use ncc\ThirdParty\Symfony\Filesystem\Filesystem; @@ -84,7 +84,7 @@ * Loads the symlink dictionary from the file * * @return void - * @throws AccessDeniedException + * @throws AuthenticationException * @throws SymlinkException */ public function load(): void @@ -129,13 +129,15 @@ * * @param bool $throw_exception * @return void - * @throws AccessDeniedException + * @throws AuthenticationException * @throws SymlinkException */ private function save(bool $throw_exception=true): void { if(Resolver::resolveScope() !== Scopes::SYSTEM) - throw new AccessDeniedException('Insufficient Permissions to write to the system symlink dictionary'); + { + throw new AuthenticationException('Insufficient Permissions to write to the system symlink dictionary'); + } Console::outDebug(sprintf('saving symlink dictionary to %s', $this->SymlinkDictionaryPath)); @@ -201,16 +203,20 @@ * @param string $package * @param string $unit * @return void - * @throws AccessDeniedException + * @throws AuthenticationException * @throws SymlinkException */ public function add(string $package, string $unit='main'): void { if(Resolver::resolveScope() !== Scopes::SYSTEM) - throw new AccessDeniedException('Insufficient Permissions to add to the system symlink dictionary'); + { + throw new AuthenticationException('Insufficient Permissions to add to the system symlink dictionary'); + } if($this->exists($package)) + { $this->remove($package); + } $entry = new SymlinkEntry(); $entry->Package = $package; @@ -225,16 +231,20 @@ * * @param string $package * @return void - * @throws AccessDeniedException + * @throws AuthenticationException * @throws SymlinkException */ public function remove(string $package): void { if(Resolver::resolveScope() !== Scopes::SYSTEM) - throw new AccessDeniedException('Insufficient Permissions to remove from the system symlink dictionary'); + { + throw new AuthenticationException('Insufficient Permissions to remove from the system symlink dictionary'); + } if(!$this->exists($package)) + { return; + } foreach($this->SymlinkDictionary as $key => $entry) { @@ -265,7 +275,7 @@ * * @param string $package * @return void - * @throws AccessDeniedException + * @throws AuthenticationException * @throws SymlinkException */ private function setAsRegistered(string $package): void @@ -286,13 +296,15 @@ * Syncs the symlink dictionary with the filesystem * * @return void - * @throws AccessDeniedException + * @throws AuthenticationException * @throws SymlinkException */ public function sync(): void { if(Resolver::resolveScope() !== Scopes::SYSTEM) - throw new AccessDeniedException('Insufficient Permissions to sync the system symlink dictionary'); + { + throw new AuthenticationException('Insufficient Permissions to sync the system symlink dictionary'); + } $filesystem = new Filesystem(); $execution_pointer_manager = new ExecutionPointerManager(); diff --git a/src/ncc/Utilities/Functions.php b/src/ncc/Utilities/Functions.php index b870fe3..808f07a 100644 --- a/src/ncc/Utilities/Functions.php +++ b/src/ncc/Utilities/Functions.php @@ -39,7 +39,6 @@ use ncc\Classes\PythonExtension\Python2Runner; use ncc\Classes\PythonExtension\Python3Runner; use ncc\Classes\PythonExtension\PythonRunner; - use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\ArchiveException; use ncc\Exceptions\AuthenticationException; use ncc\Exceptions\HttpException; @@ -291,7 +290,6 @@ * @param string $path * @param ExecutionPolicy $policy * @return ExecutionUnit - * @throws AccessDeniedException * @throws IOException * @throws PathNotFoundException * @throws RunnerExecutionException @@ -354,14 +352,13 @@ * Initializes NCC files * * @return void - * @throws AccessDeniedException * @noinspection PhpRedundantOptionalArgumentInspection */ public static function initializeFiles(): void { if(Resolver::resolveScope() !== Scopes::SYSTEM) { - throw new AccessDeniedException('Cannot initialize NCC files, insufficient permissions'); + throw new AuthenticationException('Cannot initialize NCC files, insufficient permissions'); } Console::outVerbose('Initializing NCC files'); diff --git a/src/ncc/ncc.php b/src/ncc/ncc.php index e34f78f..24c3051 100644 --- a/src/ncc/ncc.php +++ b/src/ncc/ncc.php @@ -25,11 +25,9 @@ namespace ncc; - use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\IOException; use ncc\Exceptions\MalformedJsonException; use ncc\Exceptions\PathNotFoundException; - use ncc\Exceptions\RuntimeException; use ncc\Objects\NccVersionInformation; use ncc\Utilities\Functions; @@ -52,7 +50,6 @@ * * @param boolean $reload Indicates if the cached version is to be ignored and the version file to be reloaded and validated * @return NccVersionInformation - * @throws AccessDeniedException * @throws IOException * @throws PathNotFoundException */ @@ -94,7 +91,6 @@ * Initializes the NCC environment * * @return bool - * @throws AccessDeniedException * @throws IOException * @throws PathNotFoundException */