[Pkg-owncloud-commits] [php-sabredav] 15/148: Moved all ACL properties to new XML parser.

David Prévot taffit at moszumanska.debian.org
Wed Apr 15 01:37:03 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabredav.

commit 667906e21d9f8e1b77430a05bef15550accfe194
Author: Evert Pot <me at evertpot.com>
Date:   Thu Feb 5 23:40:06 2015 -0500

    Moved all ACL properties to new XML parser.
---
 composer.json                                      |   2 +-
 lib/DAV/XMLUtil.php                                |   4 +-
 lib/DAV/Xml/Property/Href.php                      |  28 +--
 lib/DAV/Xml/Property/LockDiscovery.php             |   6 +-
 lib/DAVACL/Plugin.php                              |  27 +--
 lib/DAVACL/Property/Acl.php                        | 212 ------------------
 lib/DAVACL/Property/AclRestrictions.php            |  34 ---
 lib/DAVACL/Property/CurrentUserPrivilegeSet.php    | 136 ------------
 lib/DAVACL/Property/Principal.php                  | 164 --------------
 lib/DAVACL/Property/SupportedPrivilegeSet.php      | 105 ---------
 lib/DAVACL/Xml/Property/Acl.php                    | 236 +++++++++++++++++++++
 lib/DAVACL/Xml/Property/AclRestrictions.php        |  47 ++++
 .../Xml/Property/CurrentUserPrivilegeSet.php       | 134 ++++++++++++
 lib/DAVACL/Xml/Property/Principal.php              | 167 +++++++++++++++
 lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php  | 115 ++++++++++
 tests/Sabre/DAVACL/PluginPropertiesTest.php        |  27 +--
 .../Sabre/DAVACL/Property/ACLRestrictionsTest.php  |  36 ----
 tests/Sabre/DAVACL/{ => Xml}/Property/ACLTest.php  | 130 +++++-------
 .../DAVACL/Xml/Property/AclRestrictionsTest.php    |  30 +++
 .../Property/CurrentUserPrivilegeSetTest.php       |  31 +--
 .../DAVACL/{ => Xml}/Property/PrincipalTest.php    |  89 +++-----
 .../Property/SupportedPrivilegeSetTest.php         |  62 ++----
 22 files changed, 893 insertions(+), 929 deletions(-)

diff --git a/composer.json b/composer.json
index e52a9f1..47ad209 100644
--- a/composer.json
+++ b/composer.json
@@ -17,7 +17,7 @@
         "php": ">=5.4.1",
         "sabre/vobject": "~3.3.4",
         "sabre/event" : "~2.0.0",
-        "sabre/xml"  : "~0.2.2",
+        "sabre/xml"  : "~0.3.0",
         "sabre/http" : "dev-master",
         "sabre/uri" : "~1.0",
         "ext-dom": "*",
