SMB_OC.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\Files_External\Lib\Backend;
  8. use OCA\Files_External\Lib\Auth\AuthMechanism;
  9. use OCA\Files_External\Lib\Auth\Password\SessionCredentials;
  10. use OCA\Files_External\Lib\DefinitionParameter;
  11. use OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
  12. use OCA\Files_External\Lib\StorageConfig;
  13. use OCA\Files_External\Service\BackendService;
  14. use OCP\IL10N;
  15. use OCP\IUser;
  16. /**
  17. * Deprecated SMB_OC class - use SMB with the password::sessioncredentials auth mechanism
  18. */
  19. class SMB_OC extends Backend {
  20. use LegacyDependencyCheckPolyfill;
  21. public function __construct(IL10N $l, SessionCredentials $legacyAuth, SMB $smbBackend) {
  22. $this
  23. ->setIdentifier('\OC\Files\Storage\SMB_OC')
  24. ->setStorageClass('\OCA\Files_External\Lib\Storage\SMB')
  25. ->setText($l->t('SMB/CIFS using OC login'))
  26. ->addParameters([
  27. new DefinitionParameter('host', $l->t('Host')),
  28. (new DefinitionParameter('username_as_share', $l->t('Login as share')))
  29. ->setType(DefinitionParameter::VALUE_BOOLEAN),
  30. (new DefinitionParameter('share', $l->t('Share')))
  31. ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
  32. (new DefinitionParameter('root', $l->t('Remote subfolder')))
  33. ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
  34. ])
  35. ->setPriority(BackendService::PRIORITY_DEFAULT - 10)
  36. ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD)
  37. ->setLegacyAuthMechanism($legacyAuth)
  38. ->deprecateTo($smbBackend)
  39. ;
  40. }
  41. /**
  42. * @return void
  43. */
  44. public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
  45. $username_as_share = ($storage->getBackendOption('username_as_share') === true);
  46. if ($username_as_share) {
  47. $share = '/' . $storage->getBackendOption('user');
  48. $storage->setBackendOption('share', $share);
  49. }
  50. }
  51. }