diff options
Diffstat (limited to 'apps/files_external/lib/AppInfo/Application.php')
-rw-r--r-- | apps/files_external/lib/AppInfo/Application.php | 175 |
1 files changed, 102 insertions, 73 deletions
diff --git a/apps/files_external/lib/AppInfo/Application.php b/apps/files_external/lib/AppInfo/Application.php index 266665a58aa..a6c2aff947b 100644 --- a/apps/files_external/lib/AppInfo/Application.php +++ b/apps/files_external/lib/AppInfo/Application.php @@ -1,67 +1,95 @@ <?php + /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Joas Schilling <coding@schilljs.com> - * @author Lukas Reschke <lukas@statuscode.ch> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin Appelman <robin@icewind.nl> - * @author Robin McCorkell <robin@mccorkell.me.uk> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Ross Nicoll <jrn@jrn.me.uk> - * @author Vincent Petry <pvince81@owncloud.com> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ - namespace OCA\Files_External\AppInfo; -use \OCP\AppFramework\App; -use OCP\AppFramework\IAppContainer; -use \OCP\IContainer; -use \OCA\Files_External\Service\BackendService; -use \OCA\Files_External\Lib\Config\IBackendProvider; -use \OCA\Files_External\Lib\Config\IAuthMechanismProvider; +use OCA\Files\Event\LoadAdditionalScriptsEvent; +use OCA\Files_External\Config\ConfigAdapter; +use OCA\Files_External\Config\UserPlaceholderHandler; +use OCA\Files_External\ConfigLexicon; +use OCA\Files_External\Lib\Auth\AmazonS3\AccessKey; +use OCA\Files_External\Lib\Auth\Builtin; +use OCA\Files_External\Lib\Auth\NullMechanism; +use OCA\Files_External\Lib\Auth\OAuth2\OAuth2; +use OCA\Files_External\Lib\Auth\OpenStack\OpenStackV2; +use OCA\Files_External\Lib\Auth\OpenStack\OpenStackV3; +use OCA\Files_External\Lib\Auth\OpenStack\Rackspace; +use OCA\Files_External\Lib\Auth\Password\GlobalAuth; +use OCA\Files_External\Lib\Auth\Password\LoginCredentials; +use OCA\Files_External\Lib\Auth\Password\Password; +use OCA\Files_External\Lib\Auth\Password\SessionCredentials; +use OCA\Files_External\Lib\Auth\Password\UserGlobalAuth; +use OCA\Files_External\Lib\Auth\Password\UserProvided; +use OCA\Files_External\Lib\Auth\PublicKey\RSA; +use OCA\Files_External\Lib\Auth\PublicKey\RSAPrivateKey; +use OCA\Files_External\Lib\Auth\SMB\KerberosApacheAuth; +use OCA\Files_External\Lib\Auth\SMB\KerberosAuth; +use OCA\Files_External\Lib\Backend\AmazonS3; +use OCA\Files_External\Lib\Backend\DAV; +use OCA\Files_External\Lib\Backend\FTP; +use OCA\Files_External\Lib\Backend\Local; +use OCA\Files_External\Lib\Backend\OwnCloud; +use OCA\Files_External\Lib\Backend\SFTP; +use OCA\Files_External\Lib\Backend\SFTP_Key; +use OCA\Files_External\Lib\Backend\SMB; +use OCA\Files_External\Lib\Backend\SMB_OC; +use OCA\Files_External\Lib\Backend\Swift; +use OCA\Files_External\Lib\Config\IAuthMechanismProvider; +use OCA\Files_External\Lib\Config\IBackendProvider; +use OCA\Files_External\Listener\GroupDeletedListener; +use OCA\Files_External\Listener\LoadAdditionalListener; +use OCA\Files_External\Listener\UserDeletedListener; +use OCA\Files_External\Service\BackendService; +use OCP\AppFramework\App; +use OCP\AppFramework\Bootstrap\IBootContext; +use OCP\AppFramework\Bootstrap\IBootstrap; +use OCP\AppFramework\Bootstrap\IRegistrationContext; +use OCP\AppFramework\QueryException; +use OCP\Files\Config\IMountProviderCollection; +use OCP\Group\Events\GroupDeletedEvent; +use OCP\User\Events\UserDeletedEvent; /** * @package OCA\Files_External\AppInfo */ -class Application extends App implements IBackendProvider, IAuthMechanismProvider { +class Application extends App implements IBackendProvider, IAuthMechanismProvider, IBootstrap { + public const APP_ID = 'files_external'; - public function __construct(array $urlParams = array()) { - parent::__construct('files_external', $urlParams); + /** + * Application constructor. + * + * @throws QueryException + */ + public function __construct(array $urlParams = []) { + parent::__construct(self::APP_ID, $urlParams); + } - $container = $this->getContainer(); + public function register(IRegistrationContext $context): void { + $context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class); + $context->registerEventListener(GroupDeletedEvent::class, GroupDeletedListener::class); + $context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); + $context->registerConfigLexicon(ConfigLexicon::class); + } - $container->registerService('OCP\Files\Config\IUserMountCache', function (IAppContainer $c) { - return $c->getServer()->query('UserMountCache'); + public function boot(IBootContext $context): void { + $context->injectFn(function (IMountProviderCollection $mountProviderCollection, ConfigAdapter $configAdapter): void { + $mountProviderCollection->registerProvider($configAdapter); + }); + $context->injectFn(function (BackendService $backendService, UserPlaceholderHandler $userConfigHandler): void { + $backendService->registerBackendProvider($this); + $backendService->registerAuthMechanismProvider($this); + $backendService->registerConfigHandler('user', function () use ($userConfigHandler) { + return $userConfigHandler; + }); }); - - $backendService = $container->query('OCA\\Files_External\\Service\\BackendService'); - $backendService->registerBackendProvider($this); - $backendService->registerAuthMechanismProvider($this); // force-load auth mechanisms since some will register hooks // TODO: obsolete these and use the TokenProvider to get the user's password from the session $this->getAuthMechanisms(); - - // app developers: do NOT depend on this! it will disappear with oC 9.0! - \OC::$server->getEventDispatcher()->dispatch( - 'OCA\\Files_External::loadAdditionalBackends' - ); } /** @@ -71,16 +99,16 @@ class Application extends App implements IBackendProvider, IAuthMechanismProvide $container = $this->getContainer(); $backends = [ - $container->query('OCA\Files_External\Lib\Backend\Local'), - $container->query('OCA\Files_External\Lib\Backend\FTP'), - $container->query('OCA\Files_External\Lib\Backend\DAV'), - $container->query('OCA\Files_External\Lib\Backend\OwnCloud'), - $container->query('OCA\Files_External\Lib\Backend\SFTP'), - $container->query('OCA\Files_External\Lib\Backend\AmazonS3'), - $container->query('OCA\Files_External\Lib\Backend\Swift'), - $container->query('OCA\Files_External\Lib\Backend\SFTP_Key'), - $container->query('OCA\Files_External\Lib\Backend\SMB'), - $container->query('OCA\Files_External\Lib\Backend\SMB_OC'), + $container->get(Local::class), + $container->get(FTP::class), + $container->get(DAV::class), + $container->get(OwnCloud::class), + $container->get(SFTP::class), + $container->get(AmazonS3::class), + $container->get(Swift::class), + $container->get(SFTP_Key::class), + $container->get(SMB::class), + $container->get(SMB_OC::class), ]; return $backends; @@ -94,34 +122,35 @@ class Application extends App implements IBackendProvider, IAuthMechanismProvide return [ // AuthMechanism::SCHEME_NULL mechanism - $container->query('OCA\Files_External\Lib\Auth\NullMechanism'), + $container->get(NullMechanism::class), // AuthMechanism::SCHEME_BUILTIN mechanism - $container->query('OCA\Files_External\Lib\Auth\Builtin'), + $container->get(Builtin::class), // AuthMechanism::SCHEME_PASSWORD mechanisms - $container->query('OCA\Files_External\Lib\Auth\Password\Password'), - $container->query('OCA\Files_External\Lib\Auth\Password\SessionCredentials'), - $container->query('OCA\Files_External\Lib\Auth\Password\LoginCredentials'), - $container->query('OCA\Files_External\Lib\Auth\Password\UserProvided'), - $container->query('OCA\Files_External\Lib\Auth\Password\GlobalAuth'), - - // AuthMechanism::SCHEME_OAUTH1 mechanisms - $container->query('OCA\Files_External\Lib\Auth\OAuth1\OAuth1'), + $container->get(Password::class), + $container->get(SessionCredentials::class), + $container->get(LoginCredentials::class), + $container->get(UserProvided::class), + $container->get(GlobalAuth::class), + $container->get(UserGlobalAuth::class), // AuthMechanism::SCHEME_OAUTH2 mechanisms - $container->query('OCA\Files_External\Lib\Auth\OAuth2\OAuth2'), + $container->get(OAuth2::class), // AuthMechanism::SCHEME_PUBLICKEY mechanisms - $container->query('OCA\Files_External\Lib\Auth\PublicKey\RSA'), + $container->get(RSA::class), + $container->get(RSAPrivateKey::class), // AuthMechanism::SCHEME_OPENSTACK mechanisms - $container->query('OCA\Files_External\Lib\Auth\OpenStack\OpenStack'), - $container->query('OCA\Files_External\Lib\Auth\OpenStack\Rackspace'), + $container->get(OpenStackV2::class), + $container->get(OpenStackV3::class), + $container->get(Rackspace::class), // Specialized mechanisms - $container->query('OCA\Files_External\Lib\Auth\AmazonS3\AccessKey'), + $container->get(AccessKey::class), + $container->get(KerberosAuth::class), + $container->get(KerberosApacheAuth::class), ]; } - } |