AppleProvisioningNode.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. /**
  15. * @param ITimeFactory $timeFactory
  16. */
  17. public function __construct(
  18. protected ITimeFactory $timeFactory,
  19. ) {
  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. }