summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/Connector
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-08-06 13:40:52 +0200
committerGeorg Ehrke <developer@georgehrke.com>2019-08-15 15:41:27 +0200
commit01a4644cad99c8502f15a7f62f72f4e040670024 (patch)
treed6e8d5a5d8fe7ed9560df880ee5ef84afddde9a3 /apps/dav/lib/Connector
parent22f29d8e54be32fe44e5d715aa8ae0dbaf558229 (diff)
downloadnextcloud-server-01a4644cad99c8502f15a7f62f72f4e040670024.tar.gz
nextcloud-server-01a4644cad99c8502f15a7f62f72f4e040670024.zip
Use the proxymapper to obtain valid proxy data
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/dav/lib/Connector')
-rw-r--r--apps/dav/lib/Connector/Sabre/Principal.php46
1 files changed, 32 insertions, 14 deletions
diff --git a/apps/dav/lib/Connector/Sabre/Principal.php b/apps/dav/lib/Connector/Sabre/Principal.php
index 902c70bdaff..9a0cd3b5210 100644
--- a/apps/dav/lib/Connector/Sabre/Principal.php
+++ b/apps/dav/lib/Connector/Sabre/Principal.php
@@ -35,9 +35,9 @@
namespace OCA\DAV\Connector\Sabre;
use OCA\Circles\Exceptions\CircleDoesNotExistException;
+use OCA\DAV\CalDAV\Proxy\ProxyMapper;
use OCP\App\IAppManager;
use OCP\AppFramework\QueryException;
-use OCP\IConfig;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUser;
@@ -62,9 +62,6 @@ class Principal implements BackendInterface {
/** @var IUserSession */
private $userSession;
- /** @var IConfig */
- private $config;
-
/** @var IAppManager */
private $appManager;
@@ -76,30 +73,24 @@ class Principal implements BackendInterface {
/** @var bool */
private $hasCircles;
+ /** @var ProxyMapper */
+ private $proxyMapper;
- /**
- * @param IUserManager $userManager
- * @param IGroupManager $groupManager
- * @param IShareManager $shareManager
- * @param IUserSession $userSession
- * @param IConfig $config
- * @param string $principalPrefix
- */
public function __construct(IUserManager $userManager,
IGroupManager $groupManager,
IShareManager $shareManager,
IUserSession $userSession,
- IConfig $config,
IAppManager $appManager,
+ ProxyMapper $proxyMapper,
string $principalPrefix = 'principals/users/') {
$this->userManager = $userManager;
$this->groupManager = $groupManager;
$this->shareManager = $shareManager;
$this->userSession = $userSession;
- $this->config = $config;
$this->appManager = $appManager;
$this->principalPrefix = trim($principalPrefix, '/');
$this->hasGroups = $this->hasCircles = ($principalPrefix === 'principals/users/');
+ $this->proxyMapper = $proxyMapper;
}
/**
@@ -138,6 +129,21 @@ class Principal implements BackendInterface {
public function getPrincipalByPath($path) {
list($prefix, $name) = \Sabre\Uri\split($path);
+ if ($name === 'calendar-proxy-write' || $name === 'calendar-proxy-read') {
+ list($prefix2, $name2) = \Sabre\Uri\split($prefix);
+
+ if ($prefix2 === $this->principalPrefix) {
+ $user = $this->userManager->get($name2);
+
+ if ($user !== null) {
+ return [
+ 'uri' => 'principals/users/' . $user->getUID() . '/' . $name,
+ ];
+ }
+ return null;
+ }
+ }
+
if ($prefix === $this->principalPrefix) {
$user = $this->userManager->get($name);
@@ -195,6 +201,17 @@ class Principal implements BackendInterface {
return 'principals/groups/' . urlencode($group->getGID());
}, $groups);
+ $proxies = $this->proxyMapper->getProxiesFor($user->getUID());
+ foreach ($proxies as $proxy) {
+ if ($proxy->getPermissions() & ProxyMapper::PERMISSION_READ) {
+ $groups[] = 'principals/users/' . $proxy->getOwnerId() . '/calendar-proxy-read';
+ }
+
+ if ($proxy->getPermissions() & ProxyMapper::PERMISSION_WRITE) {
+ $groups[] = 'principals/users/' . $proxy->getOwnerId() . '/calendar-proxy-write';
+ }
+ }
+
return $groups;
}
}
@@ -211,6 +228,7 @@ class Principal implements BackendInterface {
* @throws Exception
*/
public function setGroupMemberSet($principal, array $members) {
+ $a = 'b';
throw new Exception('Setting members of the group is not supported yet');
}