- Removed unused exception AccessDeniedException in \ncc\Exceptions in favor of AuthenticationException

This commit is contained in:
Netkas 2023-08-21 20:46:00 -04:00
parent b685d66b77
commit 7ad8518114
No known key found for this signature in database
GPG key ID: 5DAF58535614062B
27 changed files with 72 additions and 159 deletions

View file

@ -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`

View file

@ -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

View file

@ -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

View file

@ -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
{

View file

@ -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

View file

@ -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();

View file

@ -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
{

View file

@ -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
{

View file

@ -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;

View file

@ -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
*/

View file

@ -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
*/

View file

@ -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
{

View file

@ -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
*/

View file

@ -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,

View file

@ -1,39 +0,0 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
namespace ncc\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class AccessDeniedException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::ACCESS_DENIED, $previous);
}
}

View file

@ -1,26 +1,26 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;

View file

@ -23,7 +23,6 @@
namespace ncc\Interfaces;
use ncc\Enums\Options\BuildConfigurationValues;
use ncc\Exceptions\AccessDeniedException;
use ncc\Exceptions\BuildException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\PathNotFoundException;
@ -52,7 +51,6 @@
* Executes the compiler process in the correct order and returns the finalized Package object
*
* @return Package|null
* @throws AccessDeniedException
* @throws BuildException
* @throws PathNotFoundException
* @throws IOException
@ -63,7 +61,6 @@
* Compiles the components of the package
*
* @return void
* @throws AccessDeniedException
* @throws PathNotFoundException
* @throws IOException
*/
@ -73,7 +70,6 @@
* Compiles the resources of the package
*
* @return void
* @throws AccessDeniedException
* @throws PathNotFoundException
* @throws IOException
*/
@ -83,7 +79,6 @@
* Compiles the execution policies of the package
*
* @return void
* @throws AccessDeniedException
* @throws PathNotFoundException
* @throws IOException
*/

View file

@ -22,7 +22,6 @@
namespace ncc\Interfaces;
use ncc\Exceptions\AccessDeniedException;
use ncc\Exceptions\IOException;
use ncc\Objects\Package\ExecutionUnit;
use ncc\Objects\ProjectConfiguration\ExecutionPolicy;
@ -35,7 +34,6 @@
* @param string $path
* @param ExecutionPolicy $policy
* @return ExecutionUnit
* @throws AccessDeniedException
* @throws IOException
*/
public static function processUnit(string $path, ExecutionPolicy $policy): ExecutionUnit;

View file

@ -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\PathNotFoundException;
use ncc\ThirdParty\Symfony\Yaml\Yaml;
@ -82,7 +82,6 @@
* Saves the configuration file to disk
*
* @return void
* @throws AccessDeniedException
* @throws IOException
*/
public function save(): void
@ -91,7 +90,7 @@
if(Resolver::resolveScope() !== Scopes::SYSTEM)
{
throw new AccessDeniedException('Cannot save configuration file, insufficient permissions');
throw new AuthenticationException('Cannot save configuration file, insufficient permissions');
}
if($this->configuration === null)
@ -142,7 +141,6 @@
* @param string $property
* @param $value
* @return bool
* @throws AccessDeniedException
* @throws IOException
*/
public function updateProperty(string $property, $value): bool

View file

@ -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);

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -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();

View file

@ -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');

View file

@ -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
*/