AppleProvisioningNode.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * @copyright 2018, Georg Ehrke <oc.list@georgehrke.com>
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Georg Ehrke <oc.list@georgehrke.com>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCA\DAV\Provisioning\Apple;
  25. use OCP\AppFramework\Utility\ITimeFactory;
  26. use Sabre\DAV\Exception\Forbidden;
  27. use Sabre\DAV\INode;
  28. use Sabre\DAV\IProperties;
  29. use Sabre\DAV\PropPatch;
  30. class AppleProvisioningNode implements INode, IProperties {
  31. public const FILENAME = 'apple-provisioning.mobileconfig';
  32. protected $timeFactory;
  33. /**
  34. * @param ITimeFactory $timeFactory
  35. */
  36. public function __construct(ITimeFactory $timeFactory) {
  37. $this->timeFactory = $timeFactory;
  38. }
  39. /**
  40. * @return string
  41. */
  42. public function getName() {
  43. return self::FILENAME;
  44. }
  45. public function setName($name) {
  46. throw new Forbidden('Renaming ' . self::FILENAME . ' is forbidden');
  47. }
  48. /**
  49. * @return null
  50. */
  51. public function getLastModified() {
  52. return null;
  53. }
  54. /**
  55. * @throws Forbidden
  56. */
  57. public function delete() {
  58. throw new Forbidden(self::FILENAME . ' may not be deleted.');
  59. }
  60. /**
  61. * @param array $properties
  62. * @return array
  63. */
  64. public function getProperties($properties) {
  65. $datetime = $this->timeFactory->getDateTime();
  66. return [
  67. '{DAV:}getcontentlength' => 42,
  68. '{DAV:}getlastmodified' => $datetime->format(\DateTimeInterface::RFC2822),
  69. ];
  70. }
  71. /**
  72. * @param PropPatch $propPatch
  73. * @throws Forbidden
  74. */
  75. public function propPatch(PropPatch $propPatch) {
  76. throw new Forbidden(self::FILENAME . '\'s properties may not be altered.');
  77. }
  78. }