SMB_OC.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Morris Jobke <hey@morrisjobke.de>
  6. * @author Robin McCorkell <robin@mccorkell.me.uk>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. * @author Valdnet <47037905+Valdnet@users.noreply.github.com>
  9. *
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. namespace OCA\Files_External\Lib\Backend;
  26. use OCA\Files_External\Lib\Auth\AuthMechanism;
  27. use OCA\Files_External\Lib\Auth\Password\SessionCredentials;
  28. use OCA\Files_External\Lib\DefinitionParameter;
  29. use OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
  30. use OCA\Files_External\Lib\StorageConfig;
  31. use OCA\Files_External\Service\BackendService;
  32. use OCP\IL10N;
  33. use OCP\IUser;
  34. /**
  35. * Deprecated SMB_OC class - use SMB with the password::sessioncredentials auth mechanism
  36. */
  37. class SMB_OC extends Backend {
  38. use LegacyDependencyCheckPolyfill;
  39. public function __construct(IL10N $l, SessionCredentials $legacyAuth, SMB $smbBackend) {
  40. $this
  41. ->setIdentifier('\OC\Files\Storage\SMB_OC')
  42. ->setStorageClass('\OCA\Files_External\Lib\Storage\SMB')
  43. ->setText($l->t('SMB/CIFS using OC login'))
  44. ->addParameters([
  45. new DefinitionParameter('host', $l->t('Host')),
  46. (new DefinitionParameter('username_as_share', $l->t('Login as share')))
  47. ->setType(DefinitionParameter::VALUE_BOOLEAN),
  48. (new DefinitionParameter('share', $l->t('Share')))
  49. ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
  50. (new DefinitionParameter('root', $l->t('Remote subfolder')))
  51. ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
  52. ])
  53. ->setPriority(BackendService::PRIORITY_DEFAULT - 10)
  54. ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD)
  55. ->setLegacyAuthMechanism($legacyAuth)
  56. ->deprecateTo($smbBackend)
  57. ;
  58. }
  59. /**
  60. * @return void
  61. */
  62. public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
  63. $username_as_share = ($storage->getBackendOption('username_as_share') === true);
  64. if ($username_as_share) {
  65. $share = '/' . $storage->getBackendOption('user');
  66. $storage->setBackendOption('share', $share);
  67. }
  68. }
  69. }