From bbde0205b87758d2198130a6f6ecd7512beab910 Mon Sep 17 00:00:00 2001 From: aB0t Date: Tue, 26 Mar 2024 19:06:11 +0200 Subject: [PATCH] update 2024-03-26 19:05:48 --- README.md | 76 ++++- .../README.md | 65 ++++- .../code.php | 144 ++++++++- .../code.power | 124 +++++++- .../settings.json | 34 ++- .../README.md | 70 ++++- .../code.php | 104 ++++++- .../code.power | 83 +++++- .../settings.json | 39 ++- .../README.md | 55 +++- .../code.php | 110 ++++++- .../code.power | 94 +++++- .../settings.json | 30 +- .../README.md | 73 ++++- .../code.php | 261 ++++++++++++++++- .../code.power | 238 ++++++++++++++- .../settings.json | 47 ++- .../README.md | 102 ++++++- .../code.php | 177 ++++++++++- .../code.power | 152 +++++++++- .../settings.json | 60 +++- .../README.md | 77 ++++- .../code.php | 155 +++++++++- .../code.power | 134 ++++++++- .../settings.json | 36 ++- .../README.md | 31 +- .../code.php | 16 +- .../settings.json | 29 +- .../README.md | 56 +++- .../code.php | 126 +++++++- .../code.power | 107 ++++++- .../settings.json | 38 ++- .../README.md | 65 ++++- .../code.php | 112 ++++++- .../code.power | 94 +++++- .../settings.json | 32 +- .../README.md | 31 +- .../code.php | 16 +- .../settings.json | 29 +- .../README.md | 131 ++++++++- .../code.php | 274 +++++++++++++++++- .../code.power | 254 +++++++++++++++- .../settings.json | 44 ++- .../README.md | 46 ++- .../code.php | 54 +++- .../code.power | 38 ++- .../settings.json | 26 +- .../README.md | 87 +++++- .../code.php | 143 ++++++++- .../code.power | 120 +++++++- .../settings.json | 42 ++- .../README.md | 47 ++- .../code.php | 58 +++- .../code.power | 41 ++- .../settings.json | 24 +- super-powers.json | 157 +++++++++- 56 files changed, 4852 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index 433b69e..3889f40 100644 --- a/README.md +++ b/README.md @@ -1 +1,75 @@ -###POWERREADME### \ No newline at end of file +``` +███████╗██╗ ██╗██████╗ ███████╗██████╗ +██╔════╝██║ ██║██╔══██╗██╔════╝██╔══██╗ +███████╗██║ ██║██████╔╝█████╗ ██████╔╝ +╚════██║██║ ██║██╔═══╝ ██╔══╝ ██╔══██╗ +███████║╚██████╔╝██║ ███████╗██║ ██║ +╚══════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ ███████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗██╔════╝ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝███████╗ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗╚════██║ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║███████║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝╚══════╝ +``` + +### What is JCB Super Powers? +The Joomla Component Builder (JCB) Super Power features are designed to enhance JCB's functionality and streamline the development process. These Super Powers enable developers to efficiently manage and share their custom powers across multiple JCB instances through repositories hosted on [https://git.vdm.dev/[username]/[repository-name]](https://git.vdm.dev). JCB Super Powers are managed using a combination of layers, events, tasks, methods, switches, and algorithms, which work together to provide powerful customization and extensibility options. More details on JCB Super Powers can be found in the [Super Powers Documentation](https://git.vdm.dev/joomla/super-powers/wiki). + +In summary, JCB Super Powers offer a flexible and efficient way to manage and share functionalities between JCB instances. By utilizing a sophisticated system of layers, events, tasks, methods, switches, and algorithms, developers can seamlessly integrate JCB core powers and their custom powers. For more information on how to work with JCB Super Powers, refer to the [Super Powers User Guide](https://git.vdm.dev/joomla/super-powers/wiki). + +### What can I find here? +This repository contains an index (see below) of all the approved powers within the JCB GUI. During the compilation of a component, these powers are automatically added to the repository, ensuring a well-organized and accessible collection of functionalities. + +# Index of powers + +- **Namespace**: [VDM\Joomla\Componentbuilder](#vdm-joomla-componentbuilder) + + - **class Crypt** | [Details](src/d357e796-9f22-4615-9ebc-970b42cbd280) | [Code](src/d357e796-9f22-4615-9ebc-970b42cbd280/code.php) | [Settings](src/d357e796-9f22-4615-9ebc-970b42cbd280/settings.json) | Super__d357e796_9f22_4615_9ebc_970b42cbd280__Power + - **class Server** | [Details](src/66355f70-c26c-4765-ba48-498e3df740ef) | [Code](src/66355f70-c26c-4765-ba48-498e3df740ef/code.php) | [Settings](src/66355f70-c26c-4765-ba48-498e3df740ef/settings.json) | Super__66355f70_c26c_4765_ba48_498e3df740ef__Power +- **Namespace**: [VDM\Joomla\Componentbuilder\Crypt](#vdm-joomla-componentbuilder-crypt) + + - **class Aes** | [Details](src/a25c82c8-14c2-40df-adae-f832709ab49b) | [Code](src/a25c82c8-14c2-40df-adae-f832709ab49b/code.php) | [Settings](src/a25c82c8-14c2-40df-adae-f832709ab49b/settings.json) | Super__a25c82c8_14c2_40df_adae_f832709ab49b__Power + - **class FOF** | [Details](src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe) | [Code](src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe/code.php) | [Settings](src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe/settings.json) | Super__e98b4edc_25b9_49d7_98a0_e42ad3b75efe__Power + - **class KeyLoader** | [Details](src/6da44dff-a221-4f22-b9d9-b2fc2a724b4b) | [Code](src/6da44dff-a221-4f22-b9d9-b2fc2a724b4b/code.php) | [Settings](src/6da44dff-a221-4f22-b9d9-b2fc2a724b4b/settings.json) | Super__6da44dff_a221_4f22_b9d9_b2fc2a724b4b__Power + - **class Password** | [Details](src/fea2b107-3ee4-4ebf-84be-d3f2829c8614) | [Code](src/fea2b107-3ee4-4ebf-84be-d3f2829c8614/code.php) | [Settings](src/fea2b107-3ee4-4ebf-84be-d3f2829c8614/settings.json) | Super__fea2b107_3ee4_4ebf_84be_d3f2829c8614__Power + - **class Random** | [Details](src/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c) | [Code](src/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c/code.php) | [Settings](src/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c/settings.json) | Super__c46a42b4_b0d3_48e7_a6fa_af0399e1e66c__Power +- **Namespace**: [VDM\Joomla\Componentbuilder\Server](#vdm-joomla-componentbuilder-server) + + - **class Ftp** | [Details](src/11be6be3-ee3e-4771-8663-5545b76b73ab) | [Code](src/11be6be3-ee3e-4771-8663-5545b76b73ab/code.php) | [Settings](src/11be6be3-ee3e-4771-8663-5545b76b73ab/settings.json) | Super__11be6be3_ee3e_4771_8663_5545b76b73ab__Power + - **class Load** | [Details](src/a3414824-e99d-4878-b3d1-b5deef0cae17) | [Code](src/a3414824-e99d-4878-b3d1-b5deef0cae17/code.php) | [Settings](src/a3414824-e99d-4878-b3d1-b5deef0cae17/settings.json) | Super__a3414824_e99d_4878_b3d1_b5deef0cae17__Power + - **class Sftp** | [Details](src/490b6aa5-5de7-4be5-a61a-f634f6e004c0) | [Code](src/490b6aa5-5de7-4be5-a61a-f634f6e004c0/code.php) | [Settings](src/490b6aa5-5de7-4be5-a61a-f634f6e004c0/settings.json) | Super__490b6aa5_5de7_4be5_a61a_f634f6e004c0__Power +- **Namespace**: [VDM\Joomla\Componentbuilder\Service](#vdm-joomla-componentbuilder-service) + + - **class Crypt** | [Details](src/4d8f38ef-8f3a-463d-8678-0bf087ac6815) | [Code](src/4d8f38ef-8f3a-463d-8678-0bf087ac6815/code.php) | [Settings](src/4d8f38ef-8f3a-463d-8678-0bf087ac6815/settings.json) | Super__4d8f38ef_8f3a_463d_8678_0bf087ac6815__Power + - **class Server** | [Details](src/42ceff0b-226d-42ff-9ffa-3d5935890337) | [Code](src/42ceff0b-226d-42ff-9ffa-3d5935890337/code.php) | [Settings](src/42ceff0b-226d-42ff-9ffa-3d5935890337/settings.json) | Super__42ceff0b_226d_42ff_9ffa_3d5935890337__Power +- **Namespace**: [VDM\Joomla\Componentbuilder\Crypt\Aes](#vdm-joomla-componentbuilder-crypt-aes) + + - **class Legacy** | [Details](src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0) | [Code](src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0/code.php) | [Settings](src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0/settings.json) | Super__437af6b0_ca02_49d7_8739_4edfc8a9ccb0__Power +- **Namespace**: [VDM\Joomla\Componentbuilder\Server\Model](#vdm-joomla-componentbuilder-server-model) + + - **class Load** | [Details](src/f37ee8b7-2909-4319-bdf8-769bd7635490) | [Code](src/f37ee8b7-2909-4319-bdf8-769bd7635490/code.php) | [Settings](src/f37ee8b7-2909-4319-bdf8-769bd7635490/settings.json) | Super__f37ee8b7_2909_4319_bdf8_769bd7635490__Power + +--- +``` + ██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗ + ██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗ + ██║██║ ██║██║ ██║██╔████╔██║██║ ███████║ +██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║ +╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║ + ╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ + ██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗ +██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝ +██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║ +██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║ +╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║ + ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝ +██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗ +██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗ +██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝ +██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗ +██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║ +╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/11be6be3-ee3e-4771-8663-5545b76b73ab/README.md b/src/11be6be3-ee3e-4771-8663-5545b76b73ab/README.md index 433b69e..a1e9355 100644 --- a/src/11be6be3-ee3e-4771-8663-5545b76b73ab/README.md +++ b/src/11be6be3-ee3e-4771-8663-5545b76b73ab/README.md @@ -1 +1,64 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Ftp (Details) +> namespace: **VDM\Joomla\Componentbuilder\Server** +```uml +@startuml +class Ftp #Gold { + # ?FtpClient $client + # ?object $details + + iables $signature + + set(object $details) : Ftp + + move(string $localPath, string $fileName) : bool + - connected() : bool + - getClient() : ?FtpClient +} + +note right of Ftp::set + set the server details + + since: 3.2.0 + return: Ftp +end note + +note right of Ftp::move + move a file to server with the FTP client + + since: 3.2.0 + return: bool +end note + +note right of Ftp::connected + Make sure we are connected + + since: 3.2.0 + return: bool +end note + +note right of Ftp::getClient + get the FtpClient object + + since: 3.2.0 + return: ?FtpClient +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/11be6be3-ee3e-4771-8663-5545b76b73ab/code.php b/src/11be6be3-ee3e-4771-8663-5545b76b73ab/code.php index 26c1a50..d981017 100644 --- a/src/11be6be3-ee3e-4771-8663-5545b76b73ab/code.php +++ b/src/11be6be3-ee3e-4771-8663-5545b76b73ab/code.php @@ -9,4 +9,146 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\Componentbuilder\Server; + + +use Joomla\CMS\Client\FtpClient; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Componentbuilder\Interfaces\Serverinterface; + + +/** + * Ftp Class + * + * @since 3.2.0 + */ +class Ftp implements Serverinterface +{ + /** + * The client object + * + * @var FtpClient|null + * @since 3.2.0 + **/ + protected ?FtpClient $client = null; + + /** + * The server details + * + * @var object + * @since 3.2.0 + **/ + protected ?object $details = null; + + /** + * set the server details + * + * @param object $details The server details + * + * @return Ftp + * @since 3.2.0 + **/ + public function set(object $details): Ftp + { + // we need to make sure the if the details changed to get a new server client + if (!ObjectHelper::equal($details, $this->details)) + { + // set the details + $this->details = $details; + + // reset the client if it was set before + $this->client = null; + } + + return $this; + } + + /** + * move a file to server with the FTP client + * + * @param string $localPath The full local path to the file + * @param string $fileName The file name + * + * @return bool + * @since 3.2.0 + **/ + public function move(string $localPath, string $fileName): bool + { + if ($this->connected()) + { + return $this->client->store($localPath, $fileName); + } + + return false; + } + + /** + * Make sure we are connected + * + * @return bool + * @since 3.2.0 + **/ + private function connected(): bool + { + // check if we have a connection + if ($this->client instanceof FtpClient && $this->client->isConnected()) + { + return true; + } + + $this->client = $this->getClient(); + + return $this->client instanceof FtpClient; + } + + /** + * get the FtpClient object + * + * @return FtpClient|null + * @since 3.2.0 + **/ + private function getClient(): ?FtpClient + { + // make sure we have a string and it is not default or empty + if (StringHelper::check($this->details->signature)) + { + // turn into array of variables + $signature = []; + parse_str((string) $this->details->signature, $signature); + // set options + if (isset($signature['options']) && ArrayHelper::check($signature['options'])) + { + foreach ($signature['options'] as $o__p0t1on => $vAln3) + { + if ('timeout' === $o__p0t1on) + { + $options[$o__p0t1on] = (int) $vAln3; + } + if ('type' === $o__p0t1on) + { + $options[$o__p0t1on] = (string) $vAln3; + } + } + } + else + { + $options = []; + } + // get ftp object + if (isset($signature['host']) && $signature['host'] != 'HOSTNAME' && + isset($signature['port']) && $signature['port'] != 'PORT_INT' && + isset($signature['username']) && $signature['username'] != 'user@name.com' && + isset($signature['password']) && $signature['password'] != 'password') + { + // this is a singleton + return FtpClient::getInstance($host, $port, $options, $username, $password); + } + } + + return null; + } + +} + diff --git a/src/11be6be3-ee3e-4771-8663-5545b76b73ab/code.power b/src/11be6be3-ee3e-4771-8663-5545b76b73ab/code.power index 69309b0..af9d72e 100644 --- a/src/11be6be3-ee3e-4771-8663-5545b76b73ab/code.power +++ b/src/11be6be3-ee3e-4771-8663-5545b76b73ab/code.power @@ -1 +1,123 @@ -###CODEPOWER### \ No newline at end of file + /** + * The client object + * + * @var FtpClient|null + * @since 3.2.0 + **/ + protected ?FtpClient $client = null; + + /** + * The server details + * + * @var object + * @since 3.2.0 + **/ + protected ?object $details = null; + + /** + * set the server details + * + * @param object $details The server details + * + * @return Ftp + * @since 3.2.0 + **/ + public function set(object $details): Ftp + { + // we need to make sure the if the details changed to get a new server client + if (!ObjectHelper::equal($details, $this->details)) + { + // set the details + $this->details = $details; + + // reset the client if it was set before + $this->client = null; + } + + return $this; + } + + /** + * move a file to server with the FTP client + * + * @param string $localPath The full local path to the file + * @param string $fileName The file name + * + * @return bool + * @since 3.2.0 + **/ + public function move(string $localPath, string $fileName): bool + { + if ($this->connected()) + { + return $this->client->store($localPath, $fileName); + } + + return false; + } + + /** + * Make sure we are connected + * + * @return bool + * @since 3.2.0 + **/ + private function connected(): bool + { + // check if we have a connection + if ($this->client instanceof FtpClient && $this->client->isConnected()) + { + return true; + } + + $this->client = $this->getClient(); + + return $this->client instanceof FtpClient; + } + + /** + * get the FtpClient object + * + * @return FtpClient|null + * @since 3.2.0 + **/ + private function getClient(): ?FtpClient + { + // make sure we have a string and it is not default or empty + if (StringHelper::check($this->details->signature)) + { + // turn into array of variables + $signature = []; + parse_str((string) $this->details->signature, $signature); + // set options + if (isset($signature['options']) && ArrayHelper::check($signature['options'])) + { + foreach ($signature['options'] as $o__p0t1on => $vAln3) + { + if ('timeout' === $o__p0t1on) + { + $options[$o__p0t1on] = (int) $vAln3; + } + if ('type' === $o__p0t1on) + { + $options[$o__p0t1on] = (string) $vAln3; + } + } + } + else + { + $options = []; + } + // get ftp object + if (isset($signature['host']) && $signature['host'] != 'HOSTNAME' && + isset($signature['port']) && $signature['port'] != 'PORT_INT' && + isset($signature['username']) && $signature['username'] != 'user@name.com' && + isset($signature['password']) && $signature['password'] != 'password') + { + // this is a singleton + return FtpClient::getInstance($host, $port, $options, $username, $password); + } + } + + return null; + } diff --git a/src/11be6be3-ee3e-4771-8663-5545b76b73ab/settings.json b/src/11be6be3-ee3e-4771-8663-5545b76b73ab/settings.json index 6b3b222..d94b279 100644 --- a/src/11be6be3-ee3e-4771-8663-5545b76b73ab/settings.json +++ b/src/11be6be3-ee3e-4771-8663-5545b76b73ab/settings.json @@ -1 +1,33 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "11be6be3-ee3e-4771-8663-5545b76b73ab", + "implements": [ + "86ac0760-26f5-4746-9c7f-ce77860f80f8" + ], + "load_selection": null, + "name": "Ftp", + "power_version": "1.0.0", + "system_name": "JCB.Server.Ftp", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef", + "as": "default" + }, + "use_selection1": { + "use": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a", + "as": "default" + }, + "use_selection2": { + "use": "91004529-94a9-4590-b842-e7c6b624ecf5", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\Componentbuilder.Server.Ftp", + "description": "Ftp Class\r\n\r\n@since 3.2.0", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "use Joomla\\CMS\\Client\\FtpClient;", + "composer": "" +} \ No newline at end of file diff --git a/src/42ceff0b-226d-42ff-9ffa-3d5935890337/README.md b/src/42ceff0b-226d-42ff-9ffa-3d5935890337/README.md index 433b69e..e0b06fe 100644 --- a/src/42ceff0b-226d-42ff-9ffa-3d5935890337/README.md +++ b/src/42ceff0b-226d-42ff-9ffa-3d5935890337/README.md @@ -1 +1,69 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Server (Details) +> namespace: **VDM\Joomla\Componentbuilder\Service** +```uml +@startuml +class Server #Gold { + + register(Container $container) : void + + getServer(Container $container) : Client + + getServerLoad(Container $container) : Load + + getServerFtp(Container $container) : Ftp + + getServerSftp(Container $container) : Sftp +} + +note right of Server::register + Registers the service provider with a DI container. + + since: 3.2.0 + return: void +end note + +note right of Server::getServer + Get the Server Client class + + since: 3.2.0 + return: Client +end note + +note right of Server::getServerLoad + Get the Server Load class + + since: 3.2.0 + return: Load +end note + +note right of Server::getServerFtp + Get the Server Ftp class + + since: 3.2.0 + return: Ftp +end note + +note right of Server::getServerSftp + Get the Server Sftp class + + since: 3.2.0 + return: Sftp +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/42ceff0b-226d-42ff-9ffa-3d5935890337/code.php b/src/42ceff0b-226d-42ff-9ffa-3d5935890337/code.php index 26c1a50..98933f0 100644 --- a/src/42ceff0b-226d-42ff-9ffa-3d5935890337/code.php +++ b/src/42ceff0b-226d-42ff-9ffa-3d5935890337/code.php @@ -9,4 +9,106 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\Componentbuilder\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Componentbuilder\Server as Client; +use VDM\Joomla\Componentbuilder\Server\Load; +use VDM\Joomla\Componentbuilder\Server\Ftp; +use VDM\Joomla\Componentbuilder\Server\Sftp; + + +/** + * Server Service Provider + * + * @since 3.2.0 + */ +class Server implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Client::class, 'Server') + ->share('Server', [$this, 'getServer'], true); + + $container->alias(Load::class, 'Server.Load') + ->share('Server.Load', [$this, 'getServerLoad'], true); + + $container->alias(Ftp::class, 'Server.FTP') + ->share('Server.FTP', [$this, 'getServerFtp'], true); + $container->alias(Sftp::class, 'Server.SFTP') + ->share('Server.SFTP', [$this, 'getServerSftp'], true); + } + + /** + * Get the Server Client class + * + * @param Container $container The DI container. + * + * @return Client + * @since 3.2.0 + */ + public function getServer(Container $container): Client + { + return new Client( + $container->get('Server.Load'), + $container->get('Server.FTP'), + $container->get('Server.SFTP') + ); + } + + /** + * Get the Server Load class + * + * @param Container $container The DI container. + * + * @return Load + * @since 3.2.0 + */ + public function getServerLoad(Container $container): Load + { + return new Load( + $container->get('Load'), + $container->get('Model.Server.Load') + ); + } + + /** + * Get the Server Ftp class + * + * @param Container $container The DI container. + * + * @return Ftp + * @since 3.2.0 + */ + public function getServerFtp(Container $container): Ftp + { + return new Ftp(); + } + + /** + * Get the Server Sftp class + * + * @param Container $container The DI container. + * + * @return Sftp + * @since 3.2.0 + */ + public function getServerSftp(Container $container): Sftp + { + return new Sftp( + $container->get('Crypt.Key') + ); + } + +} + diff --git a/src/42ceff0b-226d-42ff-9ffa-3d5935890337/code.power b/src/42ceff0b-226d-42ff-9ffa-3d5935890337/code.power index 69309b0..1959d37 100644 --- a/src/42ceff0b-226d-42ff-9ffa-3d5935890337/code.power +++ b/src/42ceff0b-226d-42ff-9ffa-3d5935890337/code.power @@ -1 +1,82 @@ -###CODEPOWER### \ No newline at end of file + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Client::class, 'Server') + ->share('Server', [$this, 'getServer'], true); + + $container->alias(Load::class, 'Server.Load') + ->share('Server.Load', [$this, 'getServerLoad'], true); + + $container->alias(Ftp::class, 'Server.FTP') + ->share('Server.FTP', [$this, 'getServerFtp'], true); + $container->alias(Sftp::class, 'Server.SFTP') + ->share('Server.SFTP', [$this, 'getServerSftp'], true); + } + + /** + * Get the Server Client class + * + * @param Container $container The DI container. + * + * @return Client + * @since 3.2.0 + */ + public function getServer(Container $container): Client + { + return new Client( + $container->get('Server.Load'), + $container->get('Server.FTP'), + $container->get('Server.SFTP') + ); + } + + /** + * Get the Server Load class + * + * @param Container $container The DI container. + * + * @return Load + * @since 3.2.0 + */ + public function getServerLoad(Container $container): Load + { + return new Load( + $container->get('Load'), + $container->get('Model.Server.Load') + ); + } + + /** + * Get the Server Ftp class + * + * @param Container $container The DI container. + * + * @return Ftp + * @since 3.2.0 + */ + public function getServerFtp(Container $container): Ftp + { + return new Ftp(); + } + + /** + * Get the Server Sftp class + * + * @param Container $container The DI container. + * + * @return Sftp + * @since 3.2.0 + */ + public function getServerSftp(Container $container): Sftp + { + return new Sftp( + $container->get('Crypt.Key') + ); + } diff --git a/src/42ceff0b-226d-42ff-9ffa-3d5935890337/settings.json b/src/42ceff0b-226d-42ff-9ffa-3d5935890337/settings.json index 6b3b222..48adaec 100644 --- a/src/42ceff0b-226d-42ff-9ffa-3d5935890337/settings.json +++ b/src/42ceff0b-226d-42ff-9ffa-3d5935890337/settings.json @@ -1 +1,38 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "42ceff0b-226d-42ff-9ffa-3d5935890337", + "implements": [ + "-1" + ], + "load_selection": null, + "name": "Server", + "power_version": "1.0.0", + "system_name": "JCB.Service.Server", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "66355f70-c26c-4765-ba48-498e3df740ef", + "as": "Client" + }, + "use_selection1": { + "use": "a3414824-e99d-4878-b3d1-b5deef0cae17", + "as": "default" + }, + "use_selection2": { + "use": "11be6be3-ee3e-4771-8663-5545b76b73ab", + "as": "default" + }, + "use_selection3": { + "use": "490b6aa5-5de7-4be5-a61a-f634f6e004c0", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\Componentbuilder.Service.Server", + "description": "Server Service Provider\r\n\r\n@since 3.2.0", + "implements_custom": "ServiceProviderInterface", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "use Joomla\\DI\\Container;\r\nuse Joomla\\DI\\ServiceProviderInterface;", + "composer": "" +} \ No newline at end of file diff --git a/src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0/README.md b/src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0/README.md index 433b69e..a497d73 100644 --- a/src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0/README.md +++ b/src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0/README.md @@ -1 +1,54 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Legacy (Details) +> namespace: **VDM\Joomla\Componentbuilder\Crypt\Aes** +```uml +@startuml +class Legacy #Gold { + # BASEAES $aes + # int $size + + __construct(BASEAES $aes) + + encrypt(string $string, string $key) : string + + decrypt(string $string, string $key) : ?string +} + +note right of Legacy::__construct + Constructor + + since: 3.2.0 +end note + +note right of Legacy::encrypt + Encrypt a string as needed + + since: 3.2.0 + return: string +end note + +note right of Legacy::decrypt + Decrypt a string as needed + + since: 3.2.0 + return: ?string +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0/code.php b/src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0/code.php index 26c1a50..f7f4c8e 100644 --- a/src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0/code.php +++ b/src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0/code.php @@ -9,4 +9,112 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\Componentbuilder\Crypt\Aes; + + +use phpseclib3\Crypt\AES as BASEAES; +use VDM\Joomla\Componentbuilder\Interfaces\Cryptinterface; + + +/** + * Legacy Class for Aes Encryption + * + * @since 3.2.0 + */ +class Legacy implements Cryptinterface +{ + /** + * The Aes class + * + * @var BASEAES + * @since 3.2.0 + */ + protected BASEAES $aes; + + /** + * The block size + * + * @var int + * @since 3.2.0 + */ + protected int $size = 128; + + /** + * Constructor + * + * @param BASEAES $aes The Aes class + * + * @since 3.2.0 + */ + public function __construct(BASEAES $aes) + { + $this->aes = $aes; + + // we set the length once + $this->aes->setKeyLength($this->size); + + // enable padding + $this->aes->enablePadding(); + } + + /** + * Encrypt a string as needed + * + * @param string $string The string to encrypt + * @param string $key The encryption key + * + * @return string + * @since 3.2.0 + **/ + public function encrypt(string $string, string $key): string + { + // we get the IV length + $iv_length = (int) $this->aes->getBlockLength() >> 3; + + // get the IV value + $iv = str_repeat("\0", $iv_length); + + // Load the IV + $this->aes->setIV($iv); + + // set the password + $this->aes->setPassword($key, 'pbkdf2', 'sha256', 'VastDevelopmentMethod/salt'); + + // encrypt the string, and base 64 encode the result + return base64_encode($this->aes->encrypt($string)); + } + + /** + * Decrypt a string as needed + * + * @param string $string The string to decrypt + * @param string $key The decryption key + * + * @return string|null + * @since 3.2.0 + **/ + public function decrypt(string $string, string $key): ?string + { + // remove base 64 encoding + $string = base64_decode($string); + + // we get the IV length + $iv_length = (int) $this->aes->getBlockLength() >> 3; + + // get the IV value + $iv = str_repeat("\0", $iv_length); + + // Load the IV + $this->aes->setIV($iv); + + // set the password + $this->aes->setPassword($key, 'pbkdf2', 'sha256', 'VastDevelopmentMethod/salt'); + + try { + return $this->aes->decrypt($string); + } catch (\Exception $ex) { + return null; + } + } +} + diff --git a/src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0/code.power b/src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0/code.power index 69309b0..285cafc 100644 --- a/src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0/code.power +++ b/src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0/code.power @@ -1 +1,93 @@ -###CODEPOWER### \ No newline at end of file + /** + * The Aes class + * + * @var BASEAES + * @since 3.2.0 + */ + protected BASEAES $aes; + + /** + * The block size + * + * @var int + * @since 3.2.0 + */ + protected int $size = 128; + + /** + * Constructor + * + * @param BASEAES $aes The Aes class + * + * @since 3.2.0 + */ + public function __construct(BASEAES $aes) + { + $this->aes = $aes; + + // we set the length once + $this->aes->setKeyLength($this->size); + + // enable padding + $this->aes->enablePadding(); + } + + /** + * Encrypt a string as needed + * + * @param string $string The string to encrypt + * @param string $key The encryption key + * + * @return string + * @since 3.2.0 + **/ + public function encrypt(string $string, string $key): string + { + // we get the IV length + $iv_length = (int) $this->aes->getBlockLength() >> 3; + + // get the IV value + $iv = str_repeat("\0", $iv_length); + + // Load the IV + $this->aes->setIV($iv); + + // set the password + $this->aes->setPassword($key, 'pbkdf2', 'sha256', 'VastDevelopmentMethod/salt'); + + // encrypt the string, and base 64 encode the result + return base64_encode($this->aes->encrypt($string)); + } + + /** + * Decrypt a string as needed + * + * @param string $string The string to decrypt + * @param string $key The decryption key + * + * @return string|null + * @since 3.2.0 + **/ + public function decrypt(string $string, string $key): ?string + { + // remove base 64 encoding + $string = base64_decode($string); + + // we get the IV length + $iv_length = (int) $this->aes->getBlockLength() >> 3; + + // get the IV value + $iv = str_repeat("\0", $iv_length); + + // Load the IV + $this->aes->setIV($iv); + + // set the password + $this->aes->setPassword($key, 'pbkdf2', 'sha256', 'VastDevelopmentMethod/salt'); + + try { + return $this->aes->decrypt($string); + } catch (\Exception $ex) { + return null; + } + } \ No newline at end of file diff --git a/src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0/settings.json b/src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0/settings.json index 6b3b222..81d4575 100644 --- a/src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0/settings.json +++ b/src/437af6b0-ca02-49d7-8739-4edfc8a9ccb0/settings.json @@ -1 +1,29 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "0", + "guid": "437af6b0-ca02-49d7-8739-4edfc8a9ccb0", + "implements": [ + "81de8f57-dd9c-4a17-964f-848cd4a0743b" + ], + "load_selection": null, + "name": "Legacy", + "power_version": "1.0.0", + "system_name": "JCB.Crypt.Aes.Legacy", + "type": "class", + "use_selection": null, + "namespace": "VDM\\Joomla\\Componentbuilder.Crypt.Aes.Legacy", + "description": "Legacy Class for Aes Encryption\r\n\r\n@since 3.2.0", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "", + "composer": { + "composer0": { + "access_point": "phpseclib3\/vendor\/autoload.php", + "namespace": { + "namespace0": { + "use": "phpseclib3\\Crypt\\AES as BASEAES" + } + } + } + } +} \ No newline at end of file diff --git a/src/490b6aa5-5de7-4be5-a61a-f634f6e004c0/README.md b/src/490b6aa5-5de7-4be5-a61a-f634f6e004c0/README.md index 433b69e..1d8cc56 100644 --- a/src/490b6aa5-5de7-4be5-a61a-f634f6e004c0/README.md +++ b/src/490b6aa5-5de7-4be5-a61a-f634f6e004c0/README.md @@ -1 +1,72 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Sftp (Details) +> namespace: **VDM\Joomla\Componentbuilder\Server** +```uml +@startuml +class Sftp #Gold { + # KeyLoader $key + # ?SftpClient $client + # ?object $details + # CMSApplication $app + + __construct(KeyLoader $key, ?CMSApplication $app = null) + + set(object $details) : Sftp + + move(string $localPath, string $fileName) : bool + - connected() : bool + - getClient() : ?SftpClient +} + +note right of Sftp::__construct + Constructor + + since: 3.2.0 +end note + +note right of Sftp::set + set the server details + + since: 3.2.0 + return: Sftp +end note + +note right of Sftp::move + move a file to server with the FTP client + + since: 3.2.0 + return: bool +end note + +note right of Sftp::connected + Make sure we are connected + + since: 3.2.0 + return: bool +end note + +note right of Sftp::getClient + get the SftpClient object + + since: 3.2.0 + return: ?SftpClient +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/490b6aa5-5de7-4be5-a61a-f634f6e004c0/code.php b/src/490b6aa5-5de7-4be5-a61a-f634f6e004c0/code.php index 26c1a50..27772b8 100644 --- a/src/490b6aa5-5de7-4be5-a61a-f634f6e004c0/code.php +++ b/src/490b6aa5-5de7-4be5-a61a-f634f6e004c0/code.php @@ -9,4 +9,263 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\Componentbuilder\Server; + + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplication; +use phpseclib3\Net\SFTP as SftpClient; +use VDM\Joomla\Componentbuilder\Crypt\KeyLoader; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\FileHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Componentbuilder\Interfaces\Serverinterface; + + +/** + * Sftp Class + * + * @since 3.2.0 + */ +class Sftp implements Serverinterface +{ + /** + * The KeyLoader + * + * @var KeyLoader + * @since 3.2.0 + */ + protected KeyLoader $key; + + /** + * The client object + * + * @var SftpClient|null + * @since 3.2.0 + **/ + protected ?SftpClient $client = null; + + /** + * The server details + * + * @var object + * @since 3.2.0 + **/ + protected ?object $details = null; + + /** + * Application object. + * + * @var CMSApplication + * @since 3.2.0 + **/ + protected CMSApplication $app; + + /** + * Constructor + * + * @param KeyLoader $key The key loader object. + * @param CMSApplication|null $app The app object. + * + * @since 3.2.0 + */ + public function __construct(KeyLoader $key, ?CMSApplication $app = null) + { + $this->key = $key; + $this->app = $app ?: Factory::getApplication(); + } + + /** + * set the server details + * + * @param object $details The server details + * + * @return Sftp + * @since 3.2.0 + **/ + public function set(object $details): Sftp + { + // we need to make sure the if the details changed to get a new server client + if (!ObjectHelper::equal($details, $this->details)) + { + // set the details + $this->details = $details; + + // reset the client if it was set before + $this->client = null; + } + + return $this; + } + + /** + * move a file to server with the FTP client + * + * @param string $localPath The full local path to the file + * @param string $fileName The file name + * + * @return bool + * @since 3.2.0 + **/ + public function move(string $localPath, string $fileName): bool + { + if ($this->connected() && + ($data = FileHelper::getContent($localPath, null)) !== null) + { + // get the remote path + $path = ''; + if (isset($this->details->path) && + StringHelper::check($this->details->path) && + $this->details->path !== '/') + { + $path = trim((string) $this->details->path); + $path = '/' . trim($path, '/') . '/'; + } + + try + { + return $this->client->put($path . trim($fileName), $data); + } + catch(\Exception $e) + { + $this->app->enqueueMessage( + Text::sprintf('COM_COMPONENTBUILDER_MOVING_OF_THE_S_FAILED', $fileName) . ': ' . $e->getMessage(), + 'Error' + ); + } + } + + return false; + } + + /** + * Make sure we are connected + * + * @return bool + * @since 3.2.0 + **/ + private function connected(): bool + { + // check if we have a connection + if ($this->client instanceof SftpClient && ($this->client->isConnected() || $this->client->ping())) + { + return true; + } + + $this->client = $this->getClient(); + + return $this->client instanceof SftpClient; + } + + /** + * get the SftpClient object + * + * @return SftpClient|null + * @since 3.2.0 + **/ + private function getClient(): ?SftpClient + { + // make sure we have a host value set + if (isset($this->details->host) && StringHelper::check($this->details->host) && + isset($this->details->username) && StringHelper::check($this->details->username)) + { + // insure the port is set + $port = (int)($this->details->port ?? 22); + + // open the connection + $sftp = new SftpClient($this->details->host, $port); + + // set the passphrase if it exist + $passphrase = (isset($this->details->secret) && StringHelper::check(trim($this->details->secret))) ? trim($this->details->secret) : false; + + // set the password if it exist + $password = (isset($this->details->password) && StringHelper::check(trim($this->details->password))) ? trim($this->details->password) : false; + + // now login based on authentication type + $key = null; + switch($this->details->authentication) + { + case 1: // password + $key = $password ?? null; + $password = null; + break; + case 2: // private key file + case 3: // both password and private key file + if (isset($this->details->private) && StringHelper::check($this->details->private) && + ($private_key = FileHelper::getContent($this->details->private, null)) !== null) + { + try + { + $key = $this->key::load(trim($private_key), $passphrase); + } + catch(\Exception $e) + { + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_LOADING_THE_PRIVATE_KEY_FILE_FAILED') . ': ' . $e->getMessage(), + 'Error' + ); + $key = null; + } + } + break; + case 4: // private key field + case 5: // both password and private key field + if (isset($this->details->private_key) && StringHelper::check($this->details->private_key)) + { + try + { + $key = $this->key::load(trim($this->details->private_key), $passphrase); + } + catch(\Exception $e) + { + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_LOADING_THE_PRIVATE_KEY_TEXT_FAILED') . ': ' . $e->getMessage(), + 'Error' + ); + $key = null; + } + } + break; + } + + // remove any null bites from the username + $this->details->username = trim($this->details->username); + + // login + if (!empty($key) && !empty($password)) + { + try + { + $sftp->login($this->details->username, $key, $password); + return $sftp; + } + catch(\Exception $e) + { + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_LOGIN_FAILED') . ': ' . $e->getMessage(), + 'Error' + ); + } + } + elseif (!empty($key)) + { + try + { + $sftp->login($this->details->username, $key); + return $sftp; + } + catch(\Exception $e) + { + $this->app->enqueueMessage( + Text::_('COM_COMPONENTBUILDER_LOGIN_FAILED') . ': ' . $e->getMessage(), + 'Error' + ); + } + } + } + + return null; + } +} + diff --git a/src/490b6aa5-5de7-4be5-a61a-f634f6e004c0/code.power b/src/490b6aa5-5de7-4be5-a61a-f634f6e004c0/code.power index 69309b0..4adfe70 100644 --- a/src/490b6aa5-5de7-4be5-a61a-f634f6e004c0/code.power +++ b/src/490b6aa5-5de7-4be5-a61a-f634f6e004c0/code.power @@ -1 +1,237 @@ -###CODEPOWER### \ No newline at end of file + /** + * The KeyLoader + * + * @var KeyLoader + * @since 3.2.0 + */ + protected KeyLoader $key; + + /** + * The client object + * + * @var SftpClient|null + * @since 3.2.0 + **/ + protected ?SftpClient $client = null; + + /** + * The server details + * + * @var object + * @since 3.2.0 + **/ + protected ?object $details = null; + + /** + * Application object. + * + * @var CMSApplication + * @since 3.2.0 + **/ + protected CMSApplication $app; + + /** + * Constructor + * + * @param KeyLoader $key The key loader object. + * @param CMSApplication|null $app The app object. + * + * @since 3.2.0 + */ + public function __construct(KeyLoader $key, ?CMSApplication $app = null) + { + $this->key = $key; + $this->app = $app ?: Factory::getApplication(); + } + + /** + * set the server details + * + * @param object $details The server details + * + * @return Sftp + * @since 3.2.0 + **/ + public function set(object $details): Sftp + { + // we need to make sure the if the details changed to get a new server client + if (!ObjectHelper::equal($details, $this->details)) + { + // set the details + $this->details = $details; + + // reset the client if it was set before + $this->client = null; + } + + return $this; + } + + /** + * move a file to server with the FTP client + * + * @param string $localPath The full local path to the file + * @param string $fileName The file name + * + * @return bool + * @since 3.2.0 + **/ + public function move(string $localPath, string $fileName): bool + { + if ($this->connected() && + ($data = FileHelper::getContent($localPath, null)) !== null) + { + // get the remote path + $path = ''; + if (isset($this->details->path) && + StringHelper::check($this->details->path) && + $this->details->path !== '/') + { + $path = trim((string) $this->details->path); + $path = '/' . trim($path, '/') . '/'; + } + + try + { + return $this->client->put($path . trim($fileName), $data); + } + catch(\Exception $e) + { + $this->app->enqueueMessage( + Text::sprintf('Moving of the %s failed', $fileName) . ': ' . $e->getMessage(), + 'Error' + ); + } + } + + return false; + } + + /** + * Make sure we are connected + * + * @return bool + * @since 3.2.0 + **/ + private function connected(): bool + { + // check if we have a connection + if ($this->client instanceof SftpClient && ($this->client->isConnected() || $this->client->ping())) + { + return true; + } + + $this->client = $this->getClient(); + + return $this->client instanceof SftpClient; + } + + /** + * get the SftpClient object + * + * @return SftpClient|null + * @since 3.2.0 + **/ + private function getClient(): ?SftpClient + { + // make sure we have a host value set + if (isset($this->details->host) && StringHelper::check($this->details->host) && + isset($this->details->username) && StringHelper::check($this->details->username)) + { + // insure the port is set + $port = (int)($this->details->port ?? 22); + + // open the connection + $sftp = new SftpClient($this->details->host, $port); + + // set the passphrase if it exist + $passphrase = (isset($this->details->secret) && StringHelper::check(trim($this->details->secret))) ? trim($this->details->secret) : false; + + // set the password if it exist + $password = (isset($this->details->password) && StringHelper::check(trim($this->details->password))) ? trim($this->details->password) : false; + + // now login based on authentication type + $key = null; + switch($this->details->authentication) + { + case 1: // password + $key = $password ?? null; + $password = null; + break; + case 2: // private key file + case 3: // both password and private key file + if (isset($this->details->private) && StringHelper::check($this->details->private) && + ($private_key = FileHelper::getContent($this->details->private, null)) !== null) + { + try + { + $key = $this->key::load(trim($private_key), $passphrase); + } + catch(\Exception $e) + { + $this->app->enqueueMessage( + Text::_('Loading the private key file failed') . ': ' . $e->getMessage(), + 'Error' + ); + $key = null; + } + } + break; + case 4: // private key field + case 5: // both password and private key field + if (isset($this->details->private_key) && StringHelper::check($this->details->private_key)) + { + try + { + $key = $this->key::load(trim($this->details->private_key), $passphrase); + } + catch(\Exception $e) + { + $this->app->enqueueMessage( + Text::_('Loading the private key text failed') . ': ' . $e->getMessage(), + 'Error' + ); + $key = null; + } + } + break; + } + + // remove any null bites from the username + $this->details->username = trim($this->details->username); + + // login + if (!empty($key) && !empty($password)) + { + try + { + $sftp->login($this->details->username, $key, $password); + return $sftp; + } + catch(\Exception $e) + { + $this->app->enqueueMessage( + Text::_('Login failed') . ': ' . $e->getMessage(), + 'Error' + ); + } + } + elseif (!empty($key)) + { + try + { + $sftp->login($this->details->username, $key); + return $sftp; + } + catch(\Exception $e) + { + $this->app->enqueueMessage( + Text::_('Login failed') . ': ' . $e->getMessage(), + 'Error' + ); + } + } + } + + return null; + } \ No newline at end of file diff --git a/src/490b6aa5-5de7-4be5-a61a-f634f6e004c0/settings.json b/src/490b6aa5-5de7-4be5-a61a-f634f6e004c0/settings.json index 6b3b222..f6a0787 100644 --- a/src/490b6aa5-5de7-4be5-a61a-f634f6e004c0/settings.json +++ b/src/490b6aa5-5de7-4be5-a61a-f634f6e004c0/settings.json @@ -1 +1,46 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "490b6aa5-5de7-4be5-a61a-f634f6e004c0", + "implements": [ + "86ac0760-26f5-4746-9c7f-ce77860f80f8" + ], + "load_selection": null, + "name": "Sftp", + "power_version": "1.0.0", + "system_name": "JCB.Server.Sftp", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "6da44dff-a221-4f22-b9d9-b2fc2a724b4b", + "as": "default" + }, + "use_selection1": { + "use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef", + "as": "default" + }, + "use_selection2": { + "use": "a223b31e-ea1d-4cdf-92ae-5f9becffaff0", + "as": "default" + }, + "use_selection3": { + "use": "91004529-94a9-4590-b842-e7c6b624ecf5", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\Componentbuilder.Server.Sftp", + "description": "Sftp Class\r\n\r\n@since 3.2.0", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "use Joomla\\CMS\\Factory;\r\nuse Joomla\\CMS\\Language\\Text;\r\nuse Joomla\\CMS\\Application\\CMSApplication;", + "composer": { + "composer0": { + "access_point": "phpseclib3\/vendor\/autoload.php", + "namespace": { + "namespace0": { + "use": "phpseclib3\\Net\\SFTP as SftpClient" + } + } + } + } +} \ No newline at end of file diff --git a/src/4d8f38ef-8f3a-463d-8678-0bf087ac6815/README.md b/src/4d8f38ef-8f3a-463d-8678-0bf087ac6815/README.md index 433b69e..577ea92 100644 --- a/src/4d8f38ef-8f3a-463d-8678-0bf087ac6815/README.md +++ b/src/4d8f38ef-8f3a-463d-8678-0bf087ac6815/README.md @@ -1 +1,101 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Crypt (Details) +> namespace: **VDM\Joomla\Componentbuilder\Service** +```uml +@startuml +class Crypt #Gold { + + register(Container $container) : void + + getCrypt(Container $container) : Crypto + + getPassword(Container $container) : Password + + getRandom(Container $container) : Random + + getKeyLoader(Container $container) : KeyLoader + + getBASEAESCBC(Container $container) : BASEAES + + getAesCBC(Container $container) : Aes + + getAesLEGACY(Container $container) : Legacy + + getFOF(Container $container) : FOF +} + +note right of Crypt::register + Registers the service provider with a DI container. + + since: 3.2.0 + return: void +end note + +note left of Crypt::getCrypt + Get the Crypto class + + since: 3.2.0 + return: Crypto +end note + +note right of Crypt::getPassword + Get the Password class + + since: 3.2.0 + return: Password +end note + +note left of Crypt::getRandom + Get the Random class + + since: 3.2.0 + return: Random +end note + +note right of Crypt::getKeyLoader + Get the KeyLoader class + + since: 3.2.0 + return: KeyLoader +end note + +note left of Crypt::getBASEAESCBC + Get the AES Cyper with CBC mode + + since: 3.2.0 + return: BASEAES +end note + +note right of Crypt::getAesCBC + Get the Wrapper AES Cyper with CBC mode + + since: 3.2.0 + return: Aes +end note + +note left of Crypt::getAesLEGACY + Get the Wrapper AES Legacy Cyper with CBC mode + + since: 3.2.0 + return: Legacy +end note + +note right of Crypt::getFOF + Get the FOF AES Cyper with CBC mode + + since: 3.2.0 + return: FOF +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/4d8f38ef-8f3a-463d-8678-0bf087ac6815/code.php b/src/4d8f38ef-8f3a-463d-8678-0bf087ac6815/code.php index 26c1a50..65947df 100644 --- a/src/4d8f38ef-8f3a-463d-8678-0bf087ac6815/code.php +++ b/src/4d8f38ef-8f3a-463d-8678-0bf087ac6815/code.php @@ -9,4 +9,179 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\Componentbuilder\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use phpseclib3\Crypt\AES as BASEAES; +use VDM\Joomla\Componentbuilder\Crypt as Crypto; +use VDM\Joomla\Componentbuilder\Crypt\KeyLoader; +use VDM\Joomla\Componentbuilder\Crypt\Random; +use VDM\Joomla\Componentbuilder\Crypt\Password; +use VDM\Joomla\Componentbuilder\Crypt\FOF; +use VDM\Joomla\Componentbuilder\Crypt\Aes; +use VDM\Joomla\Componentbuilder\Crypt\Aes\Legacy; + + +/** + * Phpseclib Crypt Service Provider + * + * @since 3.2.0 + */ +class Crypt implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Crypto::class, 'Crypt') + ->share('Crypt', [$this, 'getCrypt'], true); + + $container->alias(Random::class, 'Crypt.Random') + ->share('Crypt.Random', [$this, 'getRandom'], true); + + $container->alias(Password::class, 'Crypt.Password') + ->share('Crypt.Password', [$this, 'getPassword'], true); + + $container->alias(KeyLoader::class, 'Crypt.Key') + ->share('Crypt.Key', [$this, 'getKeyLoader'], true); + + $container->alias(BASEAES::class, 'Crypt.AESCBC') + ->share('Crypt.AESCBC', [$this, 'getBASEAESCBC'], false); + + $container->alias(FOF::class, 'Crypt.FOF') + ->share('Crypt.FOF', [$this, 'getFOF'], true); + + $container->alias(Aes::class, 'Crypt.AES.CBC') + ->share('Crypt.AES.CBC', [$this, 'getAesCBC'], true); + + $container->alias(Legacy::class, 'Crypt.AES.LEGACY') + ->share('Crypt.AES.LEGACY', [$this, 'getAesLEGACY'], true); + } + + /** + * Get the Crypto class + * + * @param Container $container The DI container. + * + * @return Crypto + * @since 3.2.0 + */ + public function getCrypt(Container $container): Crypto + { + return new Crypto( + $container->get('Crypt.FOF'), + $container->get('Crypt.AES.CBC'), + $container->get('Crypt.AES.LEGACY'), + $container->get('Crypt.Password') + ); + } + + /** + * Get the Password class + * + * @param Container $container The DI container. + * + * @return Password + * @since 3.2.0 + */ + public function getPassword(Container $container): Password + { + return new Password(); + } + + /** + * Get the Random class + * + * @param Container $container The DI container. + * + * @return Random + * @since 3.2.0 + */ + public function getRandom(Container $container): Random + { + return new Random(); + } + + /** + * Get the KeyLoader class + * + * @param Container $container The DI container. + * + * @return KeyLoader + * @since 3.2.0 + */ + public function getKeyLoader(Container $container): KeyLoader + { + return new KeyLoader(); + } + + /** + * Get the AES Cyper with CBC mode + * + * @param Container $container The DI container. + * + * @return BASEAES + * @since 3.2.0 + */ + public function getBASEAESCBC(Container $container): BASEAES + { + return new BASEAES('cbc'); + } + + /** + * Get the Wrapper AES Cyper with CBC mode + * + * @param Container $container The DI container. + * + * @return Aes + * @since 3.2.0 + */ + public function getAesCBC(Container $container): Aes + { + return new Aes( + $container->get('Crypt.AESCBC'), + $container->get('Crypt.Random') + ); + } + + /** + * Get the Wrapper AES Legacy Cyper with CBC mode + * + * @param Container $container The DI container. + * + * @return Legacy + * @since 3.2.0 + */ + public function getAesLEGACY(Container $container): Legacy + { + return new Legacy( + $container->get('Crypt.AESCBC') + ); + } + + /** + * Get the FOF AES Cyper with CBC mode + * + * @param Container $container The DI container. + * + * @return FOF + * @since 3.2.0 + */ + public function getFOF(Container $container): FOF + { + return new FOF( + $container->get('Crypt.AESCBC'), + $container->get('Crypt.Random') + ); + } + +} + diff --git a/src/4d8f38ef-8f3a-463d-8678-0bf087ac6815/code.power b/src/4d8f38ef-8f3a-463d-8678-0bf087ac6815/code.power index 69309b0..0f9e16a 100644 --- a/src/4d8f38ef-8f3a-463d-8678-0bf087ac6815/code.power +++ b/src/4d8f38ef-8f3a-463d-8678-0bf087ac6815/code.power @@ -1 +1,151 @@ -###CODEPOWER### \ No newline at end of file + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Crypto::class, 'Crypt') + ->share('Crypt', [$this, 'getCrypt'], true); + + $container->alias(Random::class, 'Crypt.Random') + ->share('Crypt.Random', [$this, 'getRandom'], true); + + $container->alias(Password::class, 'Crypt.Password') + ->share('Crypt.Password', [$this, 'getPassword'], true); + + $container->alias(KeyLoader::class, 'Crypt.Key') + ->share('Crypt.Key', [$this, 'getKeyLoader'], true); + + $container->alias(BASEAES::class, 'Crypt.AESCBC') + ->share('Crypt.AESCBC', [$this, 'getBASEAESCBC'], false); + + $container->alias(FOF::class, 'Crypt.FOF') + ->share('Crypt.FOF', [$this, 'getFOF'], true); + + $container->alias(Aes::class, 'Crypt.AES.CBC') + ->share('Crypt.AES.CBC', [$this, 'getAesCBC'], true); + + $container->alias(Legacy::class, 'Crypt.AES.LEGACY') + ->share('Crypt.AES.LEGACY', [$this, 'getAesLEGACY'], true); + } + + /** + * Get the Crypto class + * + * @param Container $container The DI container. + * + * @return Crypto + * @since 3.2.0 + */ + public function getCrypt(Container $container): Crypto + { + return new Crypto( + $container->get('Crypt.FOF'), + $container->get('Crypt.AES.CBC'), + $container->get('Crypt.AES.LEGACY'), + $container->get('Crypt.Password') + ); + } + + /** + * Get the Password class + * + * @param Container $container The DI container. + * + * @return Password + * @since 3.2.0 + */ + public function getPassword(Container $container): Password + { + return new Password(); + } + + /** + * Get the Random class + * + * @param Container $container The DI container. + * + * @return Random + * @since 3.2.0 + */ + public function getRandom(Container $container): Random + { + return new Random(); + } + + /** + * Get the KeyLoader class + * + * @param Container $container The DI container. + * + * @return KeyLoader + * @since 3.2.0 + */ + public function getKeyLoader(Container $container): KeyLoader + { + return new KeyLoader(); + } + + /** + * Get the AES Cyper with CBC mode + * + * @param Container $container The DI container. + * + * @return BASEAES + * @since 3.2.0 + */ + public function getBASEAESCBC(Container $container): BASEAES + { + return new BASEAES('cbc'); + } + + /** + * Get the Wrapper AES Cyper with CBC mode + * + * @param Container $container The DI container. + * + * @return Aes + * @since 3.2.0 + */ + public function getAesCBC(Container $container): Aes + { + return new Aes( + $container->get('Crypt.AESCBC'), + $container->get('Crypt.Random') + ); + } + + /** + * Get the Wrapper AES Legacy Cyper with CBC mode + * + * @param Container $container The DI container. + * + * @return Legacy + * @since 3.2.0 + */ + public function getAesLEGACY(Container $container): Legacy + { + return new Legacy( + $container->get('Crypt.AESCBC') + ); + } + + /** + * Get the FOF AES Cyper with CBC mode + * + * @param Container $container The DI container. + * + * @return FOF + * @since 3.2.0 + */ + public function getFOF(Container $container): FOF + { + return new FOF( + $container->get('Crypt.AESCBC'), + $container->get('Crypt.Random') + ); + } diff --git a/src/4d8f38ef-8f3a-463d-8678-0bf087ac6815/settings.json b/src/4d8f38ef-8f3a-463d-8678-0bf087ac6815/settings.json index 6b3b222..d1c4cdc 100644 --- a/src/4d8f38ef-8f3a-463d-8678-0bf087ac6815/settings.json +++ b/src/4d8f38ef-8f3a-463d-8678-0bf087ac6815/settings.json @@ -1 +1,59 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "4d8f38ef-8f3a-463d-8678-0bf087ac6815", + "implements": [ + "-1" + ], + "load_selection": null, + "name": "Crypt", + "power_version": "1.0.0", + "system_name": "JCB.Service.Crypt", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "d357e796-9f22-4615-9ebc-970b42cbd280", + "as": "Crypto" + }, + "use_selection1": { + "use": "6da44dff-a221-4f22-b9d9-b2fc2a724b4b", + "as": "default" + }, + "use_selection2": { + "use": "c46a42b4-b0d3-48e7-a6fa-af0399e1e66c", + "as": "default" + }, + "use_selection3": { + "use": "fea2b107-3ee4-4ebf-84be-d3f2829c8614", + "as": "default" + }, + "use_selection4": { + "use": "e98b4edc-25b9-49d7-98a0-e42ad3b75efe", + "as": "default" + }, + "use_selection5": { + "use": "a25c82c8-14c2-40df-adae-f832709ab49b", + "as": "default" + }, + "use_selection6": { + "use": "437af6b0-ca02-49d7-8739-4edfc8a9ccb0", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\Componentbuilder.Service.Crypt", + "description": "Phpseclib Crypt Service Provider\r\n\r\n@since 3.2.0", + "implements_custom": "ServiceProviderInterface", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "use Joomla\\DI\\Container;\r\nuse Joomla\\DI\\ServiceProviderInterface;", + "composer": { + "composer0": { + "access_point": "phpseclib3\/vendor\/autoload.php", + "namespace": { + "namespace0": { + "use": "phpseclib3\\Crypt\\AES as BASEAES" + } + } + } + } +} \ No newline at end of file diff --git a/src/66355f70-c26c-4765-ba48-498e3df740ef/README.md b/src/66355f70-c26c-4765-ba48-498e3df740ef/README.md index 433b69e..c4c8d7d 100644 --- a/src/66355f70-c26c-4765-ba48-498e3df740ef/README.md +++ b/src/66355f70-c26c-4765-ba48-498e3df740ef/README.md @@ -1 +1,76 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Server (Details) +> namespace: **VDM\Joomla\Componentbuilder** +```uml +@startuml +class Server #Gold { + # Load $load + # Ftp $ftp + # Sftp $sftp + # User $user + + __construct(Load $load, Ftp $ftp, ...) + + move(int $id, string $localPath, ...) : bool + + legacyMove(string $localPath, string $fileName, ...) : bool +} + +note right of Server::__construct + Constructor + + since: 3.2.0 + + arguments: + Load $load + Ftp $ftp + Sftp $sftp + ?User $user = null +end note + +note right of Server::move + Move File to Server + + since: 3.2.0 + return: bool + + arguments: + int $id + string $localPath + string $fileName + ?int $protocol = null + string $permission = 'core.export' +end note + +note right of Server::legacyMove + Move File to Server (Legacy Signature) + + since: 3.2.0 + return: bool + + arguments: + string $localPath + string $fileName + int $serverID + int $protocol = null + string $permission = 'core.export' +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/66355f70-c26c-4765-ba48-498e3df740ef/code.php b/src/66355f70-c26c-4765-ba48-498e3df740ef/code.php index 26c1a50..46220dc 100644 --- a/src/66355f70-c26c-4765-ba48-498e3df740ef/code.php +++ b/src/66355f70-c26c-4765-ba48-498e3df740ef/code.php @@ -9,4 +9,157 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\Componentbuilder; + + +use Joomla\CMS\Factory as JoomlaFactory; +use Joomla\CMS\User\User; +use VDM\Joomla\Componentbuilder\Server\Load; +use VDM\Joomla\Componentbuilder\Server\Ftp; +use VDM\Joomla\Componentbuilder\Server\Sftp; +use VDM\Joomla\Utilities\StringHelper; + + +/** + * Server Class + * + * @since 3.2.0 + */ +class Server +{ + /** + * The Loader + * + * @var Load + * @since 3.2.0 + */ + protected Load $load; + + /** + * The Ftp object + * + * @var Ftp + * @since 3.2.0 + **/ + protected Ftp $ftp; + + /** + * The Sftp object + * + * @var Sftp + * @since 3.2.0 + **/ + protected Sftp $sftp; + + /** + * Current User object + * + * @var User + * @since 3.2.0 + */ + protected User $user; + + /** + * Constructor + * + * @param Load $load The server details loader object. + * @param Ftp $ftp The server ftp object. + * @param Sftp $sftp The server sftp object. + * @param User|null $user The user object. + * + * @since 3.2.0 + */ + public function __construct(Load $load, Ftp $ftp, Sftp $sftp, ?User $user = null) + { + $this->load = $load; + $this->ftp = $ftp; + $this->sftp = $sftp; + $this->user = $user ?: JoomlaFactory::getUser(); + } + + /** + * Move File to Server + * + * @param int $id The server local id to use + * @param string $localPath The local path to the file + * @param string $fileName The actual file name + * @param int|null $protocol The protocol to use (if set) + * @param string $permission The permission validation area + * + * @return bool true on success + * @since 3.2.0 + */ + public function move(int $id, string $localPath, string $fileName, + ?int $protocol = null, string $permission = 'core.export'): bool + { + // get the server + if ($this->user->authorise($permission, 'com_componentbuilder') && + ( + ( + is_numeric($protocol) && + ($protocol == 1 || $protocol == 2) + ) || ( + ($protocol = $this->load->value($id, 'protocol')) !== null && + ($protocol == 1 || $protocol == 2) + ) + ) + ) + { + // use the FTP protocol + if (1 == $protocol) + { + $protocol = 'ftp'; + $fields = [ + 'name', + 'signature' + ]; + } + // use the SFTP protocol + else + { + $protocol = 'sftp'; + $fields = [ + 'name', + 'authentication', + 'username', + 'host', + 'password', + 'path', + 'port', + 'private', + 'private_key', + 'secret' + ]; + } + + // get the details + if (StringHelper::check($protocol) && ($details = $this->load->item($id, $fields)) !== null) + { + // now move the file + return $this->{$protocol}->set($details)->move($localPath, $fileName); + } + } + + return false; + } + + /** + * Move File to Server (Legacy Signature) + * + * @param string $localPath The local path to the file + * @param string $fileName The actual file name + * @param int $serverID The server local id to use + * @param int $protocol The server protocol to use + * @param string $permission The permission validation area + * + * @return bool true on success + * @since 3.2.0 + * @deprecated 4.0 + */ + public function legacyMove($localPath, $fileName, $serverID, $protocol = null, $permission = 'core.export'): bool + { + return $this->move($serverID, $localPath, $fileName, $protocol, $permission); + } + +} + diff --git a/src/66355f70-c26c-4765-ba48-498e3df740ef/code.power b/src/66355f70-c26c-4765-ba48-498e3df740ef/code.power index 69309b0..2cf16ee 100644 --- a/src/66355f70-c26c-4765-ba48-498e3df740ef/code.power +++ b/src/66355f70-c26c-4765-ba48-498e3df740ef/code.power @@ -1 +1,133 @@ -###CODEPOWER### \ No newline at end of file + /** + * The Loader + * + * @var Load + * @since 3.2.0 + */ + protected Load $load; + + /** + * The Ftp object + * + * @var Ftp + * @since 3.2.0 + **/ + protected Ftp $ftp; + + /** + * The Sftp object + * + * @var Sftp + * @since 3.2.0 + **/ + protected Sftp $sftp; + + /** + * Current User object + * + * @var User + * @since 3.2.0 + */ + protected User $user; + + /** + * Constructor + * + * @param Load $load The server details loader object. + * @param Ftp $ftp The server ftp object. + * @param Sftp $sftp The server sftp object. + * @param User|null $user The user object. + * + * @since 3.2.0 + */ + public function __construct(Load $load, Ftp $ftp, Sftp $sftp, ?User $user = null) + { + $this->load = $load; + $this->ftp = $ftp; + $this->sftp = $sftp; + $this->user = $user ?: JoomlaFactory::getUser(); + } + + /** + * Move File to Server + * + * @param int $id The server local id to use + * @param string $localPath The local path to the file + * @param string $fileName The actual file name + * @param int|null $protocol The protocol to use (if set) + * @param string $permission The permission validation area + * + * @return bool true on success + * @since 3.2.0 + */ + public function move(int $id, string $localPath, string $fileName, + ?int $protocol = null, string $permission = 'core.export'): bool + { + // get the server + if ($this->user->authorise($permission, 'com_componentbuilder') && + ( + ( + is_numeric($protocol) && + ($protocol == 1 || $protocol == 2) + ) || ( + ($protocol = $this->load->value($id, 'protocol')) !== null && + ($protocol == 1 || $protocol == 2) + ) + ) + ) + { + // use the FTP protocol + if (1 == $protocol) + { + $protocol = 'ftp'; + $fields = [ + 'name', + 'signature' + ]; + } + // use the SFTP protocol + else + { + $protocol = 'sftp'; + $fields = [ + 'name', + 'authentication', + 'username', + 'host', + 'password', + 'path', + 'port', + 'private', + 'private_key', + 'secret' + ]; + } + + // get the details + if (StringHelper::check($protocol) && ($details = $this->load->item($id, $fields)) !== null) + { + // now move the file + return $this->{$protocol}->set($details)->move($localPath, $fileName); + } + } + + return false; + } + + /** + * Move File to Server (Legacy Signature) + * + * @param string $localPath The local path to the file + * @param string $fileName The actual file name + * @param int $serverID The server local id to use + * @param int $protocol The server protocol to use + * @param string $permission The permission validation area + * + * @return bool true on success + * @since 3.2.0 + * @deprecated 4.0 + */ + public function legacyMove($localPath, $fileName, $serverID, $protocol = null, $permission = 'core.export'): bool + { + return $this->move($serverID, $localPath, $fileName, $protocol, $permission); + } diff --git a/src/66355f70-c26c-4765-ba48-498e3df740ef/settings.json b/src/66355f70-c26c-4765-ba48-498e3df740ef/settings.json index 6b3b222..46e1ee5 100644 --- a/src/66355f70-c26c-4765-ba48-498e3df740ef/settings.json +++ b/src/66355f70-c26c-4765-ba48-498e3df740ef/settings.json @@ -1 +1,35 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "66355f70-c26c-4765-ba48-498e3df740ef", + "implements": null, + "load_selection": null, + "name": "Server", + "power_version": "1.0.0", + "system_name": "JCB.Server", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "a3414824-e99d-4878-b3d1-b5deef0cae17", + "as": "default" + }, + "use_selection1": { + "use": "11be6be3-ee3e-4771-8663-5545b76b73ab", + "as": "default" + }, + "use_selection2": { + "use": "490b6aa5-5de7-4be5-a61a-f634f6e004c0", + "as": "default" + }, + "use_selection3": { + "use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\Componentbuilder.Server", + "description": "Server Class\r\n\r\n@since 3.2.0", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "use Joomla\\CMS\\Factory as JoomlaFactory;\r\nuse Joomla\\CMS\\User\\User;", + "composer": "" +} \ No newline at end of file diff --git a/src/6da44dff-a221-4f22-b9d9-b2fc2a724b4b/README.md b/src/6da44dff-a221-4f22-b9d9-b2fc2a724b4b/README.md index 433b69e..d9d4e30 100644 --- a/src/6da44dff-a221-4f22-b9d9-b2fc2a724b4b/README.md +++ b/src/6da44dff-a221-4f22-b9d9-b2fc2a724b4b/README.md @@ -1 +1,30 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class KeyLoader (Details) +> namespace: **VDM\Joomla\Componentbuilder\Crypt** +> extends: **PublicKeyLoader** +```uml +@startuml +class KeyLoader #Gold { +} + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/6da44dff-a221-4f22-b9d9-b2fc2a724b4b/code.php b/src/6da44dff-a221-4f22-b9d9-b2fc2a724b4b/code.php index 26c1a50..e6ed5f0 100644 --- a/src/6da44dff-a221-4f22-b9d9-b2fc2a724b4b/code.php +++ b/src/6da44dff-a221-4f22-b9d9-b2fc2a724b4b/code.php @@ -9,4 +9,18 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\Componentbuilder\Crypt; + + +use phpseclib3\Crypt\PublicKeyLoader; + + +/** + * KeyLoader Class + * + * @since 3.2.0 + */ +class KeyLoader extends PublicKeyLoader +{ +} + diff --git a/src/6da44dff-a221-4f22-b9d9-b2fc2a724b4b/settings.json b/src/6da44dff-a221-4f22-b9d9-b2fc2a724b4b/settings.json index 6b3b222..b496bbe 100644 --- a/src/6da44dff-a221-4f22-b9d9-b2fc2a724b4b/settings.json +++ b/src/6da44dff-a221-4f22-b9d9-b2fc2a724b4b/settings.json @@ -1 +1,28 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "-1", + "guid": "6da44dff-a221-4f22-b9d9-b2fc2a724b4b", + "implements": null, + "load_selection": null, + "name": "KeyLoader", + "power_version": "1.0.0", + "system_name": "JCB.Crypt.KeyLoader", + "type": "class", + "use_selection": null, + "namespace": "VDM\\Joomla\\Componentbuilder.Crypt.KeyLoader", + "description": "KeyLoader Class\r\n\r\n@since 3.2.0", + "extends_custom": "PublicKeyLoader", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "", + "composer": { + "composer0": { + "access_point": "phpseclib3\/vendor\/autoload.php", + "namespace": { + "namespace0": { + "use": "phpseclib3\\Crypt\\PublicKeyLoader" + } + } + } + } +} \ No newline at end of file diff --git a/src/a25c82c8-14c2-40df-adae-f832709ab49b/README.md b/src/a25c82c8-14c2-40df-adae-f832709ab49b/README.md index 433b69e..2185778 100644 --- a/src/a25c82c8-14c2-40df-adae-f832709ab49b/README.md +++ b/src/a25c82c8-14c2-40df-adae-f832709ab49b/README.md @@ -1 +1,55 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Aes (Details) +> namespace: **VDM\Joomla\Componentbuilder\Crypt** +```uml +@startuml +class Aes #Gold { + # BASEAES $aes + # Random $random + # int $size + + __construct(BASEAES $aes, Random $random) + + encrypt(string $string, string $key) : string + + decrypt(string $string, string $key) : ?string +} + +note right of Aes::__construct + Constructor + + since: 3.2.0 +end note + +note right of Aes::encrypt + Encrypt a string as needed + + since: 3.2.0 + return: string +end note + +note right of Aes::decrypt + Decrypt a string as needed + + since: 3.2.0 + return: ?string +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/a25c82c8-14c2-40df-adae-f832709ab49b/code.php b/src/a25c82c8-14c2-40df-adae-f832709ab49b/code.php index 26c1a50..893691e 100644 --- a/src/a25c82c8-14c2-40df-adae-f832709ab49b/code.php +++ b/src/a25c82c8-14c2-40df-adae-f832709ab49b/code.php @@ -9,4 +9,128 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\Componentbuilder\Crypt; + + + +use phpseclib3\Crypt\AES as BASEAES; +use phpseclib3\Exception\BadDecryptionException; +use VDM\Joomla\Componentbuilder\Crypt\Random; +use VDM\Joomla\Componentbuilder\Interfaces\Cryptinterface; + + +/** + * Class for Aes Encryption + * + * @since 3.2.0 + */ +class Aes implements Cryptinterface +{ + /** + * The Aes class + * + * @var BASEAES + * @since 3.2.0 + */ + protected BASEAES $aes; + + /** + * The Random class + * + * @var Random + * @since 3.2.0 + */ + protected Random $random; + + /** + * The block size + * + * @var int + * @since 3.2.0 + */ + protected int $size = 256; + + /** + * Constructor + * + * @param BASEAES $aes The Aes class + * @param Random $random The Random class + * + * @since 3.2.0 + */ + public function __construct(BASEAES $aes, Random $random) + { + $this->aes = $aes; + $this->random = $random; + + // we set the length once + $this->aes->setKeyLength($this->size); + + // enable padding + $this->aes->enablePadding(); + } + + /** + * Encrypt a string as needed + * + * @param string $string The string to encrypt + * @param string $key The encryption key + * + * @return string + * @since 3.2.0 + **/ + public function encrypt(string $string, string $key): string + { + // we get the IV length + $iv_length = (int) $this->aes->getBlockLength() >> 3; + + // get the IV value + $iv = $this->random::string($iv_length); + + // Load the IV + $this->aes->setIV($iv); + + // set the password + $this->aes->setPassword($key, 'pbkdf2', 'sha256', 'VastDevelopmentMethod/salt'); + + // encrypt the string, and base 64 encode the result + return base64_encode($iv . $this->aes->encrypt($string)); + } + + /** + * Decrypt a string as needed + * + * @param string $string The string to decrypt + * @param string $key The decryption key + * + * @return string|null + * @since 3.2.0 + **/ + public function decrypt(string $string, string $key): ?string + { + // we get the IV length + $iv_length = (int) $this->aes->getBlockLength() >> 3; + + // remove base 64 encoding + $string = base64_decode($string); + + // get the IV + $iv = substr($string, 0, $iv_length); + + // remove the IV + $string = substr($string, $iv_length); + + // set the IV + $this->aes->setIV($iv); + + // set the password + $this->aes->setPassword($key, 'pbkdf2', 'sha256', 'VastDevelopmentMethod/salt'); + + try { + return $this->aes->decrypt($string); + } catch (\Exception $ex) { + return null; + } + } +} + diff --git a/src/a25c82c8-14c2-40df-adae-f832709ab49b/code.power b/src/a25c82c8-14c2-40df-adae-f832709ab49b/code.power index 69309b0..2c869c0 100644 --- a/src/a25c82c8-14c2-40df-adae-f832709ab49b/code.power +++ b/src/a25c82c8-14c2-40df-adae-f832709ab49b/code.power @@ -1 +1,106 @@ -###CODEPOWER### \ No newline at end of file + /** + * The Aes class + * + * @var BASEAES + * @since 3.2.0 + */ + protected BASEAES $aes; + + /** + * The Random class + * + * @var Random + * @since 3.2.0 + */ + protected Random $random; + + /** + * The block size + * + * @var int + * @since 3.2.0 + */ + protected int $size = 256; + + /** + * Constructor + * + * @param BASEAES $aes The Aes class + * @param Random $random The Random class + * + * @since 3.2.0 + */ + public function __construct(BASEAES $aes, Random $random) + { + $this->aes = $aes; + $this->random = $random; + + // we set the length once + $this->aes->setKeyLength($this->size); + + // enable padding + $this->aes->enablePadding(); + } + + /** + * Encrypt a string as needed + * + * @param string $string The string to encrypt + * @param string $key The encryption key + * + * @return string + * @since 3.2.0 + **/ + public function encrypt(string $string, string $key): string + { + // we get the IV length + $iv_length = (int) $this->aes->getBlockLength() >> 3; + + // get the IV value + $iv = $this->random::string($iv_length); + + // Load the IV + $this->aes->setIV($iv); + + // set the password + $this->aes->setPassword($key, 'pbkdf2', 'sha256', 'VastDevelopmentMethod/salt'); + + // encrypt the string, and base 64 encode the result + return base64_encode($iv . $this->aes->encrypt($string)); + } + + /** + * Decrypt a string as needed + * + * @param string $string The string to decrypt + * @param string $key The decryption key + * + * @return string|null + * @since 3.2.0 + **/ + public function decrypt(string $string, string $key): ?string + { + // we get the IV length + $iv_length = (int) $this->aes->getBlockLength() >> 3; + + // remove base 64 encoding + $string = base64_decode($string); + + // get the IV + $iv = substr($string, 0, $iv_length); + + // remove the IV + $string = substr($string, $iv_length); + + // set the IV + $this->aes->setIV($iv); + + // set the password + $this->aes->setPassword($key, 'pbkdf2', 'sha256', 'VastDevelopmentMethod/salt'); + + try { + return $this->aes->decrypt($string); + } catch (\Exception $ex) { + return null; + } + } \ No newline at end of file diff --git a/src/a25c82c8-14c2-40df-adae-f832709ab49b/settings.json b/src/a25c82c8-14c2-40df-adae-f832709ab49b/settings.json index 6b3b222..83e4158 100644 --- a/src/a25c82c8-14c2-40df-adae-f832709ab49b/settings.json +++ b/src/a25c82c8-14c2-40df-adae-f832709ab49b/settings.json @@ -1 +1,37 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "a25c82c8-14c2-40df-adae-f832709ab49b", + "implements": [ + "81de8f57-dd9c-4a17-964f-848cd4a0743b" + ], + "load_selection": null, + "name": "Aes", + "power_version": "1.0.0", + "system_name": "JCB.Crypt.Aes", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "c46a42b4-b0d3-48e7-a6fa-af0399e1e66c", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\Componentbuilder.Crypt.Aes", + "description": "Class for Aes Encryption\r\n\r\n@since 3.2.0", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "", + "composer": { + "composer0": { + "access_point": "phpseclib3\/vendor\/autoload.php", + "namespace": { + "namespace0": { + "use": "phpseclib3\\Crypt\\AES as BASEAES" + }, + "namespace1": { + "use": "phpseclib3\\Exception\\BadDecryptionException" + } + } + } + } +} \ No newline at end of file diff --git a/src/a3414824-e99d-4878-b3d1-b5deef0cae17/README.md b/src/a3414824-e99d-4878-b3d1-b5deef0cae17/README.md index 433b69e..0d91de5 100644 --- a/src/a3414824-e99d-4878-b3d1-b5deef0cae17/README.md +++ b/src/a3414824-e99d-4878-b3d1-b5deef0cae17/README.md @@ -1 +1,64 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Load (Details) +> namespace: **VDM\Joomla\Componentbuilder\Server** +```uml +@startuml +class Load #Gold { + # Database $db + # Model $model + + __construct(?Database $db = null, ?Model $model = null) + + value(int $id, string $field) : mixed|null + + item(int $id, array $fields) : ?object + # setDatabaseFields(array $fields, string $key = 'a') : array +} + +note right of Load::__construct + Constructor + + since: 3.2.0 +end note + +note right of Load::value + Get a value from a given server +Example: $this->value(23, 'protocol'); + + since: 3.2.0 + return: mixed|null +end note + +note right of Load::item + Get values from a given server +Example: $this->item(23, ['name', 'of', 'fields']); + + since: 3.2.0 + return: ?object +end note + +note right of Load::setDatabaseFields + Set Fields ready to use in database call + + since: 3.2.0 + return: array +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/a3414824-e99d-4878-b3d1-b5deef0cae17/code.php b/src/a3414824-e99d-4878-b3d1-b5deef0cae17/code.php index 26c1a50..7abbea0 100644 --- a/src/a3414824-e99d-4878-b3d1-b5deef0cae17/code.php +++ b/src/a3414824-e99d-4878-b3d1-b5deef0cae17/code.php @@ -9,4 +9,114 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\Componentbuilder\Server; + + +use VDM\Joomla\Componentbuilder\Compiler\Factory; +use VDM\Joomla\Database\Load as Database; +use VDM\Joomla\Componentbuilder\Server\Model\Load as Model; + + +/** + * Server Load Class + * + * @since 3.2.0 + */ +class Load +{ + /** + * Database Load + * + * @var Database + * @since 3.2.0 + */ + protected Database $db; + + /** + * Model Class + * + * @var Model + * @since 3.2.0 + */ + protected Model $model; + + /** + * Constructor + * + * @param Database|null $db The database object. + * @param Model|null $model The core crypt object. + * + * @since 3.2.0 + */ + public function __construct(?Database $db = null, ?Model $model = null) + { + $this->db = $db ?: Factory::_('Load'); + $this->model = $model ?: Factory::_('Model.Server.Load'); + } + + /** + * Get a value from a given server + * Example: $this->value(23, 'protocol'); + * + * @param int $id The item ID + * @param string $field The table field + * + * @return mixed|null + * @since 3.2.0 + */ + public function value(int $id, string $field) + { + if ($id > 0 && ($value = $this->db->value( + $this->setDatabaseFields([$field]), ['a' => 'server'], ['a.id' => $id] + )) !== null) + { + return $this->model->value($value, $field, 'server'); + } + + return null; + } + + /** + * Get values from a given server + * Example: $this->item(23, ['name', 'of', 'fields']); + * + * @param int $id The item ID + * @param array $fields The table fields + * + * @return object|null + * @since 3.2.0 + */ + public function item(int $id, array $fields): ?object + { + if ($id > 0 && ($item = $this->db->item( + $this->setDatabaseFields($fields), ['a' => 'server'], ['a.id' => $id] + )) !== null) + { + return $this->model->item($item, 'server'); + } + + return null; + } + + /** + * Set Fields ready to use in database call + * + * @param array $fields The table + * @param string $key The table key to which the fields belong + * + * @return array + * @since 3.2.0 + */ + protected function setDatabaseFields(array $fields, string $key = 'a'): array + { + $bucket = []; + foreach ($fields as $field) + { + $bucket[$key . '.' . $field] = $field; + } + + return $bucket; + } + +} + diff --git a/src/a3414824-e99d-4878-b3d1-b5deef0cae17/code.power b/src/a3414824-e99d-4878-b3d1-b5deef0cae17/code.power index 69309b0..4efddbe 100644 --- a/src/a3414824-e99d-4878-b3d1-b5deef0cae17/code.power +++ b/src/a3414824-e99d-4878-b3d1-b5deef0cae17/code.power @@ -1 +1,93 @@ -###CODEPOWER### \ No newline at end of file + /** + * Database Load + * + * @var Database + * @since 3.2.0 + */ + protected Database $db; + + /** + * Model Class + * + * @var Model + * @since 3.2.0 + */ + protected Model $model; + + /** + * Constructor + * + * @param Database|null $db The database object. + * @param Model|null $model The core crypt object. + * + * @since 3.2.0 + */ + public function __construct(?Database $db = null, ?Model $model = null) + { + $this->db = $db ?: Factory::_('Load'); + $this->model = $model ?: Factory::_('Model.Server.Load'); + } + + /** + * Get a value from a given server + * Example: $this->value(23, 'protocol'); + * + * @param int $id The item ID + * @param string $field The table field + * + * @return mixed|null + * @since 3.2.0 + */ + public function value(int $id, string $field) + { + if ($id > 0 && ($value = $this->db->value( + $this->setDatabaseFields([$field]), ['a' => 'server'], ['a.id' => $id] + )) !== null) + { + return $this->model->value($value, $field, 'server'); + } + + return null; + } + + /** + * Get values from a given server + * Example: $this->item(23, ['name', 'of', 'fields']); + * + * @param int $id The item ID + * @param array $fields The table fields + * + * @return object|null + * @since 3.2.0 + */ + public function item(int $id, array $fields): ?object + { + if ($id > 0 && ($item = $this->db->item( + $this->setDatabaseFields($fields), ['a' => 'server'], ['a.id' => $id] + )) !== null) + { + return $this->model->item($item, 'server'); + } + + return null; + } + + /** + * Set Fields ready to use in database call + * + * @param array $fields The table + * @param string $key The table key to which the fields belong + * + * @return array + * @since 3.2.0 + */ + protected function setDatabaseFields(array $fields, string $key = 'a'): array + { + $bucket = []; + foreach ($fields as $field) + { + $bucket[$key . '.' . $field] = $field; + } + + return $bucket; + } diff --git a/src/a3414824-e99d-4878-b3d1-b5deef0cae17/settings.json b/src/a3414824-e99d-4878-b3d1-b5deef0cae17/settings.json index 6b3b222..c11a03f 100644 --- a/src/a3414824-e99d-4878-b3d1-b5deef0cae17/settings.json +++ b/src/a3414824-e99d-4878-b3d1-b5deef0cae17/settings.json @@ -1 +1,31 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "0", + "guid": "a3414824-e99d-4878-b3d1-b5deef0cae17", + "implements": null, + "load_selection": null, + "name": "Load", + "power_version": "1.0.0", + "system_name": "JCB.Server.Load", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac", + "as": "default" + }, + "use_selection1": { + "use": "06f8eada-d59b-441c-b287-0aea1793da5a", + "as": "Database" + }, + "use_selection2": { + "use": "f37ee8b7-2909-4319-bdf8-769bd7635490", + "as": "Model" + } + }, + "namespace": "VDM\\Joomla\\Componentbuilder.Server.Load", + "description": "Server Load Class\r\n\r\n@since 3.2.0", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "", + "composer": "" +} \ No newline at end of file diff --git a/src/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c/README.md b/src/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c/README.md index 433b69e..32f02e8 100644 --- a/src/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c/README.md +++ b/src/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c/README.md @@ -1 +1,30 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Random (Details) +> namespace: **VDM\Joomla\Componentbuilder\Crypt** +> extends: **CryptRandom** +```uml +@startuml +class Random #Gold { +} + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c/code.php b/src/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c/code.php index 26c1a50..4815684 100644 --- a/src/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c/code.php +++ b/src/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c/code.php @@ -9,4 +9,18 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\Componentbuilder\Crypt; + + +use phpseclib3\Crypt\Random as CryptRandom; + + +/** + * Random Class + * + * @since 3.2.0 + */ +class Random extends CryptRandom +{ +} + diff --git a/src/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c/settings.json b/src/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c/settings.json index 6b3b222..d94164d 100644 --- a/src/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c/settings.json +++ b/src/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c/settings.json @@ -1 +1,28 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "-1", + "guid": "c46a42b4-b0d3-48e7-a6fa-af0399e1e66c", + "implements": null, + "load_selection": null, + "name": "Random", + "power_version": "1.0.0", + "system_name": "JCB.Crypt.Random", + "type": "class", + "use_selection": null, + "namespace": "VDM\\Joomla\\Componentbuilder.Crypt.Random", + "description": "Random Class\r\n\r\n@since 3.2.0", + "extends_custom": "CryptRandom", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "", + "composer": { + "composer0": { + "access_point": "phpseclib3\/vendor\/autoload.php", + "namespace": { + "namespace0": { + "use": "phpseclib3\\Crypt\\Random as CryptRandom" + } + } + } + } +} \ No newline at end of file diff --git a/src/d357e796-9f22-4615-9ebc-970b42cbd280/README.md b/src/d357e796-9f22-4615-9ebc-970b42cbd280/README.md index 433b69e..b9ac7aa 100644 --- a/src/d357e796-9f22-4615-9ebc-970b42cbd280/README.md +++ b/src/d357e796-9f22-4615-9ebc-970b42cbd280/README.md @@ -1 +1,130 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Crypt (Details) +> namespace: **VDM\Joomla\Componentbuilder** +```uml +@startuml +class Crypt #Gold { + # FOF $fof + # Aes $aes + # Legacy $legacy + # Password $password + # array $options + # array $passwords + + __construct(FOF $fof, Aes $aes, ...) + + encrypt(string $string, string $method, ...) : string + + decrypt(string $string, string $method, ...) : ?string + + exist(string $method) : bool + - getClassName(string $method) : ?string + - getClassNameFromRegistry(string $method) : ?string + - getClassNameFromOptions(string $method) : ?string + - getPassword(string $method, ?string $password = null) : ?string + - getPasswordKey(string $method) : string + - name(string $method) : string +} + +note right of Crypt::__construct + Constructor + + since: 3.2.0 + + arguments: + FOF $fof + Aes $aes + Legacy $legacy + Password $password +end note + +note left of Crypt::encrypt + Encrypt a string as needed + + since: 3.2.0 + return: string + + arguments: + string $string + string $method + ?string $password = null +end note + +note right of Crypt::decrypt + Decrypt a string as needed + + since: 3.2.0 + return: ?string + + arguments: + string $string + string $method + ?string $default = null +end note + +note left of Crypt::exist + Check if a decryption method exist and is supported + + since: 3.2.0 + return: bool +end note + +note right of Crypt::getClassName + Get crypto class name to use + + since: 3.2.0 + return: ?string +end note + +note left of Crypt::getClassNameFromRegistry + Get the crypto class name from the registry + + since: 3.2.0 + return: ?string +end note + +note right of Crypt::getClassNameFromOptions + Get the crypto class name for the given encryption method and options + + since: 3.2.0 + return: ?string +end note + +note left of Crypt::getPassword + Get the password + + since: 3.2.0 + return: ?string +end note + +note right of Crypt::getPasswordKey + Get the key + + since: 3.2.0 + return: string +end note + +note left of Crypt::name + Get the class name + + since: 3.2.0 + return: string +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/d357e796-9f22-4615-9ebc-970b42cbd280/code.php b/src/d357e796-9f22-4615-9ebc-970b42cbd280/code.php index 26c1a50..f126084 100644 --- a/src/d357e796-9f22-4615-9ebc-970b42cbd280/code.php +++ b/src/d357e796-9f22-4615-9ebc-970b42cbd280/code.php @@ -9,4 +9,276 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\Componentbuilder; + + +use VDM\Joomla\Componentbuilder\Crypt\FOF; +use VDM\Joomla\Componentbuilder\Crypt\Aes; +use VDM\Joomla\Componentbuilder\Crypt\Aes\Legacy; +use VDM\Joomla\Componentbuilder\Crypt\Password; +use VDM\Joomla\Componentbuilder\Interfaces\Cryptinterface; +use VDM\Joomla\Utilities\StringHelper; + + +/** + * Crypto Class + * + * @since 3.2.0 + */ +class Crypt +{ + /** + * The Crypt AES FOF class + * replacement class + * + * @var FOF + * @since 3.2.0 + */ + protected FOF $fof; + + /** + * The Crypt AES CBC class + * + * @var Aes + * @since 3.2.0 + */ + protected Aes $aes; + + /** + * The Crypt AES Legacy class + * + * @var Legacy + * @since 3.2.0 + */ + protected Legacy $legacy; + + /** + * The Password class + * + * @var Password + * @since 3.2.0 + */ + protected Password $password; + + /** + * Active encryption options + * + * @var array + * @since 3.2.0 + */ + protected array $options = [ + 'basic' => 'fof', + 'medium' => 'fof', + 'local' => 'aes' + ]; + + /** + * Active passwords + * + * @var array + * @since 3.2.0 + */ + protected array $passwords = []; + + /** + * Constructor + * + * @param FOF $fof The FOF class + * @param Aes $aes The AES CBC class + * @param Legacy $legacy The AES Legacy class + * @param Password $password The Password class + * + * @since 3.2.0 + */ + public function __construct(FOF $fof, Aes $aes, Legacy $legacy, Password $password) + { + $this->fof = $fof; + $this->aes = $aes; + $this->legacy = $legacy; + $this->password = $password; + } + + /** + * Encrypt a string as needed + * + * @param string $string The string to encrypt + * @param string $method The encryption method to use + * @param string|null $password The password + * + * @return string + * @since 3.2.0 + **/ + public function encrypt(string $string, string $method, + ?string $password = null): string + { + if (($password = $this->getPassword($method, $password)) !== null + && ($name = $this->getClassName($method)) !== null) + { + return $this->{$name}->encrypt($string, $password); + } + + return $string; + } + + /** + * Decrypt a string as needed + * + * @param string $string The string to decrypt + * @param string $method The encryption method to use + * @param string|null $default The default password + * + * @return string|null + * @since 3.2.0 + **/ + public function decrypt(string $string, string $method, + ?string $default = null): ?string + { + if (($password = $this->getPassword($method, $default)) !== null + && ($name = $this->getClassName($method)) !== null) + { + return $this->{$name}->decrypt($string, $password); + } + + return null; + } + + /** + * Check if a decryption method exist and is supported + * + * @param string $method The encryption method to find + * + * @return bool true if it exist + * @since 3.2.0 + **/ + public function exist(string $method): bool + { + return is_string($this->getClassName($method)) ?? false; + } + + /** + * Get crypto class name to use + * + * @param string $method The encryption method to find + * + * @return string|null The crypto class name + * @since 3.2.0 + **/ + private function getClassName(string $method): ?string + { + if (($name = $this->getClassNameFromRegistry($method)) !== null) + { + return $name; + } + + return $this->getClassNameFromOptions($method); + } + + /** + * Get the crypto class name from the registry + * + * @param string $method The encryption method to use + * + * @return string|null The crypto class name, or null if not found + * @since 3.2.0 + **/ + private function getClassNameFromRegistry(string $method): ?string + { + $name = $this->name($method); + + if (isset($this->{$name}) && $this->{$name} instanceof Cryptinterface) + { + return $name; + } + + return null; + } + + /** + * Get the crypto class name for the given encryption method and options + * + * @param string $method The encryption method to use + * + * @return string|null The crypto class name, or null if not found + * @since 3.2.0 + **/ + private function getClassNameFromOptions(string $method): ?string + { + $key = $this->getPasswordKey($method); + + if (isset($this->options[$key])) + { + $name = $this->options[$key]; + + if (isset($this->{$name}) && $this->{$name} instanceof Cryptinterface) + { + return $name; + } + } + + return null; + } + + /** + * Get the password + * + * @param string $method The encryption method to find + * @param string|null $password The password + * + * @return string|null the password or null + * @since 3.2.0 + **/ + private function getPassword(string $method, ?string $password = null): ?string + { + if (StringHelper::check($password)) + { + return $password; + } + + // get password key name + $key = $this->getPasswordKey($method); + + if (empty($this->passwords[$key])) + { + $this->passwords[$key] = $this->password->get($key); + } + + return $this->passwords[$key]; + } + + /** + * Get the key + * + * @param string $method The encryption method to find + * + * @return string the password key name + * @since 3.2.0 + **/ + private function getPasswordKey(string $method): string + { + if (($pos = strpos($method, '.')) !== false) + { + return substr($method, 0, $pos); + } + + return $method; + } + + /** + * Get the class name + * + * @param string $method The encryption method to find + * + * @return string the class name + * @since 3.2.0 + **/ + private function name(string $method): string + { + if (($pos = strpos($method, '.')) !== false) + { + return substr($method, $pos + 1); + } + + return $method; + } +} + diff --git a/src/d357e796-9f22-4615-9ebc-970b42cbd280/code.power b/src/d357e796-9f22-4615-9ebc-970b42cbd280/code.power index 69309b0..957768d 100644 --- a/src/d357e796-9f22-4615-9ebc-970b42cbd280/code.power +++ b/src/d357e796-9f22-4615-9ebc-970b42cbd280/code.power @@ -1 +1,253 @@ -###CODEPOWER### \ No newline at end of file + /** + * The Crypt AES FOF class + * replacement class + * + * @var FOF + * @since 3.2.0 + */ + protected FOF $fof; + + /** + * The Crypt AES CBC class + * + * @var Aes + * @since 3.2.0 + */ + protected Aes $aes; + + /** + * The Crypt AES Legacy class + * + * @var Legacy + * @since 3.2.0 + */ + protected Legacy $legacy; + + /** + * The Password class + * + * @var Password + * @since 3.2.0 + */ + protected Password $password; + + /** + * Active encryption options + * + * @var array + * @since 3.2.0 + */ + protected array $options = [ + 'basic' => 'fof', + 'medium' => 'fof', + 'local' => 'aes' + ]; + + /** + * Active passwords + * + * @var array + * @since 3.2.0 + */ + protected array $passwords = []; + + /** + * Constructor + * + * @param FOF $fof The FOF class + * @param Aes $aes The AES CBC class + * @param Legacy $legacy The AES Legacy class + * @param Password $password The Password class + * + * @since 3.2.0 + */ + public function __construct(FOF $fof, Aes $aes, Legacy $legacy, Password $password) + { + $this->fof = $fof; + $this->aes = $aes; + $this->legacy = $legacy; + $this->password = $password; + } + + /** + * Encrypt a string as needed + * + * @param string $string The string to encrypt + * @param string $method The encryption method to use + * @param string|null $password The password + * + * @return string + * @since 3.2.0 + **/ + public function encrypt(string $string, string $method, + ?string $password = null): string + { + if (($password = $this->getPassword($method, $password)) !== null + && ($name = $this->getClassName($method)) !== null) + { + return $this->{$name}->encrypt($string, $password); + } + + return $string; + } + + /** + * Decrypt a string as needed + * + * @param string $string The string to decrypt + * @param string $method The encryption method to use + * @param string|null $default The default password + * + * @return string|null + * @since 3.2.0 + **/ + public function decrypt(string $string, string $method, + ?string $default = null): ?string + { + if (($password = $this->getPassword($method, $default)) !== null + && ($name = $this->getClassName($method)) !== null) + { + return $this->{$name}->decrypt($string, $password); + } + + return null; + } + + /** + * Check if a decryption method exist and is supported + * + * @param string $method The encryption method to find + * + * @return bool true if it exist + * @since 3.2.0 + **/ + public function exist(string $method): bool + { + return is_string($this->getClassName($method)) ?? false; + } + + /** + * Get crypto class name to use + * + * @param string $method The encryption method to find + * + * @return string|null The crypto class name + * @since 3.2.0 + **/ + private function getClassName(string $method): ?string + { + if (($name = $this->getClassNameFromRegistry($method)) !== null) + { + return $name; + } + + return $this->getClassNameFromOptions($method); + } + + /** + * Get the crypto class name from the registry + * + * @param string $method The encryption method to use + * + * @return string|null The crypto class name, or null if not found + * @since 3.2.0 + **/ + private function getClassNameFromRegistry(string $method): ?string + { + $name = $this->name($method); + + if (isset($this->{$name}) && $this->{$name} instanceof Cryptinterface) + { + return $name; + } + + return null; + } + + /** + * Get the crypto class name for the given encryption method and options + * + * @param string $method The encryption method to use + * + * @return string|null The crypto class name, or null if not found + * @since 3.2.0 + **/ + private function getClassNameFromOptions(string $method): ?string + { + $key = $this->getPasswordKey($method); + + if (isset($this->options[$key])) + { + $name = $this->options[$key]; + + if (isset($this->{$name}) && $this->{$name} instanceof Cryptinterface) + { + return $name; + } + } + + return null; + } + + /** + * Get the password + * + * @param string $method The encryption method to find + * @param string|null $password The password + * + * @return string|null the password or null + * @since 3.2.0 + **/ + private function getPassword(string $method, ?string $password = null): ?string + { + if (StringHelper::check($password)) + { + return $password; + } + + // get password key name + $key = $this->getPasswordKey($method); + + if (empty($this->passwords[$key])) + { + $this->passwords[$key] = $this->password->get($key); + } + + return $this->passwords[$key]; + } + + /** + * Get the key + * + * @param string $method The encryption method to find + * + * @return string the password key name + * @since 3.2.0 + **/ + private function getPasswordKey(string $method): string + { + if (($pos = strpos($method, '.')) !== false) + { + return substr($method, 0, $pos); + } + + return $method; + } + + /** + * Get the class name + * + * @param string $method The encryption method to find + * + * @return string the class name + * @since 3.2.0 + **/ + private function name(string $method): string + { + if (($pos = strpos($method, '.')) !== false) + { + return substr($method, $pos + 1); + } + + return $method; + } \ No newline at end of file diff --git a/src/d357e796-9f22-4615-9ebc-970b42cbd280/settings.json b/src/d357e796-9f22-4615-9ebc-970b42cbd280/settings.json index 6b3b222..d33598a 100644 --- a/src/d357e796-9f22-4615-9ebc-970b42cbd280/settings.json +++ b/src/d357e796-9f22-4615-9ebc-970b42cbd280/settings.json @@ -1 +1,43 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "0", + "guid": "d357e796-9f22-4615-9ebc-970b42cbd280", + "implements": null, + "load_selection": null, + "name": "Crypt", + "power_version": "1.0.0", + "system_name": "JCB.Crypt", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "e98b4edc-25b9-49d7-98a0-e42ad3b75efe", + "as": "default" + }, + "use_selection1": { + "use": "a25c82c8-14c2-40df-adae-f832709ab49b", + "as": "default" + }, + "use_selection2": { + "use": "437af6b0-ca02-49d7-8739-4edfc8a9ccb0", + "as": "default" + }, + "use_selection3": { + "use": "fea2b107-3ee4-4ebf-84be-d3f2829c8614", + "as": "default" + }, + "use_selection4": { + "use": "81de8f57-dd9c-4a17-964f-848cd4a0743b", + "as": "default" + }, + "use_selection5": { + "use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\Componentbuilder.Crypt", + "description": "Crypto Class\r\n\r\n@since 3.2.0", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "", + "composer": "" +} \ No newline at end of file diff --git a/src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe/README.md b/src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe/README.md index 433b69e..488d839 100644 --- a/src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe/README.md +++ b/src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe/README.md @@ -1 +1,45 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class FOF (Details) +> namespace: **VDM\Joomla\Componentbuilder\Crypt** +```uml +@startuml +class FOF #Gold { + + encrypt(string $string, string $key) : string + + decrypt(string $string, string $key) : ?string +} + +note right of FOF::encrypt + Encrypt a string as needed + + since: 3.2.0 + return: string +end note + +note right of FOF::decrypt + Decrypt a string as needed + + since: 3.2.0 + return: ?string +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe/code.php b/src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe/code.php index 26c1a50..d964692 100644 --- a/src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe/code.php +++ b/src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe/code.php @@ -9,4 +9,56 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\Componentbuilder\Crypt; + + +use VDM\Joomla\FOF\Encrypt\AES; +use VDM\Joomla\Componentbuilder\Interfaces\Cryptinterface; + + +/** + * Temp Class for FOFEncryptAes + * + * @since 3.2.0 + */ +class FOF implements Cryptinterface +{ + /** + * Encrypt a string as needed + * + * @param string $string The string to encrypt + * @param string $key The encryption key + * + * @return string + * @since 3.2.0 + **/ + public function encrypt(string $string, string $key): string + { + // Get the encryption object. + $aes = new Aes($key, 128); + + return $aes->decryptString($string); + } + + /** + * Decrypt a string as needed + * + * @param string $string The string to decrypt + * @param string $key The decryption key + * + * @return string|null + * @since 3.2.0 + **/ + public function decrypt(string $string, string $key): ?string + { + // Get the encryption object. + $aes = new Aes($key, 128); + + try { + return $aes->decryptString($string); + } catch (\Exception $ex) { + return null; + } + } +} + diff --git a/src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe/code.power b/src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe/code.power index 69309b0..52b997f 100644 --- a/src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe/code.power +++ b/src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe/code.power @@ -1 +1,37 @@ -###CODEPOWER### \ No newline at end of file + /** + * Encrypt a string as needed + * + * @param string $string The string to encrypt + * @param string $key The encryption key + * + * @return string + * @since 3.2.0 + **/ + public function encrypt(string $string, string $key): string + { + // Get the encryption object. + $aes = new Aes($key, 128); + + return $aes->decryptString($string); + } + + /** + * Decrypt a string as needed + * + * @param string $string The string to decrypt + * @param string $key The decryption key + * + * @return string|null + * @since 3.2.0 + **/ + public function decrypt(string $string, string $key): ?string + { + // Get the encryption object. + $aes = new Aes($key, 128); + + try { + return $aes->decryptString($string); + } catch (\Exception $ex) { + return null; + } + } \ No newline at end of file diff --git a/src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe/settings.json b/src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe/settings.json index 6b3b222..e460ca5 100644 --- a/src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe/settings.json +++ b/src/e98b4edc-25b9-49d7-98a0-e42ad3b75efe/settings.json @@ -1 +1,25 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "0", + "guid": "e98b4edc-25b9-49d7-98a0-e42ad3b75efe", + "implements": [ + "81de8f57-dd9c-4a17-964f-848cd4a0743b" + ], + "load_selection": null, + "name": "FOF", + "power_version": "1.0.0", + "system_name": "JCB.Crypt.FOF", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "99175f6d-dba8-4086-8a65-5c4ec175e61d", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\Componentbuilder.Crypt.FOF", + "description": "Temp Class for FOFEncryptAes\r\n\r\n@since 3.2.0", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "", + "composer": "" +} \ No newline at end of file diff --git a/src/f37ee8b7-2909-4319-bdf8-769bd7635490/README.md b/src/f37ee8b7-2909-4319-bdf8-769bd7635490/README.md index 433b69e..69f2fc8 100644 --- a/src/f37ee8b7-2909-4319-bdf8-769bd7635490/README.md +++ b/src/f37ee8b7-2909-4319-bdf8-769bd7635490/README.md @@ -1 +1,86 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Load (Details) +> namespace: **VDM\Joomla\Componentbuilder\Server\Model** +> extends: **Model** +```uml +@startuml +class Load #Gold { + # Crypt $crypt + + __construct(?Crypt $crypt = null, ?Table $table = null) + + value(mixed $value, string $field, ...) : mixed + # validateBefore(mixed $value, ?string $field = null, ...) : bool + # validateAfter(mixed $value, ?string $field = null, ...) : bool + # getTable() : string +} + +note right of Load::__construct + Constructor + + since: 3.2.0 +end note + +note right of Load::value + Model the value +Example: $this->value(value, 'value_key', 'table_name'); + + since: 3.2.0 + return: mixed + + arguments: + mixed $value + string $field + ?string $table = null +end note + +note right of Load::validateBefore + Validate before the value is modelled + + since: 3.2.0 + return: bool + + arguments: + mixed $value + ?string $field = null + ?string $table = null +end note + +note right of Load::validateAfter + Validate after the value is modelled + + since: 3.2.0 + return: bool + + arguments: + mixed $value + ?string $field = null + ?string $table = null +end note + +note right of Load::getTable + Get the current active table + + since: 3.2.0 + return: string +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/f37ee8b7-2909-4319-bdf8-769bd7635490/code.php b/src/f37ee8b7-2909-4319-bdf8-769bd7635490/code.php index 26c1a50..9917bc8 100644 --- a/src/f37ee8b7-2909-4319-bdf8-769bd7635490/code.php +++ b/src/f37ee8b7-2909-4319-bdf8-769bd7635490/code.php @@ -9,4 +9,145 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\Componentbuilder\Server\Model; + + +use Joomla\Registry\Registry; +use VDM\Joomla\Componentbuilder\Compiler\Factory; +use VDM\Joomla\Componentbuilder\Crypt; +use VDM\Joomla\Componentbuilder\Table; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Interfaces\ModelInterface; +use VDM\Joomla\Abstraction\Model; + + +/** + * Server Model Load Class + * + * @since 3.2.0 + */ +class Load extends Model implements ModelInterface +{ + /** + * Decryption Class + * + * @var Crypt + * @since 3.2.0 + */ + protected Crypt $crypt; + + /** + * Constructor + * + * @param Crypt|null $crypt The core crypt object. + * @param Table|null $table The search table object. + * + * @since 3.2.0 + */ + public function __construct(?Crypt $crypt = null, ?Table $table = null) + { + parent::__construct($table ?? Factory::_('Table')); + + $this->crypt = $crypt ?: Factory::_('Crypt'); + } + + /** + * Model the value + * Example: $this->value(value, 'value_key', 'table_name'); + * + * @param mixed $value The value to model + * @param string $field The field key + * @param string|null $table The table + * + * @return mixed + * @since 3.2.0 + */ + public function value($value, string $field, ?string $table = null) + { + // load the table + if (empty($table)) + { + $table = $this->getTable(); + } + + // check if this is a valid table + if (StringHelper::check($value) && ($store = $this->table->get($table, $field, 'store')) !== null) + { + // open the value based on the store method + switch($store) + { + case 'basic_encryption': + $value = $this->crypt->decrypt($value, 'basic'); + break; + case 'medium_encryption': + $value = $this->crypt->decrypt($value, 'medium'); + break; + case 'base64': + $value = base64_decode((string) $value); + break; + case 'json': + // check if there is a json string + if (JsonHelper::check($value)) + { + $registry = new Registry; + $registry->loadString($value); + $value = $registry->toArray(); + } + break; + default: + if ($this->crypt->exist($store)) + { + $value = $this->crypt->decrypt($value, $store); + } + break; + } + } + + return $value; + } + + /** + * Validate before the value is modelled + * + * @param mixed $value The field value + * @param string|null $field The field key + * @param string|null $table The table + * + * @return bool + * @since 3.2.0 + */ + protected function validateBefore(&$value, ?string $field = null, ?string $table = null): bool + { + // remove none + return true; + } + + /** + * Validate after the value is modelled + * + * @param mixed $value The field value + * @param string|null $field The field key + * @param string|null $table The table + * + * @return bool + * @since 3.2.0 + */ + protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool + { + return true; + } + + /** + * Get the current active table + * + * @return string + * @since 3.2.0 + */ + protected function getTable(): string + { + return 'server'; + } + +} + diff --git a/src/f37ee8b7-2909-4319-bdf8-769bd7635490/code.power b/src/f37ee8b7-2909-4319-bdf8-769bd7635490/code.power index 69309b0..46c4e3f 100644 --- a/src/f37ee8b7-2909-4319-bdf8-769bd7635490/code.power +++ b/src/f37ee8b7-2909-4319-bdf8-769bd7635490/code.power @@ -1 +1,119 @@ -###CODEPOWER### \ No newline at end of file + /** + * Decryption Class + * + * @var Crypt + * @since 3.2.0 + */ + protected Crypt $crypt; + + /** + * Constructor + * + * @param Crypt|null $crypt The core crypt object. + * @param Table|null $table The search table object. + * + * @since 3.2.0 + */ + public function __construct(?Crypt $crypt = null, ?Table $table = null) + { + parent::__construct($table ?? Factory::_('Table')); + + $this->crypt = $crypt ?: Factory::_('Crypt'); + } + + /** + * Model the value + * Example: $this->value(value, 'value_key', 'table_name'); + * + * @param mixed $value The value to model + * @param string $field The field key + * @param string|null $table The table + * + * @return mixed + * @since 3.2.0 + */ + public function value($value, string $field, ?string $table = null) + { + // load the table + if (empty($table)) + { + $table = $this->getTable(); + } + + // check if this is a valid table + if (StringHelper::check($value) && ($store = $this->table->get($table, $field, 'store')) !== null) + { + // open the value based on the store method + switch($store) + { + case 'basic_encryption': + $value = $this->crypt->decrypt($value, 'basic'); + break; + case 'medium_encryption': + $value = $this->crypt->decrypt($value, 'medium'); + break; + case 'base64': + $value = base64_decode((string) $value); + break; + case 'json': + // check if there is a json string + if (JsonHelper::check($value)) + { + $registry = new Registry; + $registry->loadString($value); + $value = $registry->toArray(); + } + break; + default: + if ($this->crypt->exist($store)) + { + $value = $this->crypt->decrypt($value, $store); + } + break; + } + } + + return $value; + } + + /** + * Validate before the value is modelled + * + * @param mixed $value The field value + * @param string|null $field The field key + * @param string|null $table The table + * + * @return bool + * @since 3.2.0 + */ + protected function validateBefore(&$value, ?string $field = null, ?string $table = null): bool + { + // remove none + return true; + } + + /** + * Validate after the value is modelled + * + * @param mixed $value The field value + * @param string|null $field The field key + * @param string|null $table The table + * + * @return bool + * @since 3.2.0 + */ + protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool + { + return true; + } + + /** + * Get the current active table + * + * @return string + * @since 3.2.0 + */ + protected function getTable(): string + { + return 'server'; + } diff --git a/src/f37ee8b7-2909-4319-bdf8-769bd7635490/settings.json b/src/f37ee8b7-2909-4319-bdf8-769bd7635490/settings.json index 6b3b222..f2d46e4 100644 --- a/src/f37ee8b7-2909-4319-bdf8-769bd7635490/settings.json +++ b/src/f37ee8b7-2909-4319-bdf8-769bd7635490/settings.json @@ -1 +1,41 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "584747d1-3a86-453d-b7a3-a2219de8d777", + "guid": "f37ee8b7-2909-4319-bdf8-769bd7635490", + "implements": [ + "8aef58c1-3f70-4bd4-b9e4-3f29fcd41cff" + ], + "load_selection": null, + "name": "Load", + "power_version": "1.0.0", + "system_name": "JCB.Server.Model.Load", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac", + "as": "default" + }, + "use_selection1": { + "use": "d357e796-9f22-4615-9ebc-970b42cbd280", + "as": "default" + }, + "use_selection2": { + "use": "bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8", + "as": "default" + }, + "use_selection3": { + "use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef", + "as": "default" + }, + "use_selection4": { + "use": "4b225c51-d293-48e4-b3f6-5136cf5c3f18", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\Componentbuilder.Server.Model.Load", + "description": "Server Model Load Class\r\n\r\n@since 3.2.0", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "use Joomla\\Registry\\Registry;", + "composer": "" +} \ No newline at end of file diff --git a/src/fea2b107-3ee4-4ebf-84be-d3f2829c8614/README.md b/src/fea2b107-3ee4-4ebf-84be-d3f2829c8614/README.md index 433b69e..8cf3925 100644 --- a/src/fea2b107-3ee4-4ebf-84be-d3f2829c8614/README.md +++ b/src/fea2b107-3ee4-4ebf-84be-d3f2829c8614/README.md @@ -1 +1,46 @@ -###POWERREADME### \ No newline at end of file +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Password (Details) +> namespace: **VDM\Joomla\Componentbuilder\Crypt** +```uml +@startuml +class Password #Gold { + + get(string $type, ?string $default = null) : ?string + - local() : string +} + +note right of Password::get + Get the type of password +Example: $this->get('basic', 'default-password'); + + since: 3.2.0 + return: ?string +end note + +note right of Password::local + Get the local password + + since: 3.2.0 + return: string +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/fea2b107-3ee4-4ebf-84be-d3f2829c8614/code.php b/src/fea2b107-3ee4-4ebf-84be-d3f2829c8614/code.php index 26c1a50..de5e790 100644 --- a/src/fea2b107-3ee4-4ebf-84be-d3f2829c8614/code.php +++ b/src/fea2b107-3ee4-4ebf-84be-d3f2829c8614/code.php @@ -9,4 +9,60 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -###POWERCODE### +namespace VDM\Joomla\Componentbuilder\Crypt; + + +use Joomla\CMS\Language\Text; +use VDM\Joomla\Utilities\Component\Helper; + + +/** + * Password Class + * + * @since 3.2.0 + */ +class Password +{ + /** + * Get the type of password + * Example: $this->get('basic', 'default-password'); + * + * @param string $type The value of password to get + * @param string|null $default The default password if the type is not found + * + * @return string|null + * @since 3.2.0 + */ + public function get(string $type, ?string $default = null): ?string + { + // we have a local key for JCB only use + if ('local' === $type) + { + return $this->local(); + } + elseif (($password = Helper::_('getCryptKey', [$type, $default])) !== null) + { + return $password; + } + + return $default; + } + + /** + * Get the local password + * + * @return string + * @since 3.2.0 + */ + private function local(): string + { + return base64_decode( + Text::sprintf( + 'COM_COMPONENTBUILDER_VJRZDESSMHBTRWFIFTYTWVZEROAESFLVVXJTMTHREEJTWOIXM', + 'QzdmV', '9kQ' + ) + ); + } + +} + diff --git a/src/fea2b107-3ee4-4ebf-84be-d3f2829c8614/code.power b/src/fea2b107-3ee4-4ebf-84be-d3f2829c8614/code.power index 69309b0..1d8803b 100644 --- a/src/fea2b107-3ee4-4ebf-84be-d3f2829c8614/code.power +++ b/src/fea2b107-3ee4-4ebf-84be-d3f2829c8614/code.power @@ -1 +1,40 @@ -###CODEPOWER### \ No newline at end of file + /** + * Get the type of password + * Example: $this->get('basic', 'default-password'); + * + * @param string $type The value of password to get + * @param string|null $default The default password if the type is not found + * + * @return string|null + * @since 3.2.0 + */ + public function get(string $type, ?string $default = null): ?string + { + // we have a local key for JCB only use + if ('local' === $type) + { + return $this->local(); + } + elseif (($password = Helper::_('getCryptKey', [$type, $default])) !== null) + { + return $password; + } + + return $default; + } + + /** + * Get the local password + * + * @return string + * @since 3.2.0 + */ + private function local(): string + { + return base64_decode( + Text::sprintf( + JustTEXT::_('VjRzdE%ssMHBtRW50TWV0aE%sFlvVXJTM3J2IXM='), + 'QzdmV', '9kQ' + ) + ); + } diff --git a/src/fea2b107-3ee4-4ebf-84be-d3f2829c8614/settings.json b/src/fea2b107-3ee4-4ebf-84be-d3f2829c8614/settings.json index 6b3b222..9185db8 100644 --- a/src/fea2b107-3ee4-4ebf-84be-d3f2829c8614/settings.json +++ b/src/fea2b107-3ee4-4ebf-84be-d3f2829c8614/settings.json @@ -1 +1,23 @@ -###POWERLINKER### \ No newline at end of file +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "fea2b107-3ee4-4ebf-84be-d3f2829c8614", + "implements": null, + "load_selection": null, + "name": "Password", + "power_version": "1.0.0", + "system_name": "JCB.Crypt.Password", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "640b5352-fb09-425f-a26e-cd44eda03f15", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\Componentbuilder.Crypt.Password", + "description": "Password Class\r\n\r\n@since 3.2.0", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "use Joomla\\CMS\\Language\\Text;", + "composer": "" +} \ No newline at end of file diff --git a/super-powers.json b/super-powers.json index 18f683b..eab66d9 100644 --- a/super-powers.json +++ b/super-powers.json @@ -1 +1,156 @@ -###POWERINDEX### \ No newline at end of file +{ + "11be6be3-ee3e-4771-8663-5545b76b73ab": { + "name": "Ftp", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Server", + "code": "src\/11be6be3-ee3e-4771-8663-5545b76b73ab\/code.php", + "power": "src\/11be6be3-ee3e-4771-8663-5545b76b73ab\/code.power", + "settings": "src\/11be6be3-ee3e-4771-8663-5545b76b73ab\/settings.json", + "path": "src\/11be6be3-ee3e-4771-8663-5545b76b73ab", + "spk": "Super__11be6be3_ee3e_4771_8663_5545b76b73ab__Power", + "guid": "11be6be3-ee3e-4771-8663-5545b76b73ab" + }, + "42ceff0b-226d-42ff-9ffa-3d5935890337": { + "name": "Server", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Service", + "code": "src\/42ceff0b-226d-42ff-9ffa-3d5935890337\/code.php", + "power": "src\/42ceff0b-226d-42ff-9ffa-3d5935890337\/code.power", + "settings": "src\/42ceff0b-226d-42ff-9ffa-3d5935890337\/settings.json", + "path": "src\/42ceff0b-226d-42ff-9ffa-3d5935890337", + "spk": "Super__42ceff0b_226d_42ff_9ffa_3d5935890337__Power", + "guid": "42ceff0b-226d-42ff-9ffa-3d5935890337" + }, + "437af6b0-ca02-49d7-8739-4edfc8a9ccb0": { + "name": "Legacy", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Crypt\\Aes", + "code": "src\/437af6b0-ca02-49d7-8739-4edfc8a9ccb0\/code.php", + "power": "src\/437af6b0-ca02-49d7-8739-4edfc8a9ccb0\/code.power", + "settings": "src\/437af6b0-ca02-49d7-8739-4edfc8a9ccb0\/settings.json", + "path": "src\/437af6b0-ca02-49d7-8739-4edfc8a9ccb0", + "spk": "Super__437af6b0_ca02_49d7_8739_4edfc8a9ccb0__Power", + "guid": "437af6b0-ca02-49d7-8739-4edfc8a9ccb0" + }, + "490b6aa5-5de7-4be5-a61a-f634f6e004c0": { + "name": "Sftp", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Server", + "code": "src\/490b6aa5-5de7-4be5-a61a-f634f6e004c0\/code.php", + "power": "src\/490b6aa5-5de7-4be5-a61a-f634f6e004c0\/code.power", + "settings": "src\/490b6aa5-5de7-4be5-a61a-f634f6e004c0\/settings.json", + "path": "src\/490b6aa5-5de7-4be5-a61a-f634f6e004c0", + "spk": "Super__490b6aa5_5de7_4be5_a61a_f634f6e004c0__Power", + "guid": "490b6aa5-5de7-4be5-a61a-f634f6e004c0" + }, + "4d8f38ef-8f3a-463d-8678-0bf087ac6815": { + "name": "Crypt", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Service", + "code": "src\/4d8f38ef-8f3a-463d-8678-0bf087ac6815\/code.php", + "power": "src\/4d8f38ef-8f3a-463d-8678-0bf087ac6815\/code.power", + "settings": "src\/4d8f38ef-8f3a-463d-8678-0bf087ac6815\/settings.json", + "path": "src\/4d8f38ef-8f3a-463d-8678-0bf087ac6815", + "spk": "Super__4d8f38ef_8f3a_463d_8678_0bf087ac6815__Power", + "guid": "4d8f38ef-8f3a-463d-8678-0bf087ac6815" + }, + "66355f70-c26c-4765-ba48-498e3df740ef": { + "name": "Server", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder", + "code": "src\/66355f70-c26c-4765-ba48-498e3df740ef\/code.php", + "power": "src\/66355f70-c26c-4765-ba48-498e3df740ef\/code.power", + "settings": "src\/66355f70-c26c-4765-ba48-498e3df740ef\/settings.json", + "path": "src\/66355f70-c26c-4765-ba48-498e3df740ef", + "spk": "Super__66355f70_c26c_4765_ba48_498e3df740ef__Power", + "guid": "66355f70-c26c-4765-ba48-498e3df740ef" + }, + "6da44dff-a221-4f22-b9d9-b2fc2a724b4b": { + "name": "KeyLoader", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Crypt", + "code": "src\/6da44dff-a221-4f22-b9d9-b2fc2a724b4b\/code.php", + "power": "src\/6da44dff-a221-4f22-b9d9-b2fc2a724b4b\/code.power", + "settings": "src\/6da44dff-a221-4f22-b9d9-b2fc2a724b4b\/settings.json", + "path": "src\/6da44dff-a221-4f22-b9d9-b2fc2a724b4b", + "spk": "Super__6da44dff_a221_4f22_b9d9_b2fc2a724b4b__Power", + "guid": "6da44dff-a221-4f22-b9d9-b2fc2a724b4b" + }, + "a25c82c8-14c2-40df-adae-f832709ab49b": { + "name": "Aes", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Crypt", + "code": "src\/a25c82c8-14c2-40df-adae-f832709ab49b\/code.php", + "power": "src\/a25c82c8-14c2-40df-adae-f832709ab49b\/code.power", + "settings": "src\/a25c82c8-14c2-40df-adae-f832709ab49b\/settings.json", + "path": "src\/a25c82c8-14c2-40df-adae-f832709ab49b", + "spk": "Super__a25c82c8_14c2_40df_adae_f832709ab49b__Power", + "guid": "a25c82c8-14c2-40df-adae-f832709ab49b" + }, + "a3414824-e99d-4878-b3d1-b5deef0cae17": { + "name": "Load", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Server", + "code": "src\/a3414824-e99d-4878-b3d1-b5deef0cae17\/code.php", + "power": "src\/a3414824-e99d-4878-b3d1-b5deef0cae17\/code.power", + "settings": "src\/a3414824-e99d-4878-b3d1-b5deef0cae17\/settings.json", + "path": "src\/a3414824-e99d-4878-b3d1-b5deef0cae17", + "spk": "Super__a3414824_e99d_4878_b3d1_b5deef0cae17__Power", + "guid": "a3414824-e99d-4878-b3d1-b5deef0cae17" + }, + "c46a42b4-b0d3-48e7-a6fa-af0399e1e66c": { + "name": "Random", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Crypt", + "code": "src\/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c\/code.php", + "power": "src\/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c\/code.power", + "settings": "src\/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c\/settings.json", + "path": "src\/c46a42b4-b0d3-48e7-a6fa-af0399e1e66c", + "spk": "Super__c46a42b4_b0d3_48e7_a6fa_af0399e1e66c__Power", + "guid": "c46a42b4-b0d3-48e7-a6fa-af0399e1e66c" + }, + "d357e796-9f22-4615-9ebc-970b42cbd280": { + "name": "Crypt", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder", + "code": "src\/d357e796-9f22-4615-9ebc-970b42cbd280\/code.php", + "power": "src\/d357e796-9f22-4615-9ebc-970b42cbd280\/code.power", + "settings": "src\/d357e796-9f22-4615-9ebc-970b42cbd280\/settings.json", + "path": "src\/d357e796-9f22-4615-9ebc-970b42cbd280", + "spk": "Super__d357e796_9f22_4615_9ebc_970b42cbd280__Power", + "guid": "d357e796-9f22-4615-9ebc-970b42cbd280" + }, + "e98b4edc-25b9-49d7-98a0-e42ad3b75efe": { + "name": "FOF", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Crypt", + "code": "src\/e98b4edc-25b9-49d7-98a0-e42ad3b75efe\/code.php", + "power": "src\/e98b4edc-25b9-49d7-98a0-e42ad3b75efe\/code.power", + "settings": "src\/e98b4edc-25b9-49d7-98a0-e42ad3b75efe\/settings.json", + "path": "src\/e98b4edc-25b9-49d7-98a0-e42ad3b75efe", + "spk": "Super__e98b4edc_25b9_49d7_98a0_e42ad3b75efe__Power", + "guid": "e98b4edc-25b9-49d7-98a0-e42ad3b75efe" + }, + "f37ee8b7-2909-4319-bdf8-769bd7635490": { + "name": "Load", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Server\\Model", + "code": "src\/f37ee8b7-2909-4319-bdf8-769bd7635490\/code.php", + "power": "src\/f37ee8b7-2909-4319-bdf8-769bd7635490\/code.power", + "settings": "src\/f37ee8b7-2909-4319-bdf8-769bd7635490\/settings.json", + "path": "src\/f37ee8b7-2909-4319-bdf8-769bd7635490", + "spk": "Super__f37ee8b7_2909_4319_bdf8_769bd7635490__Power", + "guid": "f37ee8b7-2909-4319-bdf8-769bd7635490" + }, + "fea2b107-3ee4-4ebf-84be-d3f2829c8614": { + "name": "Password", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Crypt", + "code": "src\/fea2b107-3ee4-4ebf-84be-d3f2829c8614\/code.php", + "power": "src\/fea2b107-3ee4-4ebf-84be-d3f2829c8614\/code.power", + "settings": "src\/fea2b107-3ee4-4ebf-84be-d3f2829c8614\/settings.json", + "path": "src\/fea2b107-3ee4-4ebf-84be-d3f2829c8614", + "spk": "Super__fea2b107_3ee4_4ebf_84be_d3f2829c8614__Power", + "guid": "fea2b107-3ee4-4ebf-84be-d3f2829c8614" + } +} \ No newline at end of file