LockdownManager.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, Robin Appelman <robin@icewind.nl>
  4. *
  5. * This code is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Affero General Public License, version 3,
  7. * as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Affero General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Affero General Public License, version 3,
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>
  16. *
  17. */
  18. namespace OC\Lockdown;
  19. use OC\Authentication\Token\IToken;
  20. use OCP\Lockdown\ILockdownManager;
  21. class LockdownManager implements ILockdownManager {
  22. private $enabled = false;
  23. /** @var array|null */
  24. private $scope;
  25. public function enable() {
  26. $this->enabled = true;
  27. }
  28. public function setToken(IToken $token) {
  29. $this->scope = $token->getScopeAsArray();
  30. $this->enable();
  31. }
  32. public function canAccessFilesystem() {
  33. if (!$this->enabled) {
  34. return true;
  35. }
  36. return !$this->scope || $this->scope['filesystem'];
  37. }
  38. }