diff --git a/lib/DAV/XMLUtil.php b/lib/DAV/XMLUtil.php
index 628681e..e9453ec 100644
--- a/lib/DAV/XMLUtil.php
+++ b/lib/DAV/XMLUtil.php
@@ -73,11 +73,13 @@ class XMLUtil {
      * Generates an XML document and returns the output as a string.
      *
      * @param mixed $output
+     * @param string $baseUri // Specify the base URI of the document.
      * @return string
      */
-    function write($output) {
+    function write($output, $baseUri = null) {
 
         $writer = new XML\Writer();
+        $writer->baseUri = $baseUri;
         $writer->namespaceMap = $this->namespaceMap;
         $writer->openMemory();
         $writer->write($output);
diff --git a/lib/DAV/Xml/Property/Href.php b/lib/DAV/Xml/Property/Href.php
index 8c53e2d..2ff665b 100644
--- a/lib/DAV/Xml/Property/Href.php
+++ b/lib/DAV/Xml/Property/Href.php
@@ -48,7 +48,7 @@ class Href implements Element {
      * @param string|string[] $href
      * @param bool $autoPrefix
      */
-    public function __construct($hrefs, $autoPrefix = true) {
+    function __construct($hrefs, $autoPrefix = true) {
 
         if (is_string($hrefs)) {
             $hrefs = [$hrefs];
@@ -64,7 +64,7 @@ class Href implements Element {
      *
      * @return string
      */
-    public function getHref() {
+    function getHref() {
 
         return $this->hrefs[0];
 
@@ -75,28 +75,32 @@ class Href implements Element {
      *
      * @return array
      */
-    public function getHrefs() {
+    function getHrefs() {
 
         return $this->hrefs;
 
     }
 
     /**
-     * The serialize method is called during xml writing.
+     * The xmlSerialize metod is called during xml writing.
      *
-     * It should use the $writer argument to encode this object into XML.
+     * Use the $writer argument to write its own xml serialization.
      *
-     * Important note: it is not needed to create the parent element. The
-     * parent element is already created, and we only have to worry about
-     * attributes, child elements and text (if any).
+     * An important note: do _not_ create a parent element. Any element
+     * implementing XmlSerializble should only ever write what's considered
+     * its 'inner xml'.
      *
-     * Important note 2: If you are writing any new elements, you are also
-     * responsible for closing them.
+     * The parent of the current element is responsible for writing a
+     * containing element.
+     *
+     * This allows serializers to be re-used for different element names.
+     *
+     * If you are opening new elements, you must also close them again.
      *
      * @param Writer $writer
      * @return void
      */
-    public function xmlSerialize(Writer $writer) {
+    function xmlSerialize(Writer $writer) {
 
         foreach($this->getHrefs() as $href) {
             if ($this->autoPrefix) {
@@ -128,7 +132,7 @@ class Href implements Element {
      * @param Reader $reader
      * @return mixed
      */
-    static public function xmlDeserialize(Reader $reader) {
+    static function xmlDeserialize(Reader $reader) {
 
         $hrefs = [];
         foreach($reader->parseInnerTree() as $elem) {
diff --git a/lib/DAV/Xml/Property/LockDiscovery.php b/lib/DAV/Xml/Property/LockDiscovery.php
index 605cc99..7082c67 100644
--- a/lib/DAV/Xml/Property/LockDiscovery.php
+++ b/lib/DAV/Xml/Property/LockDiscovery.php
@@ -52,7 +52,7 @@ class LockDiscovery implements Element {
      * @param \Sabre\DAV\Locks\LockInfo[] $locks
      * @param bool $revealLockToken
      */
-    public function __construct($locks, $revealLockToken = false) {
+    function __construct($locks, $revealLockToken = false) {
 
         $this->locks = $locks;
         $this->revealLockToken = $revealLockToken;
@@ -74,7 +74,7 @@ class LockDiscovery implements Element {
      * @param Writer $writer
      * @return void
      */
-    public function xmlSerialize(Writer $writer) {
+    function xmlSerialize(Writer $writer) {
 
         foreach($this->locks as $lock) {
 
@@ -136,7 +136,7 @@ class LockDiscovery implements Element {
      * @param Reader $reader
      * @return mixed
      */
-    static public function xmlDeserialize(Reader $reader) {
+    static function xmlDeserialize(Reader $reader) {
 
         throw new CannotDeserialize('This element does not have a deserializer');
 
diff --git a/lib/DAVACL/Plugin.php b/lib/DAVACL/Plugin.php
index 0bb2985..4298f1c 100644
--- a/lib/DAVACL/Plugin.php
+++ b/lib/DAVACL/Plugin.php
@@ -708,7 +708,8 @@ class Plugin extends DAV\ServerPlugin {
 
         // Mapping the group-member-set property to the HrefList property
         // class.
-        $server->propertyMap['{DAV:}group-member-set'] = 'Sabre\\DAV\\Xml\\Property\\Href';
+        $server->xml->elementMap['{DAV:}group-member-set'] = 'Sabre\\DAV\\Xml\\Property\\Href';
+        $server->xml->elementMap['{DAV:}acl'] = 'Sabre\\DAVACL\\Xml\\Property\\Acl';
 
     }
 
@@ -896,13 +897,13 @@ class Plugin extends DAV\ServerPlugin {
         });
         $propFind->handle('{DAV:}current-user-principal', function() {
             if ($url = $this->getCurrentUserPrincipal()) {
-                return new Property\Principal(Property\Principal::HREF, $url . '/');
+                return new Xml\Property\Principal(Xml\Property\Principal::HREF, $url . '/');
             } else {
-                return new Property\Principal(Property\Principal::UNAUTHENTICATED);
+                return new Xml\Property\Principal(Xml\Property\Principal::UNAUTHENTICATED);
             }
         });
         $propFind->handle('{DAV:}supported-privilege-set', function() use ($node) {
-            return new Property\SupportedPrivilegeSet($this->getSupportedPrivilegeSet($node));
+            return new Xml\Property\SupportedPrivilegeSet($this->getSupportedPrivilegeSet($node));
         });
         $propFind->handle('{DAV:}current-user-privilege-set', function() use ($node, $propFind, $path) {
             if (!$this->checkPrivileges($path, '{DAV:}read-current-user-privilege-set', self::R_PARENT, false)) {
@@ -910,7 +911,7 @@ class Plugin extends DAV\ServerPlugin {
             } else {
                 $val = $this->getCurrentUserPrivilegeSet($node);
                 if (!is_null($val)) {
-                    return new Property\CurrentUserPrivilegeSet($val);
+                    return new Xml\Property\CurrentUserPrivilegeSet($val);
                 }
             }
         });
@@ -921,12 +922,12 @@ class Plugin extends DAV\ServerPlugin {
             } else {
                 $acl = $this->getACL($node);
                 if (!is_null($acl)) {
-                    return new Property\Acl($this->getACL($node));
+                    return new Xml\Property\Acl($this->getACL($node));
                 }
             }
         });
         $propFind->handle('{DAV:}acl-restrictions', function() {
-            return new Property\AclRestrictions();
+            return new Xml\Property\AclRestrictions();
         });
 
         /* Adding ACL properties */
@@ -1014,11 +1015,13 @@ class Plugin extends DAV\ServerPlugin {
 
         $path = $request->getPath();
         $body = $request->getBodyAsString();
-        $dom = DAV\XMLUtil::loadDOMDocument($body);
 
-        $newAcl =
-            Property\Acl::unserialize($dom->firstChild, $this->server->propertyMap)
-            ->getPrivileges();
+        if (!$body) {
+            throw new DAV\Exception\BadRequest('XML body expected in ACL request');
+        }
+
+        $acl = $this->server->xml->parse($body);
+        $newAcl = $acl['value']->getPrivileges();
 
         // Normalizing urls
         foreach($newAcl as $k=>$newAce) {
@@ -1026,7 +1029,7 @@ class Plugin extends DAV\ServerPlugin {
         }
         $node = $this->server->tree->getNodeForPath($path);
 
-        if (!($node instanceof IACL)) {
+        if (!$node instanceof IACL) {
             throw new DAV\Exception\MethodNotAllowed('This node does not support the ACL method');
         }
 
diff --git a/lib/DAVACL/Property/Acl.php b/lib/DAVACL/Property/Acl.php
deleted file mode 100644
index e140f41..0000000
--- a/lib/DAVACL/Property/Acl.php
+++ /dev/null
@@ -1,212 +0,0 @@
-<?php
-
-namespace Sabre\DAVACL\Property;
-
-use Sabre\DAV;
-
-/**
- * This class represents the {DAV:}acl property
- *
- * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://evertpot.com/)
- * @license http://sabre.io/license/ Modified BSD License
- */
-class Acl extends DAV\Property {
-
-    /**
-     * List of privileges
-     *
-     * @var array
-     */
-    private $privileges;
-
-    /**
-     * Whether or not the server base url is required to be prefixed when
-     * serializing the property.
-     *
-     * @var boolean
-     */
-    private $prefixBaseUrl;
-
-    /**
-     * Constructor
-     *
-     * This object requires a structure similar to the return value from
-     * Sabre\DAVACL\Plugin::getACL().
-     *
-     * Each privilege is a an array with at least a 'privilege' property, and a
-     * 'principal' property. A privilege may have a 'protected' property as
-     * well.
-     *
-     * The prefixBaseUrl should be set to false, if the supplied principal urls
-     * are already full urls. If this is kept to true, the servers base url
-     * will automatically be prefixed.
-     *
-     * @param bool $prefixBaseUrl
-     * @param array $privileges
-     */
-    function __construct(array $privileges, $prefixBaseUrl = true) {
-
-        $this->privileges = $privileges;
-        $this->prefixBaseUrl = $prefixBaseUrl;
-
-    }
-
-    /**
-     * Returns the list of privileges for this property
-     *
-     * @return array
-     */
-    function getPrivileges() {
-
-        return $this->privileges;
-
-    }
-
-    /**
-     * Serializes the property into a DOMElement
-     *
-     * @param DAV\Server $server
-     * @param \DOMElement $node
-     * @return void
-     */
-    function serialize(DAV\Server $server,\DOMElement $node) {
-
-        $doc = $node->ownerDocument;
-        foreach($this->privileges as $ace) {
-
-            $this->serializeAce($doc, $node, $ace, $server);
-
-        }
-
-    }
-
-    /**
-     * Unserializes the {DAV:}acl xml element.
-     *
-     * @param \DOMElement $dom
-     * @param array $propertyMap
-     * @return Acl
-     */
-    static function unserialize(\DOMElement $dom, array $propertyMap) {
-
-        $privileges = [];
-        $xaces = $dom->getElementsByTagNameNS('urn:DAV','ace');
-        for($ii=0; $ii < $xaces->length; $ii++) {
-
-            $xace = $xaces->item($ii);
-            $principal = $xace->getElementsByTagNameNS('urn:DAV','principal');
-            if ($principal->length !== 1) {
-                throw new DAV\Exception\BadRequest('Each {DAV:}ace element must have one {DAV:}principal element');
-            }
-            $principal = Principal::unserialize($principal->item(0), $propertyMap);
-
-            switch($principal->getType()) {
-                case Principal::HREF :
-                    $principal = $principal->getHref();
-                    break;
-                case Principal::AUTHENTICATED :
-                    $principal = '{DAV:}authenticated';
-                    break;
-                case Principal::UNAUTHENTICATED :
-                    $principal = '{DAV:}unauthenticated';
-                    break;
-                case Principal::ALL :
-                    $principal = '{DAV:}all';
-                    break;
-
-            }
-
-            $protected = false;
-
-            if ($xace->getElementsByTagNameNS('urn:DAV','protected')->length > 0) {
-                $protected = true;
-            }
-
-            $grants = $xace->getElementsByTagNameNS('urn:DAV','grant');
-            if ($grants->length < 1) {
-                throw new DAV\Exception\NotImplemented('Every {DAV:}ace element must have a {DAV:}grant element. {DAV:}deny is not yet supported');
-            }
-            $grant = $grants->item(0);
-
-            $xprivs = $grant->getElementsByTagNameNS('urn:DAV','privilege');
-            for($jj=0; $jj<$xprivs->length; $jj++) {
-
-                $xpriv = $xprivs->item($jj);
-
-                $privilegeName = null;
-
-                for ($kk=0;$kk<$xpriv->childNodes->length;$kk++) {
-
-                    $childNode = $xpriv->childNodes->item($kk);
-                    if ($t = DAV\XMLUtil::toClarkNotation($childNode)) {
-                        $privilegeName = $t;
-                        break;
-                    }
-                }
-                if (is_null($privilegeName)) {
-                    throw new DAV\Exception\BadRequest('{DAV:}privilege elements must have a privilege element contained within them.');
-                }
-
-                $privileges[] = [
-                    'principal' => $principal,
-                    'protected' => $protected,
-                    'privilege' => $privilegeName,
-                ];
-
-            }
-
-        }
-
-        return new self($privileges);
-
-    }
-
-    /**
-     * Serializes a single access control entry.
-     *
-     * @param \DOMDocument $doc
-     * @param \DOMElement $node
-     * @param array $ace
-     * @param DAV\Server $server
-     * @return void
-     */
-    private function serializeAce($doc,$node,$ace, DAV\Server $server) {
-
-        $xace  = $doc->createElementNS('DAV:','d:ace');
-        $node->appendChild($xace);
-
-        $principal = $doc->createElementNS('DAV:','d:principal');
-        $xace->appendChild($principal);
-        switch($ace['principal']) {
-            case '{DAV:}authenticated' :
-                $principal->appendChild($doc->createElementNS('DAV:','d:authenticated'));
-                break;
-            case '{DAV:}unauthenticated' :
-                $principal->appendChild($doc->createElementNS('DAV:','d:unauthenticated'));
-                break;
-            case '{DAV:}all' :
-                $principal->appendChild($doc->createElementNS('DAV:','d:all'));
-                break;
-            default:
-                $principal->appendChild($doc->createElementNS('DAV:','d:href',($this->prefixBaseUrl?$server->getBaseUri():'') . $ace['principal'] . '/'));
-        }
-
-        $grant = $doc->createElementNS('DAV:','d:grant');
-        $xace->appendChild($grant);
-
-        $privParts = null;
-
-        preg_match('/^{([^}]*)}(.*)$/',$ace['privilege'],$privParts);
-
-        $xprivilege = $doc->createElementNS('DAV:','d:privilege');
-        $grant->appendChild($xprivilege);
-
-        $xprivilege->appendChild($doc->createElementNS($privParts[1],'d:'.$privParts[2]));
-
-        if (isset($ace['protected']) && $ace['protected'])
-            $xace->appendChild($doc->createElement('d:protected'));
-
-    }
-
-}
diff --git a/lib/DAVACL/Property/AclRestrictions.php b/lib/DAVACL/Property/AclRestrictions.php
deleted file mode 100644
index d2bfb42..0000000
--- a/lib/DAVACL/Property/AclRestrictions.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-namespace Sabre\DAVACL\Property;
-
-use Sabre\DAV;
-
-/**
- * AclRestrictions property
- *
- * This property represents {DAV:}acl-restrictions, as defined in RFC3744.
- *
- * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://evertpot.com/)
- * @license http://sabre.io/license/ Modified BSD License
- */
-class AclRestrictions extends DAV\Property {
-
-    /**
-     * Serializes the property into a DOMElement
-     *
-     * @param DAV\Server $server
-     * @param \DOMElement $elem
-     * @return void
-     */
-    function serialize(DAV\Server $server,\DOMElement $elem) {
-
-        $doc = $elem->ownerDocument;
-
-        $elem->appendChild($doc->createElementNS('DAV:','d:grant-only'));
-        $elem->appendChild($doc->createElementNS('DAV:','d:no-invert'));
-
-    }
-
-}
diff --git a/lib/DAVACL/Property/CurrentUserPrivilegeSet.php b/lib/DAVACL/Property/CurrentUserPrivilegeSet.php
deleted file mode 100644
index 2f525f8..0000000
--- a/lib/DAVACL/Property/CurrentUserPrivilegeSet.php
+++ /dev/null
@@ -1,136 +0,0 @@
-<?php
-
-namespace Sabre\DAVACL\Property;
-
-use Sabre\DAV;
-
-/**
- * CurrentUserPrivilegeSet
- *
- * This class represents the current-user-privilege-set property. When
- * requested, it contain all the privileges a user has on a specific node.
- *
- * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://evertpot.com/)
- * @license http://sabre.io/license/ Modified BSD License
- */
-class CurrentUserPrivilegeSet extends DAV\Property {
-
-    /**
-     * List of privileges
-     *
-     * @var array
-     */
-    private $privileges;
-
-    /**
-     * Creates the object
-     *
-     * Pass the privileges in clark-notation
-     *
-     * @param array $privileges
-     */
-    function __construct(array $privileges) {
-
-        $this->privileges = $privileges;
-
-    }
-
-    /**
-     * Serializes the property in the DOM
-     *
-     * @param DAV\Server $server
-     * @param \DOMElement $node
-     * @return void
-     */
-    function serialize(DAV\Server $server,\DOMElement $node) {
-
-        $doc = $node->ownerDocument;
-        foreach($this->privileges as $privName) {
-
-            $this->serializePriv($doc,$node,$privName);
-
-        }
-
-    }
-
-    /**
-     * Returns true or false, whether the specified principal appears in the
-     * list.
-     *
-     * @return bool
-     */
-    function has($privilegeName) {
-
-        return in_array($privilegeName, $this->privileges);
-
-    }
-
-    /**
-     * Returns the list of privileges.
-     *
-     * @return array
-     */
-    function getValue() {
-
-        return $this->privileges;
-
-    }
-
-    /**
-     * Serializes one privilege
-     *
-     * @param \DOMDocument $doc
-     * @param \DOMElement $node
-     * @param string $privName
-     * @return void
-     */
-    protected function serializePriv($doc,$node,$privName) {
-
-        $xp  = $doc->createElementNS('DAV:','d:privilege');
-        $node->appendChild($xp);
-
-        $privParts = null;
-        preg_match('/^{([^}]*)}(.*)$/',$privName,$privParts);
-
-        $xp->appendChild($doc->createElementNS($privParts[1],'d:'.$privParts[2]));
-
-    }
-
-    /**
-     * Unserializes the {DAV:}current-user-privilege-set element.
-     *
-     * @param \DOMElement $node
-     * @param array $propertyMap
-     * @return CurrentUserPrivilegeSet
-     */
-    static function unserialize(\DOMElement $node, array $propertyMap) {
-
-        $result = [];
-
-        $xprivs = $node->getElementsByTagNameNS('urn:DAV','privilege');
-
-        for($jj=0; $jj<$xprivs->length; $jj++) {
-
-            $xpriv = $xprivs->item($jj);
-
-            $privilegeName = null;
-
-            for ($kk=0;$kk<$xpriv->childNodes->length;$kk++) {
-
-                $childNode = $xpriv->childNodes->item($kk);
-                if ($t = DAV\XMLUtil::toClarkNotation($childNode)) {
-                    $privilegeName = $t;
-                    break;
-                }
-            }
-
-            $result[] = $privilegeName;
-
-        }
-
-        return new self($result);
-
-    }
-
-}
diff --git a/lib/DAVACL/Property/Principal.php b/lib/DAVACL/Property/Principal.php
deleted file mode 100644
index 0d0f8a7..0000000
--- a/lib/DAVACL/Property/Principal.php
+++ /dev/null
@@ -1,164 +0,0 @@
-<?php
-
-namespace Sabre\DAVACL\Property;
-
-use Sabre\DAV;
-use Sabre\HTTP\URLUtil;
-
-/**
- * Principal property
- *
- * The principal property represents a principal from RFC3744 (ACL).
- * The property can be used to specify a principal or pseudo principals.
- *
- * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://evertpot.com/)
- * @license http://sabre.io/license/ Modified BSD License
- */
-class Principal extends DAV\Property implements DAV\Property\IHref {
-
-    /**
-     * To specify a not-logged-in user, use the UNAUTHENTICATED principal
-     */
-    const UNAUTHENTICATED = 1;
-
-    /**
-     * To specify any principal that is logged in, use AUTHENTICATED
-     */
-    const AUTHENTICATED = 2;
-
-    /**
-     * Specific principals can be specified with the HREF
-     */
-    const HREF = 3;
-
-    /**
-     * Everybody, basically
-     */
-    const ALL = 4;
-
-    /**
-     * Principal-type
-     *
-     * Must be one of the UNAUTHENTICATED, AUTHENTICATED or HREF constants.
-     *
-     * @var int
-     */
-    private $type;
-
-    /**
-     * Url to principal
-     *
-     * This value is only used for the HREF principal type.
-     *
-     * @var string
-     */
-    private $href;
-
-    /**
-     * Creates the property.
-     *
-     * The 'type' argument must be one of the type constants defined in this class.
-     *
-     * 'href' is only required for the HREF type.
-     *
-     * @param int $type
-     * @param string|null $href
-     */
-    function __construct($type, $href = null) {
-
-        $this->type = $type;
-
-        if ($type===self::HREF && is_null($href)) {
-            throw new DAV\Exception('The href argument must be specified for the HREF principal type.');
-        }
-        $this->href = $href;
-
-    }
-
-    /**
-     * Returns the principal type
-     *
-     * @return int
-     */
-    function getType() {
-
-        return $this->type;
-
-    }
-
-    /**
-     * Returns the principal uri.
-     *
-     * @return string
-     */
-    function getHref() {
-
-        return $this->href;
-
-    }
-
-    /**
-     * Serializes the property into a DOMElement.
-     *
-     * @param DAV\Server $server
-     * @param \DOMElement $node
-     * @return void
-     */
-    function serialize(DAV\Server $server, \DOMElement $node) {
-
-        $prefix = $server->xmlNamespaces['DAV:'];
-        switch($this->type) {
-
-            case self::UNAUTHENTICATED :
-                $node->appendChild(
-                    $node->ownerDocument->createElement($prefix . ':unauthenticated')
-                );
-                break;
-            case self::AUTHENTICATED :
-                $node->appendChild(
-                    $node->ownerDocument->createElement($prefix . ':authenticated')
-                );
-                break;
-            case self::HREF :
-                $href = $node->ownerDocument->createElement($prefix . ':href');
-                $href->nodeValue = $server->getBaseUri() . URLUtil::encodePath($this->href);
-                $node->appendChild($href);
-                break;
-
-        }
-
-    }
-
-    /**
-     * Deserializes a DOM element into a property object.
-     *
-     * @param \DOMElement $dom
-     * @param array $propertyMap
-     * @return Principal
-     */
-    static function unserialize(\DOMElement $dom, array $propertyMap) {
-
-        $parent = $dom->firstChild;
-        while(!DAV\XMLUtil::toClarkNotation($parent)) {
-            $parent = $parent->nextSibling;
-        }
-
-        switch(DAV\XMLUtil::toClarkNotation($parent)) {
-
-            case '{DAV:}unauthenticated' :
-                return new self(self::UNAUTHENTICATED);
-            case '{DAV:}authenticated' :
-                return new self(self::AUTHENTICATED);
-            case '{DAV:}href':
-                return new self(self::HREF, $parent->textContent);
-            case '{DAV:}all':
-                return new self(self::ALL);
-            default :
-                throw new DAV\Exception\BadRequest('Unexpected element (' . DAV\XMLUtil::toClarkNotation($parent) . '). Could not deserialize');
-
-        }
-
-    }
-
-}
diff --git a/lib/DAVACL/Property/SupportedPrivilegeSet.php b/lib/DAVACL/Property/SupportedPrivilegeSet.php
deleted file mode 100644
index 2f9e4f0..0000000
--- a/lib/DAVACL/Property/SupportedPrivilegeSet.php
+++ /dev/null
@@ -1,105 +0,0 @@
-<?php
-
-namespace Sabre\DAVACL\Property;
-
-use Sabre\DAV;
-
-/**
- * SupportedPrivilegeSet property
- *
- * This property encodes the {DAV:}supported-privilege-set property, as defined
- * in rfc3744. Please consult the rfc for details about it's structure.
- *
- * This class expects a structure like the one given from
- * Sabre\DAVACL\Plugin::getSupportedPrivilegeSet as the argument in its
- * constructor.
- *
- * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://evertpot.com/)
- * @license http://sabre.io/license/ Modified BSD License
- */
-class SupportedPrivilegeSet extends DAV\Property {
-
-    /**
-     * privileges
-     *
-     * @var array
-     */
-    private $privileges;
-
-    /**
-     * Constructor
-     *
-     * @param array $privileges
-     */
-    function __construct(array $privileges) {
-
-        $this->privileges = $privileges;
-
-    }
-
-    /**
-     * Returns the privilege value.
-     *
-     * @return array
-     */
-    function getValue() {
-
-        return $this->privileges;
-
-    }
-
-    /**
-     * Serializes the property into a domdocument.
-     *
-     * @param DAV\Server $server
-     * @param \DOMElement $node
-     * @return void
-     */
-    function serialize(DAV\Server $server,\DOMElement $node) {
-
-        $doc = $node->ownerDocument;
-        $this->serializePriv($doc, $node, $this->privileges);
-
-    }
-
-    /**
-     * Serializes a property
-     *
-     * This is a recursive function.
-     *
-     * @param \DOMDocument $doc
-     * @param \DOMElement $node
-     * @param array $privilege
-     * @return void
-     */
-    private function serializePriv($doc,$node,$privilege) {
-
-        $xsp = $doc->createElementNS('DAV:','d:supported-privilege');
-        $node->appendChild($xsp);
-
-        $xp  = $doc->createElementNS('DAV:','d:privilege');
-        $xsp->appendChild($xp);
-
-        $privParts = null;
-        preg_match('/^{([^}]*)}(.*)$/',$privilege['privilege'],$privParts);
-
-        $xp->appendChild($doc->createElementNS($privParts[1],'d:'.$privParts[2]));
-
-        if (isset($privilege['abstract']) && $privilege['abstract']) {
-            $xsp->appendChild($doc->createElementNS('DAV:','d:abstract'));
-        }
-
-        if (isset($privilege['description'])) {
-            $xsp->appendChild($doc->createElementNS('DAV:','d:description',$privilege['description']));
-        }
-
-        if (isset($privilege['aggregates'])) {
-            foreach($privilege['aggregates'] as $subPrivilege) {
-                $this->serializePriv($doc,$xsp,$subPrivilege);
-            }
-        }
-
-    }
-
-}
diff --git a/lib/DAVACL/Xml/Property/Acl.php b/lib/DAVACL/Xml/Property/Acl.php
new file mode 100644
index 0000000..68cf552
--- /dev/null
+++ b/lib/DAVACL/Xml/Property/Acl.php
@@ -0,0 +1,236 @@
+<?php
+
+namespace Sabre\DAVACL\Xml\Property;
+
+use
+    Sabre\DAV,
+    Sabre\Xml\Element,
+    Sabre\Xml\Reader,
+    Sabre\Xml\Writer;
+
+/**
+ * This class represents the {DAV:}acl property.
+ *
+ * The {DAV:}acl property is a full list of access control entries for a
+ * resource.
+ *
+ * {DAV:}acl is used as a WebDAV property, but it is also used within the body
+ * of the ACL request.
+ *
+ * See:
+ * http://tools.ietf.org/html/rfc3744#section-5.5
+ *
+ * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class Acl implements Element {
+
+    /**
+     * List of privileges
+     *
+     * @var array
+     */
+    protected $privileges;
+
+    /**
+     * Whether or not the server base url is required to be prefixed when
+     * serializing the property.
+     *
+     * @var boolean
+     */
+    protected $prefixBaseUrl;
+
+    /**
+     * Constructor
+     *
+     * This object requires a structure similar to the return value from
+     * Sabre\DAVACL\Plugin::getACL().
+     *
+     * Each privilege is a an array with at least a 'privilege' property, and a
+     * 'principal' property. A privilege may have a 'protected' property as
+     * well.
+     *
+     * The prefixBaseUrl should be set to false, if the supplied principal urls
+     * are already full urls. If this is kept to true, the servers base url
+     * will automatically be prefixed.
+     *
+     * @param bool $prefixBaseUrl
+     * @param array $privileges
+     */
+    function __construct(array $privileges, $prefixBaseUrl = true) {
+
+        $this->privileges = $privileges;
+        $this->prefixBaseUrl = $prefixBaseUrl;
+
+    }
+
+    /**
+     * Returns the list of privileges for this property
+     *
+     * @return array
+     */
+    function getPrivileges() {
+
+        return $this->privileges;
+
+    }
+
+    /**
+     * The xmlSerialize metod is called during xml writing.
+     *
+     * Use the $writer argument to write its own xml serialization.
+     *
+     * An important note: do _not_ create a parent element. Any element
+     * implementing XmlSerializble should only ever write what's considered
+     * its 'inner xml'.
+     *
+     * The parent of the current element is responsible for writing a
+     * containing element.
+     *
+     * This allows serializers to be re-used for different element names.
+     *
+     * If you are opening new elements, you must also close them again.
+     *
+     * @param Writer $writer
+     * @return void
+     */
+    function xmlSerialize(Writer $writer) {
+
+        foreach($this->privileges as $ace) {
+
+            $this->serializeAce($writer, $ace);
+
+        }
+
+    }
+
+    /**
+     * The deserialize method is called during xml parsing.
+     *
+     * This method is called statictly, this is because in theory this method
+     * may be used as a type of constructor, or factory method.
+     *
+     * Often you want to return an instance of the current class, but you are
+     * free to return other data as well.
+     *
+     * Important note 2: You are responsible for advancing the reader to the
+     * next element. Not doing anything will result in a never-ending loop.
+     *
+     * If you just want to skip parsing for this element altogether, you can
+     * just call $reader->next();
+     *
+     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+     * the next element.
+     *
+     * @param Reader $reader
+     * @return mixed
+     */
+    static function xmlDeserialize(Reader $reader) {
+
+        $elementMap = [
+            '{DAV:}ace'       => 'Sabre\Xml\Element\KeyValue',
+            '{DAV:}privilege' => 'Sabre\Xml\Element\Elements',
+            '{DAV:}principal' => 'Sabre\DAVACL\Xml\Property\Principal',
+        ];
+
+        $privileges = [];
+
+        foreach((array)$reader->parseInnerTree($elementMap) as $element) {
+
+            if ($element['name']!=='{DAV:}ace') {
+                continue;
+            }
+            $ace = $element['value'];
+
+            if (empty($ace['{DAV:}principal'])) {
+                throw new DAV\Exception\BadRequest('Each {DAV:}ace element must have one {DAV:}principal element');
+            }
+            $principal = $ace['{DAV:}principal'];
+
+            switch($principal->getType()) {
+                case Principal::HREF :
+                    $principal = $principal->getHref();
+                    break;
+                case Principal::AUTHENTICATED :
+                    $principal = '{DAV:}authenticated';
+                    break;
+                case Principal::UNAUTHENTICATED :
+                    $principal = '{DAV:}unauthenticated';
+                    break;
+                case Principal::ALL :
+                    $principal = '{DAV:}all';
+                    break;
+
+            }
+
+            $protected = array_key_exists('{DAV:}protected', $ace);
+
+            if (!isset($ace['{DAV:}grant'])) {
+                throw new DAV\Exception\NotImplemented('Every {DAV:}ace element must have a {DAV:}grant element. {DAV:}deny is not yet supported');
+            }
+            foreach($ace['{DAV:}grant'] as $elem) {
+                if ($elem['name'] !== '{DAV:}privilege') {
+                    continue;
+                }
+
+                foreach($elem['value'] as $priv) {
+                    $privileges[] = [
+                        'principal' => $principal,
+                        'protected' => $protected,
+                        'privilege' => $priv,
+                    ];
+                }
+
+            }
+
+        }
+
+        return new self($privileges);
+
+    }
+
+    /**
+     * Serializes a single access control entry.
+     *
+     * @param Writer $writer
+     * @param array $ace
+     * @return void
+     */
+    private function serializeAce(Writer $writer, array $ace) {
+
+        $writer->startElement('{DAV:}ace');
+
+        switch($ace['principal']) {
+            case '{DAV:}authenticated' :
+                $principal = new Principal(Principal::AUTHENTICATED);
+                break;
+            case '{DAV:}unauthenticated' :
+                $principal = new Principal(Principal::UNAUTHENTICATED);
+                break;
+            case '{DAV:}all' :
+                $principal = new Principal(Principal::ALL);
+                break;
+            default:
+                $principal = new Principal(Principal::HREF, $ace['principal']);
+                break;
+        }
+
+        $writer->writeElement('{DAV:}principal', $principal);
+        $writer->startElement('{DAV:}grant');
+        $writer->startElement('{DAV:}privilege');
+
+        $writer->writeElement($ace['privilege']);
+
+        $writer->endElement(); // privilege
+        $writer->endElement(); // grant
+
+        if (!empty($ace['protected'])) {
+            $writer->writeElement('{DAV:}protected');
+        }
+
+        $writer->endElement(); // ace
+
+    }
+
+}
diff --git a/lib/DAVACL/Xml/Property/AclRestrictions.php b/lib/DAVACL/Xml/Property/AclRestrictions.php
new file mode 100644
index 0000000..3d61e09
--- /dev/null
+++ b/lib/DAVACL/Xml/Property/AclRestrictions.php
@@ -0,0 +1,47 @@
+<?php
+
+namespace Sabre\DAVACL\Xml\Property;
+
+use
+    Sabre\DAV,
+    Sabre\Xml\XmlSerializable,
+    Sabre\Xml\Writer;
+
+/**
+ * AclRestrictions property
+ *
+ * This property represents {DAV:}acl-restrictions, as defined in RFC3744.
+ *
+ * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class AclRestrictions implements XmlSerializable {
+
+    /**
+     * The xmlSerialize metod is called during xml writing.
+     *
+     * Use the $writer argument to write its own xml serialization.
+     *
+     * An important note: do _not_ create a parent element. Any element
+     * implementing XmlSerializble should only ever write what's considered
+     * its 'inner xml'.
+     *
+     * The parent of the current element is responsible for writing a
+     * containing element.
+     *
+     * This allows serializers to be re-used for different element names.
+     *
+     * If you are opening new elements, you must also close them again.
+     *
+     * @param Writer $writer
+     * @return void
+     */
+    function xmlSerialize(Writer $writer) {
+
+        $writer->writeElement('{DAV:}grant-only');
+        $writer->writeElement('{DAV:}no-invert');
+
+    }
+
+}
diff --git a/lib/DAVACL/Xml/Property/CurrentUserPrivilegeSet.php b/lib/DAVACL/Xml/Property/CurrentUserPrivilegeSet.php
new file mode 100644
index 0000000..20750cc
--- /dev/null
+++ b/lib/DAVACL/Xml/Property/CurrentUserPrivilegeSet.php
@@ -0,0 +1,134 @@
+<?php
+
+namespace Sabre\DAVACL\Xml\Property;
+
+use
+    Sabre\DAV,
+    Sabre\Xml\Element,
+    Sabre\Xml\Reader,
+    Sabre\Xml\Writer;
+
+/**
+ * CurrentUserPrivilegeSet
+ *
+ * This class represents the current-user-privilege-set property. When
+ * requested, it contain all the privileges a user has on a specific node.
+ *
+ * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class CurrentUserPrivilegeSet implements Element {
+
+    /**
+     * List of privileges
+     *
+     * @var array
+     */
+    private $privileges;
+
+    /**
+     * Creates the object
+     *
+     * Pass the privileges in clark-notation
+     *
+     * @param array $privileges
+     */
+    function __construct(array $privileges) {
+
+        $this->privileges = $privileges;
+
+    }
+
+    /**
+     * The xmlSerialize metod is called during xml writing.
+     *
+     * Use the $writer argument to write its own xml serialization.
+     *
+     * An important note: do _not_ create a parent element. Any element
+     * implementing XmlSerializble should only ever write what's considered
+     * its 'inner xml'.
+     *
+     * The parent of the current element is responsible for writing a
+     * containing element.
+     *
+     * This allows serializers to be re-used for different element names.
+     *
+     * If you are opening new elements, you must also close them again.
+     *
+     * @param Writer $writer
+     * @return void
+     */
+    function xmlSerialize(Writer $writer) {
+
+        foreach($this->privileges as $privName) {
+
+            $writer->startElement('{DAV:}privilege');
+            $writer->writeElement($privName);
+            $writer->endElement();
+
+        }
+
+
+    }
+
+    /**
+     * Returns true or false, whether the specified principal appears in the
+     * list.
+     *
+     * @return bool
+     */
+    function has($privilegeName) {
+
+        return in_array($privilegeName, $this->privileges);
+
+    }
+
+    /**
+     * Returns the list of privileges.
+     *
+     * @return array
+     */
+    function getValue() {
+
+        return $this->privileges;
+
+    }
+
+    /**
+     * The deserialize method is called during xml parsing.
+     *
+     * This method is called statictly, this is because in theory this method
+     * may be used as a type of constructor, or factory method.
+     *
+     * Often you want to return an instance of the current class, but you are
+     * free to return other data as well.
+     *
+     * Important note 2: You are responsible for advancing the reader to the
+     * next element. Not doing anything will result in a never-ending loop.
+     *
+     * If you just want to skip parsing for this element altogether, you can
+     * just call $reader->next();
+     *
+     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+     * the next element.
+     *
+     * @param Reader $reader
+     * @return mixed
+     */
+    static function xmlDeserialize(Reader $reader) {
+
+        $result = [];
+
+        $tree = $reader->parseInnerTree(['{DAV:}privilege' => 'Sabre\\Xml\\Element\\Elements']);
+        foreach($tree as $element) {
+            if ($element['name'] !== '{DAV:}privilege') {
+                continue;
+            }
+            $result[] = $element['value'][0];
+        }
+        return new self($result);
+
+    }
+
+}
diff --git a/lib/DAVACL/Xml/Property/Principal.php b/lib/DAVACL/Xml/Property/Principal.php
new file mode 100644
index 0000000..521f56c
--- /dev/null
+++ b/lib/DAVACL/Xml/Property/Principal.php
@@ -0,0 +1,167 @@
+<?php
+
+namespace Sabre\DAVACL\Xml\Property;
+
+use
+    Sabre\DAV,
+    Sabre\DAV\Exception\BadRequest,
+    Sabre\Xml\Element,
+    Sabre\Xml\Reader,
+    Sabre\Xml\Writer;
+
+/**
+ * Principal property
+ *
+ * The principal property represents a principal from RFC3744 (ACL).
+ * The property can be used to specify a principal or pseudo principals.
+ *
+ * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class Principal extends DAV\Xml\Property\Href {
+
+    /**
+     * To specify a not-logged-in user, use the UNAUTHENTICATED principal
+     */
+    const UNAUTHENTICATED = 1;
+
+    /**
+     * To specify any principal that is logged in, use AUTHENTICATED
+     */
+    const AUTHENTICATED = 2;
+
+    /**
+     * Specific principals can be specified with the HREF
+     */
+    const HREF = 3;
+
+    /**
+     * Everybody, basically
+     */
+    const ALL = 4;
+
+    /**
+     * Principal-type
+     *
+     * Must be one of the UNAUTHENTICATED, AUTHENTICATED or HREF constants.
+     *
+     * @var int
+     */
+    protected $type;
+
+    /**
+     * Creates the property.
+     *
+     * The 'type' argument must be one of the type constants defined in this class.
+     *
+     * 'href' is only required for the HREF type.
+     *
+     * @param int $type
+     * @param string|null $href
+     */
+    function __construct($type, $href = null) {
+
+        $this->type = $type;
+        if ($type===self::HREF && is_null($href)) {
+            throw new DAV\Exception('The href argument must be specified for the HREF principal type.');
+        }
+        if ($href) {
+            $href = rtrim($href,'/') . '/';
+            parent::__construct($href);
+        }
+
+    }
+
+    /**
+     * Returns the principal type
+     *
+     * @return int
+     */
+    function getType() {
+
+        return $this->type;
+
+    }
+
+   
+    /**
+     * The xmlSerialize metod is called during xml writing.
+     *
+     * Use the $writer argument to write its own xml serialization.
+     *
+     * An important note: do _not_ create a parent element. Any element
+     * implementing XmlSerializble should only ever write what's considered
+     * its 'inner xml'.
+     *
+     * The parent of the current element is responsible for writing a
+     * containing element.
+     *
+     * This allows serializers to be re-used for different element names.
+     *
+     * If you are opening new elements, you must also close them again.
+     *
+     * @param Writer $writer
+     * @return void
+     */
+    function xmlSerialize(Writer $writer) {
+
+        switch($this->type) {
+
+            case self::UNAUTHENTICATED :
+                $writer->writeElement('{DAV:}unauthenticated');
+                break;
+            case self::AUTHENTICATED :
+                $writer->writeElement('{DAV:}authenticated');
+                break;
+            case self::HREF :
+                parent::xmlSerialize($writer);
+                break;
+            case self::ALL :
+                $writer->writeElement('{DAV:}all');
+                break;
+        }
+
+    }
+
+    /**
+     * The deserialize method is called during xml parsing.
+     *
+     * This method is called statictly, this is because in theory this method
+     * may be used as a type of constructor, or factory method.
+     *
+     * Often you want to return an instance of the current class, but you are
+     * free to return other data as well.
+     *
+     * Important note 2: You are responsible for advancing the reader to the
+     * next element. Not doing anything will result in a never-ending loop.
+     *
+     * If you just want to skip parsing for this element altogether, you can
+     * just call $reader->next();
+     *
+     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+     * the next element.
+     *
+     * @param Reader $reader
+     * @return mixed
+     */
+    static function xmlDeserialize(Reader $reader) {
+
+        $tree = $reader->parseInnerTree()[0];
+
+        switch($tree['name']) {
+            case '{DAV:}unauthenticated' :
+                return new self(self::UNAUTHENTICATED);
+            case '{DAV:}authenticated' :
+                return new self(self::AUTHENTICATED);
+            case '{DAV:}href':
+                return new self(self::HREF, $tree['value']);
+            case '{DAV:}all':
+                return new self(self::ALL);
+            default :
+                throw new BadRequest('Unknown or unsupported principal type: ' . $tree['name']); 
+        }
+
+    }
+
+}
diff --git a/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php b/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php
new file mode 100644
index 0000000..e76c206
--- /dev/null
+++ b/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php
@@ -0,0 +1,115 @@
+<?php
+
+namespace Sabre\DAVACL\Xml\Property;
+
+use
+    Sabre\DAV,
+    Sabre\Xml\XmlSerializable,
+    Sabre\Xml\Reader,
+    Sabre\Xml\Writer;
+
+/**
+ * SupportedPrivilegeSet property
+ *
+ * This property encodes the {DAV:}supported-privilege-set property, as defined
+ * in rfc3744. Please consult the rfc for details about it's structure.
+ *
+ * This class expects a structure like the one given from
+ * Sabre\DAVACL\Plugin::getSupportedPrivilegeSet as the argument in its
+ * constructor.
+ *
+ * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class SupportedPrivilegeSet implements XmlSerializable {
+
+    /**
+     * privileges
+     *
+     * @var array
+     */
+    protected $privileges;
+
+    /**
+     * Constructor
+     *
+     * @param array $privileges
+     */
+    function __construct(array $privileges) {
+
+        $this->privileges = $privileges;
+
+    }
+
+    /**
+     * Returns the privilege value.
+     *
+     * @return array
+     */
+    function getValue() {
+
+        return $this->privileges;
+
+    }
+
+    /**
+     * The xmlSerialize metod is called during xml writing.
+     *
+     * Use the $writer argument to write its own xml serialization.
+     *
+     * An important note: do _not_ create a parent element. Any element
+     * implementing XmlSerializble should only ever write what's considered
+     * its 'inner xml'.
+     *
+     * The parent of the current element is responsible for writing a
+     * containing element.
+     *
+     * This allows serializers to be re-used for different element names.
+     *
+     * If you are opening new elements, you must also close them again.
+     *
+     * @param Writer $writer
+     * @return void
+     */
+    function xmlSerialize(Writer $writer) {
+
+        $this->serializePriv($writer, $this->privileges);
+
+    }
+
+
+    /**
+     * Serializes a property
+     *
+     * This is a recursive function.
+     *
+     * @param Writer $writer
+     * @param array $privilege
+     * @return void
+     */
+    private function serializePriv(Writer $writer,$privilege) {
+
+        $writer->startElement('{DAV:}supported-privilege');
+
+        $writer->startElement('{DAV:}privilege');
+        $writer->writeElement($privilege['privilege']);
+        $writer->endElement(); // privilege
+
+        if (!empty($privilege['abstract'])) {
+            $writer->writeElement('{DAV:}abstract');
+        }
+        if (!empty($privilege['description'])) {
+            $writer->writeElement('{DAV:}description', $privilege['description']);
+        }
+        if (isset($privilege['aggregates'])) {
+            foreach($privilege['aggregates'] as $subPrivilege) {
+                $this->serializePriv($writer, $subPrivilege);
+            }
+        }
+
+        $writer->endElement(); // supported-privilege
+
+    }
+
+}
diff --git a/tests/Sabre/DAVACL/PluginPropertiesTest.php b/tests/Sabre/DAVACL/PluginPropertiesTest.php
index 03218db..aa367de 100644
--- a/tests/Sabre/DAVACL/PluginPropertiesTest.php
+++ b/tests/Sabre/DAVACL/PluginPropertiesTest.php
@@ -58,8 +58,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
 
         $this->assertEquals(1,count($result[200]));
         $this->assertArrayHasKey('{DAV:}current-user-principal',$result[200]);
-        $this->assertInstanceOf('Sabre\DAVACL\Property\Principal', $result[200]['{DAV:}current-user-principal']);
-        $this->assertEquals(Property\Principal::UNAUTHENTICATED, $result[200]['{DAV:}current-user-principal']->getType());
+        $this->assertInstanceOf('Sabre\DAVACL\Xml\Property\Principal', $result[200]['{DAV:}current-user-principal']);
+        $this->assertEquals(Xml\Property\Principal::UNAUTHENTICATED, $result[200]['{DAV:}current-user-principal']->getType());
 
         // This will force the login
         $fakeServer->emit('beforeMethod', [$fakeServer->httpRequest, $fakeServer->httpResponse]);
@@ -69,8 +69,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
 
         $this->assertEquals(1,count($result[200]));
         $this->assertArrayHasKey('{DAV:}current-user-principal',$result[200]);
-        $this->assertInstanceOf('Sabre\DAVACL\Property\Principal', $result[200]['{DAV:}current-user-principal']);
-        $this->assertEquals(Property\Principal::HREF, $result[200]['{DAV:}current-user-principal']->getType());
+        $this->assertInstanceOf('Sabre\DAVACL\Xml\Property\Principal', $result[200]['{DAV:}current-user-principal']);
+        $this->assertEquals(Xml\Property\Principal::HREF, $result[200]['{DAV:}current-user-principal']->getType());
         $this->assertEquals('principals/admin/', $result[200]['{DAV:}current-user-principal']->getHref());
 
     }
@@ -90,17 +90,12 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
 
         $this->assertEquals(1,count($result[200]));
         $this->assertArrayHasKey('{DAV:}supported-privilege-set',$result[200]);
-        $this->assertInstanceOf('Sabre\\DAVACL\\Property\\SupportedPrivilegeSet', $result[200]['{DAV:}supported-privilege-set']);
+        $this->assertInstanceOf('Sabre\\DAVACL\\Xml\\Property\\SupportedPrivilegeSet', $result[200]['{DAV:}supported-privilege-set']);
 
         $server = new DAV\Server();
-        $prop = $result[200]['{DAV:}supported-privilege-set'];
-
-        $dom = new \DOMDocument('1.0', 'utf-8');
-        $root = $dom->createElement('d:root');
-        $root->setAttribute('xmlns:d','DAV:');
-        $dom->appendChild($root);
-        $prop->serialize($server, $root);
 
+        $prop = $result[200]['{DAV:}supported-privilege-set'];
+        $result = $server->xml->write(['{DAV:}root' => $prop]);
 
         $xpaths = [
             '/d:root' => 1,
@@ -128,13 +123,13 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
 
         // reloading because php dom sucks
         $dom2 = new \DOMDocument('1.0', 'utf-8');
-        $dom2->loadXML($dom->saveXML());
+        $dom2->loadXML($result);
 
         $dxpath = new \DOMXPath($dom2);
         $dxpath->registerNamespace('d','DAV:');
         foreach($xpaths as $xpath=>$count) {
 
-            $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count);
+            $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count. ' Full XML: ' . $result);
 
         }
 
@@ -174,7 +169,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
 
         $this->assertEquals(1,count($result[200]),'The {DAV:}acl property did not return from the list. Full list: ' . print_r($result, true));
         $this->assertArrayHasKey('{DAV:}acl',$result[200]);
-        $this->assertInstanceOf('Sabre\\DAVACL\\Property\\ACL', $result[200]['{DAV:}acl']);
+        $this->assertInstanceOf('Sabre\\DAVACL\\Xml\Property\\Acl', $result[200]['{DAV:}acl']);
 
     }
 
@@ -212,7 +207,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
 
         $this->assertEquals(1,count($result[200]),'The {DAV:}acl-restrictions property did not return from the list. Full list: ' . print_r($result, true));
         $this->assertArrayHasKey('{DAV:}acl-restrictions',$result[200]);
-        $this->assertInstanceOf('Sabre\\DAVACL\\Property\\ACLRestrictions', $result[200]['{DAV:}acl-restrictions']);
+        $this->assertInstanceOf('Sabre\\DAVACL\\Xml\\Property\\AclRestrictions', $result[200]['{DAV:}acl-restrictions']);
 
     }
 
diff --git a/tests/Sabre/DAVACL/Property/ACLRestrictionsTest.php b/tests/Sabre/DAVACL/Property/ACLRestrictionsTest.php
deleted file mode 100644
index c6825f5..0000000
--- a/tests/Sabre/DAVACL/Property/ACLRestrictionsTest.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-namespace Sabre\DAVACL\Property;
-
-use Sabre\DAV;
-use Sabre\HTTP;
-
-class ACLRestrictionsTest extends \PHPUnit_Framework_TestCase {
-
-    function testConstruct() {
-
-        $prop = new AclRestrictions();
-        $this->assertInstanceOf('Sabre\DAVACL\Property\ACLRestrictions', $prop);
-
-    }
-
-    function testSerializeEmpty() {
-
-        $dom = new \DOMDocument('1.0');
-        $root = $dom->createElementNS('DAV:','d:root');
-
-        $dom->appendChild($root);
-
-        $acl = new AclRestrictions();
-        $acl->serialize(new DAV\Server(), $root);
-
-        $xml = $dom->saveXML();
-        $expected = '<?xml version="1.0"?>
-<d:root xmlns:d="DAV:"><d:grant-only/><d:no-invert/></d:root>
-';
-        $this->assertEquals($expected, $xml);
-
-    }
-
-
-}
diff --git a/tests/Sabre/DAVACL/Property/ACLTest.php b/tests/Sabre/DAVACL/Xml/Property/ACLTest.php
similarity index 68%
rename from tests/Sabre/DAVACL/Property/ACLTest.php
rename to tests/Sabre/DAVACL/Xml/Property/ACLTest.php
index c2f7b19..d942fc3 100644
--- a/tests/Sabre/DAVACL/Property/ACLTest.php
+++ b/tests/Sabre/DAVACL/Xml/Property/ACLTest.php
@@ -1,67 +1,52 @@
 <?php
 
-namespace Sabre\DAVACL\Property;
+namespace Sabre\DAVACL\Xml\Property;
 
 use Sabre\DAV;
 use Sabre\HTTP;
 
-
 class ACLTest extends \PHPUnit_Framework_TestCase {
 
     function testConstruct() {
 
         $acl = new Acl(array());
-        $this->assertInstanceOf('Sabre\DAVACL\Property\ACL', $acl);
+        $this->assertInstanceOf('Sabre\DAVACL\Xml\Property\ACL', $acl);
 
     }
 
     function testSerializeEmpty() {
 
-        $dom = new \DOMDocument('1.0');
-        $root = $dom->createElementNS('DAV:','d:root');
-
-        $dom->appendChild($root);
-
         $acl = new Acl(array());
-        $acl->serialize(new DAV\Server(), $root);
+        $xml = (new DAV\Server())->xml->write(['{DAV:}root' => $acl]);
 
-        $xml = $dom->saveXML();
         $expected = '<?xml version="1.0"?>
-<d:root xmlns:d="DAV:"/>
-';
-        $this->assertEquals($expected, $xml);
+<d:root xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" />';
+
+        $this->assertXmlStringEqualsXmlString($expected, $xml);
 
     }
 
     function testSerialize() {
 
-        $dom = new \DOMDocument('1.0');
-        $root = $dom->createElementNS('DAV:','d:root');
-
-        $dom->appendChild($root);
-
-        $privileges = array(
-            array(
+        $privileges = [  
+            [ 
                 'principal' => 'principals/evert',
                 'privilege' => '{DAV:}write',
                 'uri'       => 'articles',
-            ),
-            array(
+            ],
+            [ 
                 'principal' => 'principals/foo',
                 'privilege' => '{DAV:}read',
                 'uri'       => 'articles',
                 'protected' => true,
-            ),
-        );
+            ],
+        ];
 
         $acl = new Acl($privileges);
-        $acl->serialize(new DAV\Server(), $root);
-
-        $dom->formatOutput = true;
+        $xml = (new DAV\Server())->xml->write(['{DAV:}root' => $acl], '/');
 
-        $xml = $dom->saveXML();
         $expected = '<?xml version="1.0"?>
-<d:root xmlns:d="DAV:">
+<d:root xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
   <d:ace>
     <d:principal>
       <d:href>/principals/evert/</d:href>
@@ -85,17 +70,12 @@ class ACLTest extends \PHPUnit_Framework_TestCase {
   </d:ace>
 </d:root>
 ';
-        $this->assertEquals($expected, $xml);
+        $this->assertXmlStringEqualsXmlString($expected, $xml);
 
     }
 
     function testSerializeSpecialPrincipals() {
 
-        $dom = new \DOMDocument('1.0');
-        $root = $dom->createElementNS('DAV:','d:root');
-
-        $dom->appendChild($root);
-
         $privileges = array(
             array(
                 'principal' => '{DAV:}authenticated',
@@ -116,13 +96,10 @@ class ACLTest extends \PHPUnit_Framework_TestCase {
         );
 
         $acl = new Acl($privileges);
-        $acl->serialize(new DAV\Server(), $root);
-
-        $dom->formatOutput = true;
+        $xml = (new DAV\Server())->xml->write(['{DAV:}root' => $acl], '/');
 
-        $xml = $dom->saveXML();
         $expected = '<?xml version="1.0"?>
-<d:root xmlns:d="DAV:">
+<d:root xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
   <d:ace>
     <d:principal>
       <d:authenticated/>
@@ -155,7 +132,7 @@ class ACLTest extends \PHPUnit_Framework_TestCase {
   </d:ace>
 </d:root>
 ';
-        $this->assertEquals($expected, $xml);
+        $this->assertXmlStringEqualsXmlString($expected, $xml);
 
     }
 
@@ -187,10 +164,14 @@ class ACLTest extends \PHPUnit_Framework_TestCase {
 </d:root>
 ';
 
-        $dom = DAV\XMLUtil::loadDOMDocument($source);
-        $result = Acl::unserialize($dom->firstChild, array());
+        $reader = new \Sabre\Xml\Reader();
+        $reader->elementMap['{DAV:}root'] = 'Sabre\DAVACL\Xml\Property\Acl';
+        $reader->xml($source);
+
+        $result = $reader->parse();
+        $result = $result['value'];
 
-        $this->assertInstanceOf('Sabre\\DAVACL\\Property\\ACL', $result);
+        $this->assertInstanceOf('Sabre\\DAVACL\\Xml\\Property\\Acl', $result);
 
         $expected = array(
             array(
@@ -227,8 +208,12 @@ class ACLTest extends \PHPUnit_Framework_TestCase {
 </d:root>
 ';
 
-        $dom = DAV\XMLUtil::loadDOMDocument($source);
-        Acl::unserialize($dom->firstChild, array());
+
+        $reader = new \Sabre\Xml\Reader();
+        $reader->elementMap['{DAV:}root'] = 'Sabre\DAVACL\Xml\Property\Acl';
+        $reader->xml($source);
+
+        $result = $reader->parse();
 
     }
 
@@ -263,32 +248,35 @@ class ACLTest extends \PHPUnit_Framework_TestCase {
 </d:root>
 ';
 
-        $dom = DAV\XMLUtil::loadDOMDocument($source);
-        $result = Acl::unserialize($dom->firstChild, array());
+        $reader = new \Sabre\Xml\Reader();
+        $reader->elementMap['{DAV:}root'] = 'Sabre\DAVACL\Xml\Property\Acl';
+        $reader->xml($source);
 
-        $this->assertInstanceOf('Sabre\\DAVACL\\Property\\Acl', $result);
+        $result = $reader->parse();
+        $result = $result['value'];
 
-        $expected = array(
-            array(
+        $this->assertInstanceOf('Sabre\\DAVACL\\Xml\\Property\\Acl', $result);
+
+        $expected = [ 
+            [
                 'principal' => '{DAV:}authenticated',
                 'protected' => false,
                 'privilege' => '{DAV:}write',
-            ),
-            array(
+            ],
+            [ 
                 'principal' => '{DAV:}unauthenticated',
                 'protected' => false,
                 'privilege' => '{DAV:}write',
-            ),
-            array(
+            ],
+            [ 
                 'principal' => '{DAV:}all',
                 'protected' => false,
                 'privilege' => '{DAV:}write',
-            ),
-        );
+            ],
+        ];
 
         $this->assertEquals($expected, $result->getPrivileges());
 
-
     }
 
     /**
@@ -309,28 +297,12 @@ class ACLTest extends \PHPUnit_Framework_TestCase {
 </d:root>
 ';
 
-        $dom = DAV\XMLUtil::loadDOMDocument($source);
-        Acl::unserialize($dom->firstChild, array());
-    }
-
-    /**
-     * @expectedException Sabre\DAV\Exception\BadRequest
-     */
-    function testUnserializeMissingPriv() {
-
-        $source = '<?xml version="1.0"?>
-<d:root xmlns:d="DAV:">
-  <d:ace>
-    <d:grant>
-      <d:privilege />
-    </d:grant>
-    <d:principal><d:href>/principals/evert</d:href></d:principal>
-  </d:ace>
-</d:root>
-';
+        $reader = new \Sabre\Xml\Reader();
+        $reader->elementMap['{DAV:}root'] = 'Sabre\DAVACL\Xml\Property\Acl';
+        $reader->xml($source);
 
-        $dom = DAV\XMLUtil::loadDOMDocument($source);
-        Acl::unserialize($dom->firstChild, array());
+        $result = $reader->parse();
 
     }
+
 }
diff --git a/tests/Sabre/DAVACL/Xml/Property/AclRestrictionsTest.php b/tests/Sabre/DAVACL/Xml/Property/AclRestrictionsTest.php
new file mode 100644
index 0000000..4399b88
--- /dev/null
+++ b/tests/Sabre/DAVACL/Xml/Property/AclRestrictionsTest.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace Sabre\DAVACL\Xml\Property;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+class AclRestrictionsTest extends \PHPUnit_Framework_TestCase {
+
+    function testConstruct() {
+
+        $prop = new AclRestrictions();
+        $this->assertInstanceOf('Sabre\DAVACL\Xml\Property\AclRestrictions', $prop);
+
+    }
+
+    function testSerialize() {
+
+        $prop = new AclRestrictions();
+        $xml = (new DAV\Server())->xml->write(['{DAV:}root' => $prop]);
+
+        $expected = '<?xml version="1.0"?>
+<d:root xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns"><d:grant-only/><d:no-invert/></d:root>';
+
+        $this->assertXmlStringEqualsXmlString($expected, $xml);
+
+    }
+
+
+}
diff --git a/tests/Sabre/DAVACL/Property/CurrentUserPrivilegeSetTest.php b/tests/Sabre/DAVACL/Xml/Property/CurrentUserPrivilegeSetTest.php
similarity index 70%
rename from tests/Sabre/DAVACL/Property/CurrentUserPrivilegeSetTest.php
rename to tests/Sabre/DAVACL/Xml/Property/CurrentUserPrivilegeSetTest.php
index d3db35f..54e0ed5 100644
--- a/tests/Sabre/DAVACL/Property/CurrentUserPrivilegeSetTest.php
+++ b/tests/Sabre/DAVACL/Xml/Property/CurrentUserPrivilegeSetTest.php
@@ -1,28 +1,23 @@
 <?php
 
-namespace Sabre\DAVACL\Property;
+namespace Sabre\DAVACL\Xml\Property;
 
 use Sabre\DAV;
 use Sabre\DAV\XMLUtil;
 use Sabre\HTTP;
+use Sabre\Xml\Reader;
 
 
 class CurrentUserPrivilegeSetTest extends \PHPUnit_Framework_TestCase {
 
     function testSerialize() {
 
-        $privileges = array(
+        $privileges = [ 
             '{DAV:}read',
             '{DAV:}write',
-        );
+        ];
         $prop = new CurrentUserPrivilegeSet($privileges);
-
-        $server = new DAV\Server();
-        $dom = new \DOMDocument('1.0','utf-8');
-        $root = $dom->createElementNS('DAV:','d:root');
-        $dom->appendChild($root);
-
-        $prop->serialize($server, $root);
+        $xml = (new DAV\Server())->xml->write(['{DAV:}root' => $prop]);
 
         $xpaths = array(
             '/d:root' => 1,
@@ -31,8 +26,7 @@ class CurrentUserPrivilegeSetTest extends \PHPUnit_Framework_TestCase {
             '/d:root/d:privilege/d:write' => 1,
         );
 
-        // Reloading because PHP DOM sucks
-        $dom2 = XMLUtil::loadDOMDocument($dom->saveXML());
+        $dom2 = XMLUtil::loadDOMDocument($xml);
 
         $dxpath = new \DOMXPath($dom2);
         $dxpath->registerNamespace('d','urn:DAV');
@@ -56,12 +50,21 @@ class CurrentUserPrivilegeSetTest extends \PHPUnit_Framework_TestCase {
 </d:root>
 ';
 
-        $dom = DAV\XMLUtil::loadDOMDocument($source);
-        $result = CurrentUserPrivilegeSet::unserialize($dom->firstChild, array());
+        $result = $this->parse($source);
         $this->assertTrue($result->has('{DAV:}read'));
         $this->assertTrue($result->has('{DAV:}write-properties'));
         $this->assertFalse($result->has('{DAV:}bind'));
 
     }
 
+    function parse($xml) {
+
+        $reader = new Reader();
+        $reader->elementMap['{DAV:}root'] = 'Sabre\\DAVACL\\Xml\\Property\\CurrentUserPrivilegeSet';
+        $reader->xml($xml);
+        $result = $reader->parse();
+        return $result['value'];
+
+    }
+
 }
diff --git a/tests/Sabre/DAVACL/Property/PrincipalTest.php b/tests/Sabre/DAVACL/Xml/Property/PrincipalTest.php
similarity index 55%
rename from tests/Sabre/DAVACL/Property/PrincipalTest.php
rename to tests/Sabre/DAVACL/Xml/Property/PrincipalTest.php
index 1972968..0108bbf 100644
--- a/tests/Sabre/DAVACL/Property/PrincipalTest.php
+++ b/tests/Sabre/DAVACL/Xml/Property/PrincipalTest.php
@@ -1,9 +1,10 @@
 <?php
 
-namespace Sabre\DAVACL\Property;
+namespace Sabre\DAVACL\Xml\Property;
 
 use Sabre\DAV;
 use Sabre\HTTP;
+use Sabre\Xml\Reader;
 
 class PrincipalTest extends \PHPUnit_Framework_TestCase {
 
@@ -19,7 +20,7 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase {
 
         $principal = new Principal(Principal::HREF,'admin');
         $this->assertEquals(Principal::HREF, $principal->getType());
-        $this->assertEquals('admin',$principal->getHref());
+        $this->assertEquals('admin/',$principal->getHref());
 
     }
 
@@ -40,24 +41,12 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase {
 
         $prin = new Principal(Principal::UNAUTHENTICATED);
 
-        $doc = new \DOMDocument();
-        $root = $doc->createElement('d:principal');
-        $root->setAttribute('xmlns:d','DAV:');
-
-        $doc->appendChild($root);
-        $node = new DAV\SimpleCollection('rootdir');
-        $server = new DAV\Server($node);
-
-        $prin->serialize($server, $root);
-
-        $xml = $doc->saveXML();
+        $xml = (new DAV\Server())->xml->write(['{DAV:}principal' => $prin]);
 
         $this->assertEquals(
-'<?xml version="1.0"?>
-<d:principal xmlns:d="DAV:">' .
+'<d:principal xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">' .
 '<d:unauthenticated/>' .
-'</d:principal>
-', $xml);
+'</d:principal>', $xml);
 
     }
 
@@ -68,25 +57,12 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase {
     function testSerializeAuthenticated() {
 
         $prin = new Principal(Principal::AUTHENTICATED);
-
-        $doc = new \DOMDocument();
-        $root = $doc->createElement('d:principal');
-        $root->setAttribute('xmlns:d','DAV:');
-
-        $doc->appendChild($root);
-        $objectTree = new DAV\Tree(new DAV\SimpleCollection('rootdir'));
-        $server = new DAV\Server($objectTree);
-
-        $prin->serialize($server, $root);
-
-        $xml = $doc->saveXML();
+        $xml = (new DAV\Server())->xml->write(['{DAV:}principal' => $prin]);
 
         $this->assertEquals(
-'<?xml version="1.0"?>
-<d:principal xmlns:d="DAV:">' .
+'<d:principal xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">' .
 '<d:authenticated/>' .
-'</d:principal>
-', $xml);
+'</d:principal>', $xml);
 
     }
 
@@ -97,25 +73,12 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase {
     function testSerializeHref() {
 
         $prin = new Principal(Principal::HREF,'principals/admin');
-
-        $doc = new \DOMDocument();
-        $root = $doc->createElement('d:principal');
-        $root->setAttribute('xmlns:d','DAV:');
-
-        $doc->appendChild($root);
-        $objectTree = new DAV\Tree(new DAV\SimpleCollection('rootdir'));
-        $server = new DAV\Server($objectTree);
-
-        $prin->serialize($server, $root);
-
-        $xml = $doc->saveXML();
+        $xml = (new DAV\Server())->xml->write(['{DAV:}principal' => $prin], '/');
 
         $this->assertEquals(
-'<?xml version="1.0"?>
-<d:principal xmlns:d="DAV:">' .
-'<d:href>/principals/admin</d:href>' .
-'</d:principal>
-', $xml);
+'<d:principal xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">' .
+'<d:href>/principals/admin/</d:href>' .
+'</d:principal>', $xml);
 
     }
 
@@ -126,11 +89,9 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase {
 '<d:href>/principals/admin</d:href>' .
 '</d:principal>';
 
-        $dom = DAV\XMLUtil::loadDOMDocument($xml);
-
-        $principal = Principal::unserialize($dom->firstChild, array());
+        $principal = $this->parse($xml);
         $this->assertEquals(Principal::HREF, $principal->getType());
-        $this->assertEquals('/principals/admin', $principal->getHref());
+        $this->assertEquals('/principals/admin/', $principal->getHref());
 
     }
 
@@ -141,9 +102,7 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase {
 '  <d:authenticated />' .
 '</d:principal>';
 
-        $dom = DAV\XMLUtil::loadDOMDocument($xml);
-
-        $principal = Principal::unserialize($dom->firstChild, array());
+        $principal = $this->parse($xml);
         $this->assertEquals(Principal::AUTHENTICATED, $principal->getType());
 
     }
@@ -155,9 +114,7 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase {
 '  <d:unauthenticated />' .
 '</d:principal>';
 
-        $dom = DAV\XMLUtil::loadDOMDocument($xml);
-
-        $principal = Principal::unserialize($dom->firstChild, array());
+        $principal = $this->parse($xml);
         $this->assertEquals(Principal::UNAUTHENTICATED, $principal->getType());
 
     }
@@ -172,9 +129,17 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase {
 '  <d:foo />' .
 '</d:principal>';
 
-        $dom = DAV\XMLUtil::loadDOMDocument($xml);
+        $this->parse($xml);
+
+    }
+
+    function parse($xml) {
 
-        Principal::unserialize($dom->firstChild, array());
+        $reader = new Reader();
+        $reader->elementMap['{DAV:}principal'] = 'Sabre\\DAVACL\\Xml\\Property\\Principal';
+        $reader->xml($xml);
+        $result = $reader->parse();
+        return $result['value'];
 
     }
 
diff --git a/tests/Sabre/DAVACL/Property/SupportedPrivilegeSetTest.php b/tests/Sabre/DAVACL/Xml/Property/SupportedPrivilegeSetTest.php
similarity index 50%
rename from tests/Sabre/DAVACL/Property/SupportedPrivilegeSetTest.php
rename to tests/Sabre/DAVACL/Xml/Property/SupportedPrivilegeSetTest.php
index 6e462e6..038d971 100644
--- a/tests/Sabre/DAVACL/Property/SupportedPrivilegeSetTest.php
+++ b/tests/Sabre/DAVACL/Xml/Property/SupportedPrivilegeSetTest.php
@@ -1,20 +1,18 @@
 <?php
 
-namespace Sabre\DAVACL\Property;
+namespace Sabre\DAVACL\Xml\Property;
 
 use Sabre\DAV;
 use Sabre\HTTP;
 
-
-
 class SupportedPrivilegeSetTest extends \PHPUnit_Framework_TestCase {
 
     function testSimple() {
 
-        $prop = new SupportedPrivilegeSet(array(
+        $prop = new SupportedPrivilegeSet([
             'privilege' => '{DAV:}all',
-        ));
-        $this->assertInstanceOf('Sabre\DAVACL\Property\SupportedPrivilegeSet', $prop);
+        ]);
+        $this->assertInstanceOf('Sabre\DAVACL\Xml\Property\SupportedPrivilegeSet', $prop);
 
     }
 
@@ -24,30 +22,20 @@ class SupportedPrivilegeSetTest extends \PHPUnit_Framework_TestCase {
      */
     function testSerializeSimple() {
 
-        $prop = new SupportedPrivilegeSet(array(
+        $prop = new SupportedPrivilegeSet([
             'privilege' => '{DAV:}all',
-        ));
-
-        $doc = new \DOMDocument();
-        $root = $doc->createElementNS('DAV:', 'd:supported-privilege-set');
-
-        $doc->appendChild($root);
+        ]);
 
-        $server = new DAV\Server();
-        $prop->serialize($server, $root);
-
-        $xml = $doc->saveXML();
+        $xml = (new DAV\Server())->xml->write(['{DAV:}supported-privilege-set' => $prop]);
 
         $this->assertEquals(
-'<?xml version="1.0"?>
-<d:supported-privilege-set xmlns:d="DAV:">' .
+'<d:supported-privilege-set xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">' .
 '<d:supported-privilege>' .
 '<d:privilege>' .
 '<d:all/>' .
 '</d:privilege>' .
 '</d:supported-privilege>' .
-'</d:supported-privilege-set>
-', $xml);
+'</d:supported-privilege-set>', $xml);
 
     }
 
@@ -56,33 +44,24 @@ class SupportedPrivilegeSetTest extends \PHPUnit_Framework_TestCase {
      */
     function testSerializeAggregate() {
 
-        $prop = new SupportedPrivilegeSet(array(
+        $prop = new SupportedPrivilegeSet([
             'privilege' => '{DAV:}all',
             'abstract'  => true,
-            'aggregates' => array(
-                array(
+            'aggregates' => [
+                [
                     'privilege' => '{DAV:}read',
-                ),
-                array(
+                ],
+                [
                     'privilege' => '{DAV:}write',
                     'description' => 'booh',
-                ),
-            ),
-        ));
-
-        $doc = new \DOMDocument();
-        $root = $doc->createElementNS('DAV:', 'd:supported-privilege-set');
-
-        $doc->appendChild($root);
-
-        $server = new DAV\Server();
-        $prop->serialize($server, $root);
+                ],
+            ],
+        ]);
 
-        $xml = $doc->saveXML();
+        $xml = (new DAV\Server())->xml->write(['{DAV:}supported-privilege-set' => $prop]);
 
         $this->assertEquals(
-'<?xml version="1.0"?>
-<d:supported-privilege-set xmlns:d="DAV:">' .
+'<d:supported-privilege-set xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">' .
 '<d:supported-privilege>' .
 '<d:privilege>' .
 '<d:all/>' .
@@ -100,8 +79,7 @@ class SupportedPrivilegeSetTest extends \PHPUnit_Framework_TestCase {
 '<d:description>booh</d:description>' .
 '</d:supported-privilege>' .
 '</d:supported-privilege>' .
-'</d:supported-privilege-set>
-', $xml);
+'</d:supported-privilege-set>', $xml);
 
     }
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git



More information about the Pkg-owncloud-commits mailing list