From 5b9d7b485096b7659e333ae0366a1abadbec9228 Mon Sep 17 00:00:00 2001 From: Netkas Date: Tue, 24 May 2022 20:09:44 -0400 Subject: [PATCH] Added Vault objects & abstract classes, updated autoloader --- .../Abstracts/RemoteAuthenticationType.php | 16 +++ src/ncc/Abstracts/RemoteSource.php | 16 +++ src/ncc/CLI/CredentialMenu.php | 1 + src/ncc/Objects/Vault.php | 10 ++ src/ncc/Objects/Vault/DefaultEntry.php | 60 +++++++++ src/ncc/Objects/Vault/Entry.php | 127 ++++++++++++++++++ src/ncc/autoload.php | 5 + 7 files changed, 235 insertions(+) create mode 100644 src/ncc/Abstracts/RemoteAuthenticationType.php create mode 100644 src/ncc/Abstracts/RemoteSource.php create mode 100644 src/ncc/Objects/Vault/DefaultEntry.php create mode 100644 src/ncc/Objects/Vault/Entry.php diff --git a/src/ncc/Abstracts/RemoteAuthenticationType.php b/src/ncc/Abstracts/RemoteAuthenticationType.php new file mode 100644 index 0000000..64233b3 --- /dev/null +++ b/src/ncc/Abstracts/RemoteAuthenticationType.php @@ -0,0 +1,16 @@ + $this->Alias, + 'source' => $this->Source + ]; + } + + /** + * Constructs the object from an array representation + * + * @param array $data + * @return DefaultEntry + */ + public static function fromArray(array $data): DefaultEntry + { + $DefaultEntryObject = new DefaultEntry(); + + if(isset($data['alias'])) + { + $DefaultEntryObject->Alias = $data['alias']; + } + + if(isset($data['source'])) + { + $DefaultEntryObject->Source = $data['source']; + } + + return $DefaultEntryObject; + } + + } \ No newline at end of file diff --git a/src/ncc/Objects/Vault/Entry.php b/src/ncc/Objects/Vault/Entry.php new file mode 100644 index 0000000..27c778f --- /dev/null +++ b/src/ncc/Objects/Vault/Entry.php @@ -0,0 +1,127 @@ + $this->Alias, + 'source' => $this->Source, + 'source_host' => $this->SourceHost, + 'authentication_type' => $this->AuthenticationType, + 'encrypted' => $this->Encrypted, + 'authentication' => $this->Authentication + ]; + } + + /** + * Returns an array representation of the object + * + * @param array $data + * @return Entry + */ + public static function fromArray(array $data): Entry + { + $EntryObject = new Entry(); + + if(isset($data['alias'])) + { + $EntryObject->Alias = $data['alias']; + } + + if(isset($data['source'])) + { + $EntryObject->Source = $data['source']; + } + + if(isset($data['source_host'])) + { + $EntryObject->SourceHost = $data['source_host']; + } + + if(isset($data['authentication_type'])) + { + $EntryObject->AuthenticationType = $data['authentication_type']; + } + + if(isset($data['encrypted'])) + { + $EntryObject->Encrypted = $data['encrypted']; + } + + if(isset($data['authentication'])) + { + $EntryObject->Authentication = $data['authentication']; + } + + return $EntryObject; + } + } \ No newline at end of file diff --git a/src/ncc/autoload.php b/src/ncc/autoload.php index 0bb9d27..b29ca44 100644 --- a/src/ncc/autoload.php +++ b/src/ncc/autoload.php @@ -11,6 +11,8 @@ spl_autoload_register( 'ncc\\abstracts\\exceptioncodes' => '/Abstracts/ExceptionCodes.php', 'ncc\\abstracts\\nccbuildflags' => '/Abstracts/NccBuildFlags.php', 'ncc\\abstracts\\regexpatterns' => '/Abstracts/RegexPatterns.php', + 'ncc\\abstracts\\remoteauthenticationtype' => '/Abstracts/RemoteAuthenticationType.php', + 'ncc\\abstracts\\remotesource' => '/Abstracts/RemoteSource.php', 'ncc\\abstracts\\scopes' => '/Abstracts/Scopes.php', 'ncc\\abstracts\\stringpaddingmethod' => '/Abstracts/StringPaddingMethod.php', 'ncc\\cli\\credentialmenu' => '/CLI/CredentialMenu.php', @@ -38,6 +40,9 @@ spl_autoload_register( 'ncc\\objects\\projectconfiguration\\compiler' => '/Objects/ProjectConfiguration/Compiler.php', 'ncc\\objects\\projectconfiguration\\dependency' => '/Objects/ProjectConfiguration/Dependency.php', 'ncc\\objects\\projectconfiguration\\project' => '/Objects/ProjectConfiguration/Project.php', + 'ncc\\objects\\vault' => '/Objects/Vault.php', + 'ncc\\objects\\vault\\defaultentry' => '/Objects/Vault/DefaultEntry.php', + 'ncc\\objects\\vault\\entry' => '/Objects/Vault/Entry.php', 'ncc\\symfony\\component\\process\\exception\\exceptioninterface' => '/ThirdParty/Symfony/Process/Exception/ExceptionInterface.php', 'ncc\\symfony\\component\\process\\exception\\invalidargumentexception' => '/ThirdParty/Symfony/Process/Exception/InvalidArgumentException.php', 'ncc\\symfony\\component\\process\\exception\\logicexception' => '/ThirdParty/Symfony/Process/Exception/LogicException.php',