AppleProvisioningNode.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\DAV\Provisioning\Apple;
  7. use OCP\AppFramework\Utility\ITimeFactory;
  8. use Sabre\DAV\Exception\Forbidden;
  9. use Sabre\DAV\INode;
  10. use Sabre\DAV\IProperties;
  11. use Sabre\DAV\PropPatch;
  12. class AppleProvisioningNode implements INode, IProperties {
  13. public const FILENAME = 'apple-provisioning.mobileconfig';
  14. protected $timeFactory;
  15. /**
  16. * @param ITimeFactory $timeFactory
  17. */
  18. public function __construct(ITimeFactory $timeFactory) {
  19. $this->timeFactory = $timeFactory;
  20. }
  21. /**
  22. * @return string
  23. */
  24. public function getName() {
  25. return self::FILENAME;
  26. }
  27. public function setName($name) {
  28. throw new Forbidden('Renaming ' . self::FILENAME . ' is forbidden');
  29. }
  30. /**
  31. * @return null
  32. */
  33. public function getLastModified() {
  34. return null;
  35. }
  36. /**
  37. * @throws Forbidden
  38. */
  39. public function delete() {
  40. throw new Forbidden(self::FILENAME . ' may not be deleted.');
  41. }
  42. /**
  43. * @param array $properties
  44. * @return array
  45. */
  46. public function getProperties($properties) {
  47. $datetime = $this->timeFactory->getDateTime();
  48. return [
  49. '{DAV:}getcontentlength' => 42,
  50. '{DAV:}getlastmodified' => $datetime->format(\DateTimeInterface::RFC2822),
  51. ];
  52. }
  53. /**
  54. * @param PropPatch $propPatch
  55. * @throws Forbidden
  56. */
  57. public function propPatch(PropPatch $propPatch) {
  58. throw new Forbidden(self::FILENAME . '\'s properties may not be altered.');
  59. }
  60. }