@@ -45,114 +45,114 @@ |
||
| 45 | 45 | * @package OCA\DAV\Connector\Sabre |
| 46 | 46 | */ |
| 47 | 47 | class FakeLockerPlugin extends ServerPlugin { |
| 48 | - /** @var \Sabre\DAV\Server */ |
|
| 49 | - private $server; |
|
| 48 | + /** @var \Sabre\DAV\Server */ |
|
| 49 | + private $server; |
|
| 50 | 50 | |
| 51 | - /** {@inheritDoc} */ |
|
| 52 | - public function initialize(\Sabre\DAV\Server $server) { |
|
| 53 | - $this->server = $server; |
|
| 54 | - $this->server->on('method:LOCK', [$this, 'fakeLockProvider'], 1); |
|
| 55 | - $this->server->on('method:UNLOCK', [$this, 'fakeUnlockProvider'], 1); |
|
| 56 | - $server->on('propFind', [$this, 'propFind']); |
|
| 57 | - $server->on('validateTokens', [$this, 'validateTokens']); |
|
| 58 | - } |
|
| 51 | + /** {@inheritDoc} */ |
|
| 52 | + public function initialize(\Sabre\DAV\Server $server) { |
|
| 53 | + $this->server = $server; |
|
| 54 | + $this->server->on('method:LOCK', [$this, 'fakeLockProvider'], 1); |
|
| 55 | + $this->server->on('method:UNLOCK', [$this, 'fakeUnlockProvider'], 1); |
|
| 56 | + $server->on('propFind', [$this, 'propFind']); |
|
| 57 | + $server->on('validateTokens', [$this, 'validateTokens']); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Indicate that we support LOCK and UNLOCK |
|
| 62 | - * |
|
| 63 | - * @param string $path |
|
| 64 | - * @return string[] |
|
| 65 | - */ |
|
| 66 | - public function getHTTPMethods($path) { |
|
| 67 | - return [ |
|
| 68 | - 'LOCK', |
|
| 69 | - 'UNLOCK', |
|
| 70 | - ]; |
|
| 71 | - } |
|
| 60 | + /** |
|
| 61 | + * Indicate that we support LOCK and UNLOCK |
|
| 62 | + * |
|
| 63 | + * @param string $path |
|
| 64 | + * @return string[] |
|
| 65 | + */ |
|
| 66 | + public function getHTTPMethods($path) { |
|
| 67 | + return [ |
|
| 68 | + 'LOCK', |
|
| 69 | + 'UNLOCK', |
|
| 70 | + ]; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Indicate that we support locking |
|
| 75 | - * |
|
| 76 | - * @return integer[] |
|
| 77 | - */ |
|
| 78 | - function getFeatures() { |
|
| 79 | - return [2]; |
|
| 80 | - } |
|
| 73 | + /** |
|
| 74 | + * Indicate that we support locking |
|
| 75 | + * |
|
| 76 | + * @return integer[] |
|
| 77 | + */ |
|
| 78 | + function getFeatures() { |
|
| 79 | + return [2]; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Return some dummy response for PROPFIND requests with regard to locking |
|
| 84 | - * |
|
| 85 | - * @param PropFind $propFind |
|
| 86 | - * @param INode $node |
|
| 87 | - * @return void |
|
| 88 | - */ |
|
| 89 | - function propFind(PropFind $propFind, INode $node) { |
|
| 90 | - $propFind->handle('{DAV:}supportedlock', function() { |
|
| 91 | - return new SupportedLock(true); |
|
| 92 | - }); |
|
| 93 | - $propFind->handle('{DAV:}lockdiscovery', function() use ($propFind) { |
|
| 94 | - return new LockDiscovery([]); |
|
| 95 | - }); |
|
| 96 | - } |
|
| 82 | + /** |
|
| 83 | + * Return some dummy response for PROPFIND requests with regard to locking |
|
| 84 | + * |
|
| 85 | + * @param PropFind $propFind |
|
| 86 | + * @param INode $node |
|
| 87 | + * @return void |
|
| 88 | + */ |
|
| 89 | + function propFind(PropFind $propFind, INode $node) { |
|
| 90 | + $propFind->handle('{DAV:}supportedlock', function() { |
|
| 91 | + return new SupportedLock(true); |
|
| 92 | + }); |
|
| 93 | + $propFind->handle('{DAV:}lockdiscovery', function() use ($propFind) { |
|
| 94 | + return new LockDiscovery([]); |
|
| 95 | + }); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * Mark a locking token always as valid |
|
| 100 | - * |
|
| 101 | - * @param RequestInterface $request |
|
| 102 | - * @param array $conditions |
|
| 103 | - */ |
|
| 104 | - public function validateTokens(RequestInterface $request, &$conditions) { |
|
| 105 | - foreach($conditions as &$fileCondition) { |
|
| 106 | - if(isset($fileCondition['tokens'])) { |
|
| 107 | - foreach($fileCondition['tokens'] as &$token) { |
|
| 108 | - if(isset($token['token'])) { |
|
| 109 | - if(substr($token['token'], 0, 16) === 'opaquelocktoken:') { |
|
| 110 | - $token['validToken'] = true; |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - } |
|
| 98 | + /** |
|
| 99 | + * Mark a locking token always as valid |
|
| 100 | + * |
|
| 101 | + * @param RequestInterface $request |
|
| 102 | + * @param array $conditions |
|
| 103 | + */ |
|
| 104 | + public function validateTokens(RequestInterface $request, &$conditions) { |
|
| 105 | + foreach($conditions as &$fileCondition) { |
|
| 106 | + if(isset($fileCondition['tokens'])) { |
|
| 107 | + foreach($fileCondition['tokens'] as &$token) { |
|
| 108 | + if(isset($token['token'])) { |
|
| 109 | + if(substr($token['token'], 0, 16) === 'opaquelocktoken:') { |
|
| 110 | + $token['validToken'] = true; |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Fakes a successful LOCK |
|
| 120 | - * |
|
| 121 | - * @param RequestInterface $request |
|
| 122 | - * @param ResponseInterface $response |
|
| 123 | - * @return bool |
|
| 124 | - */ |
|
| 125 | - public function fakeLockProvider(RequestInterface $request, |
|
| 126 | - ResponseInterface $response) { |
|
| 118 | + /** |
|
| 119 | + * Fakes a successful LOCK |
|
| 120 | + * |
|
| 121 | + * @param RequestInterface $request |
|
| 122 | + * @param ResponseInterface $response |
|
| 123 | + * @return bool |
|
| 124 | + */ |
|
| 125 | + public function fakeLockProvider(RequestInterface $request, |
|
| 126 | + ResponseInterface $response) { |
|
| 127 | 127 | |
| 128 | - $lockInfo = new LockInfo(); |
|
| 129 | - $lockInfo->token = md5($request->getPath()); |
|
| 130 | - $lockInfo->uri = $request->getPath(); |
|
| 131 | - $lockInfo->depth = \Sabre\DAV\Server::DEPTH_INFINITY; |
|
| 132 | - $lockInfo->timeout = 1800; |
|
| 128 | + $lockInfo = new LockInfo(); |
|
| 129 | + $lockInfo->token = md5($request->getPath()); |
|
| 130 | + $lockInfo->uri = $request->getPath(); |
|
| 131 | + $lockInfo->depth = \Sabre\DAV\Server::DEPTH_INFINITY; |
|
| 132 | + $lockInfo->timeout = 1800; |
|
| 133 | 133 | |
| 134 | - $body = $this->server->xml->write('{DAV:}prop', [ |
|
| 135 | - '{DAV:}lockdiscovery' => |
|
| 136 | - new LockDiscovery([$lockInfo]) |
|
| 137 | - ]); |
|
| 134 | + $body = $this->server->xml->write('{DAV:}prop', [ |
|
| 135 | + '{DAV:}lockdiscovery' => |
|
| 136 | + new LockDiscovery([$lockInfo]) |
|
| 137 | + ]); |
|
| 138 | 138 | |
| 139 | - $response->setStatus(200); |
|
| 140 | - $response->setBody($body); |
|
| 139 | + $response->setStatus(200); |
|
| 140 | + $response->setBody($body); |
|
| 141 | 141 | |
| 142 | - return false; |
|
| 143 | - } |
|
| 142 | + return false; |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - /** |
|
| 146 | - * Fakes a successful LOCK |
|
| 147 | - * |
|
| 148 | - * @param RequestInterface $request |
|
| 149 | - * @param ResponseInterface $response |
|
| 150 | - * @return bool |
|
| 151 | - */ |
|
| 152 | - public function fakeUnlockProvider(RequestInterface $request, |
|
| 153 | - ResponseInterface $response) { |
|
| 154 | - $response->setStatus(204); |
|
| 155 | - $response->setHeader('Content-Length', '0'); |
|
| 156 | - return false; |
|
| 157 | - } |
|
| 145 | + /** |
|
| 146 | + * Fakes a successful LOCK |
|
| 147 | + * |
|
| 148 | + * @param RequestInterface $request |
|
| 149 | + * @param ResponseInterface $response |
|
| 150 | + * @return bool |
|
| 151 | + */ |
|
| 152 | + public function fakeUnlockProvider(RequestInterface $request, |
|
| 153 | + ResponseInterface $response) { |
|
| 154 | + $response->setStatus(204); |
|
| 155 | + $response->setHeader('Content-Length', '0'); |
|
| 156 | + return false; |
|
| 157 | + } |
|
| 158 | 158 | } |