@@ -29,101 +29,101 @@ |
||
29 | 29 | |
30 | 30 | class RequestTime implements ICheck { |
31 | 31 | |
32 | - const REGEX_TIME = '([0-1][0-9]|2[0-3]):([0-5][0-9])'; |
|
33 | - const REGEX_TIMEZONE = '([a-zA-Z]+(?:\\/[a-zA-Z\-\_]+)+)'; |
|
34 | - |
|
35 | - /** @var bool[] */ |
|
36 | - protected $cachedResults; |
|
37 | - |
|
38 | - /** @var IL10N */ |
|
39 | - protected $l; |
|
40 | - |
|
41 | - /** @var ITimeFactory */ |
|
42 | - protected $timeFactory; |
|
43 | - |
|
44 | - /** |
|
45 | - * @param ITimeFactory $timeFactory |
|
46 | - */ |
|
47 | - public function __construct(IL10N $l, ITimeFactory $timeFactory) { |
|
48 | - $this->l = $l; |
|
49 | - $this->timeFactory = $timeFactory; |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * @param IStorage $storage |
|
54 | - * @param string $path |
|
55 | - */ |
|
56 | - public function setFileInfo(IStorage $storage, $path) { |
|
57 | - // A different path doesn't change time, so nothing to do here. |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * @param string $operator |
|
62 | - * @param string $value |
|
63 | - * @return bool |
|
64 | - */ |
|
65 | - public function executeCheck($operator, $value) { |
|
66 | - $valueHash = md5($value); |
|
67 | - |
|
68 | - if (isset($this->cachedResults[$valueHash])) { |
|
69 | - return $this->cachedResults[$valueHash]; |
|
70 | - } |
|
71 | - |
|
72 | - $timestamp = $this->timeFactory->getTime(); |
|
73 | - |
|
74 | - $values = json_decode($value, true); |
|
75 | - $timestamp1 = $this->getTimestamp($timestamp, $values[0]); |
|
76 | - $timestamp2 = $this->getTimestamp($timestamp, $values[1]); |
|
77 | - |
|
78 | - if ($timestamp1 < $timestamp2) { |
|
79 | - $in = $timestamp1 <= $timestamp && $timestamp <= $timestamp2; |
|
80 | - } else { |
|
81 | - $in = $timestamp1 <= $timestamp || $timestamp <= $timestamp2; |
|
82 | - } |
|
83 | - |
|
84 | - return ($operator === 'in') ? $in : !$in; |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * @param int $currentTimestamp |
|
89 | - * @param string $value Format: "H:i e" |
|
90 | - * @return int |
|
91 | - */ |
|
92 | - protected function getTimestamp($currentTimestamp, $value) { |
|
93 | - list($time1, $timezone1) = explode(' ', $value); |
|
94 | - list($hour1, $minute1) = explode(':', $time1); |
|
95 | - $date1 = new \DateTime('now', new \DateTimeZone($timezone1)); |
|
96 | - $date1->setTimestamp($currentTimestamp); |
|
97 | - $date1->setTime($hour1, $minute1); |
|
98 | - |
|
99 | - return $date1->getTimestamp(); |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * @param string $operator |
|
104 | - * @param string $value |
|
105 | - * @throws \UnexpectedValueException |
|
106 | - */ |
|
107 | - public function validateCheck($operator, $value) { |
|
108 | - if (!in_array($operator, ['in', '!in'])) { |
|
109 | - throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); |
|
110 | - } |
|
111 | - |
|
112 | - $regexValue = '\"' . self::REGEX_TIME . ' ' . self::REGEX_TIMEZONE . '\"'; |
|
113 | - $result = preg_match('/^\[' . $regexValue . ',' . $regexValue . '\]$/', $value, $matches); |
|
114 | - if (!$result) { |
|
115 | - throw new \UnexpectedValueException($this->l->t('The given time span is invalid'), 2); |
|
116 | - } |
|
117 | - |
|
118 | - $values = json_decode($value, true); |
|
119 | - $time1 = \DateTime::createFromFormat('H:i e', $values[0]); |
|
120 | - if ($time1 === false) { |
|
121 | - throw new \UnexpectedValueException($this->l->t('The given start time is invalid'), 3); |
|
122 | - } |
|
123 | - |
|
124 | - $time2 = \DateTime::createFromFormat('H:i e', $values[1]); |
|
125 | - if ($time2 === false) { |
|
126 | - throw new \UnexpectedValueException($this->l->t('The given end time is invalid'), 4); |
|
127 | - } |
|
128 | - } |
|
32 | + const REGEX_TIME = '([0-1][0-9]|2[0-3]):([0-5][0-9])'; |
|
33 | + const REGEX_TIMEZONE = '([a-zA-Z]+(?:\\/[a-zA-Z\-\_]+)+)'; |
|
34 | + |
|
35 | + /** @var bool[] */ |
|
36 | + protected $cachedResults; |
|
37 | + |
|
38 | + /** @var IL10N */ |
|
39 | + protected $l; |
|
40 | + |
|
41 | + /** @var ITimeFactory */ |
|
42 | + protected $timeFactory; |
|
43 | + |
|
44 | + /** |
|
45 | + * @param ITimeFactory $timeFactory |
|
46 | + */ |
|
47 | + public function __construct(IL10N $l, ITimeFactory $timeFactory) { |
|
48 | + $this->l = $l; |
|
49 | + $this->timeFactory = $timeFactory; |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * @param IStorage $storage |
|
54 | + * @param string $path |
|
55 | + */ |
|
56 | + public function setFileInfo(IStorage $storage, $path) { |
|
57 | + // A different path doesn't change time, so nothing to do here. |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * @param string $operator |
|
62 | + * @param string $value |
|
63 | + * @return bool |
|
64 | + */ |
|
65 | + public function executeCheck($operator, $value) { |
|
66 | + $valueHash = md5($value); |
|
67 | + |
|
68 | + if (isset($this->cachedResults[$valueHash])) { |
|
69 | + return $this->cachedResults[$valueHash]; |
|
70 | + } |
|
71 | + |
|
72 | + $timestamp = $this->timeFactory->getTime(); |
|
73 | + |
|
74 | + $values = json_decode($value, true); |
|
75 | + $timestamp1 = $this->getTimestamp($timestamp, $values[0]); |
|
76 | + $timestamp2 = $this->getTimestamp($timestamp, $values[1]); |
|
77 | + |
|
78 | + if ($timestamp1 < $timestamp2) { |
|
79 | + $in = $timestamp1 <= $timestamp && $timestamp <= $timestamp2; |
|
80 | + } else { |
|
81 | + $in = $timestamp1 <= $timestamp || $timestamp <= $timestamp2; |
|
82 | + } |
|
83 | + |
|
84 | + return ($operator === 'in') ? $in : !$in; |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * @param int $currentTimestamp |
|
89 | + * @param string $value Format: "H:i e" |
|
90 | + * @return int |
|
91 | + */ |
|
92 | + protected function getTimestamp($currentTimestamp, $value) { |
|
93 | + list($time1, $timezone1) = explode(' ', $value); |
|
94 | + list($hour1, $minute1) = explode(':', $time1); |
|
95 | + $date1 = new \DateTime('now', new \DateTimeZone($timezone1)); |
|
96 | + $date1->setTimestamp($currentTimestamp); |
|
97 | + $date1->setTime($hour1, $minute1); |
|
98 | + |
|
99 | + return $date1->getTimestamp(); |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * @param string $operator |
|
104 | + * @param string $value |
|
105 | + * @throws \UnexpectedValueException |
|
106 | + */ |
|
107 | + public function validateCheck($operator, $value) { |
|
108 | + if (!in_array($operator, ['in', '!in'])) { |
|
109 | + throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); |
|
110 | + } |
|
111 | + |
|
112 | + $regexValue = '\"' . self::REGEX_TIME . ' ' . self::REGEX_TIMEZONE . '\"'; |
|
113 | + $result = preg_match('/^\[' . $regexValue . ',' . $regexValue . '\]$/', $value, $matches); |
|
114 | + if (!$result) { |
|
115 | + throw new \UnexpectedValueException($this->l->t('The given time span is invalid'), 2); |
|
116 | + } |
|
117 | + |
|
118 | + $values = json_decode($value, true); |
|
119 | + $time1 = \DateTime::createFromFormat('H:i e', $values[0]); |
|
120 | + if ($time1 === false) { |
|
121 | + throw new \UnexpectedValueException($this->l->t('The given start time is invalid'), 3); |
|
122 | + } |
|
123 | + |
|
124 | + $time2 = \DateTime::createFromFormat('H:i e', $values[1]); |
|
125 | + if ($time2 === false) { |
|
126 | + throw new \UnexpectedValueException($this->l->t('The given end time is invalid'), 4); |
|
127 | + } |
|
128 | + } |
|
129 | 129 | } |
@@ -31,84 +31,84 @@ |
||
31 | 31 | |
32 | 32 | class UserGroupMembership implements ICheck { |
33 | 33 | |
34 | - /** @var string */ |
|
35 | - protected $cachedUser; |
|
36 | - |
|
37 | - /** @var string[] */ |
|
38 | - protected $cachedGroupMemberships; |
|
39 | - |
|
40 | - /** @var IUserSession */ |
|
41 | - protected $userSession; |
|
42 | - |
|
43 | - /** @var IGroupManager */ |
|
44 | - protected $groupManager; |
|
45 | - |
|
46 | - /** @var IL10N */ |
|
47 | - protected $l; |
|
48 | - |
|
49 | - /** |
|
50 | - * @param IUserSession $userSession |
|
51 | - * @param IGroupManager $groupManager |
|
52 | - * @param IL10N $l |
|
53 | - */ |
|
54 | - public function __construct(IUserSession $userSession, IGroupManager $groupManager, IL10N $l) { |
|
55 | - $this->userSession = $userSession; |
|
56 | - $this->groupManager = $groupManager; |
|
57 | - $this->l = $l; |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * @param IStorage $storage |
|
62 | - * @param string $path |
|
63 | - */ |
|
64 | - public function setFileInfo(IStorage $storage, $path) { |
|
65 | - // A different path doesn't change group memberships, so nothing to do here. |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * @param string $operator |
|
70 | - * @param string $value |
|
71 | - * @return bool |
|
72 | - */ |
|
73 | - public function executeCheck($operator, $value) { |
|
74 | - $user = $this->userSession->getUser(); |
|
75 | - |
|
76 | - if ($user instanceof IUser) { |
|
77 | - $groupIds = $this->getUserGroups($user); |
|
78 | - return ($operator === 'is') === in_array($value, $groupIds); |
|
79 | - } else { |
|
80 | - return $operator !== 'is'; |
|
81 | - } |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * @param string $operator |
|
87 | - * @param string $value |
|
88 | - * @throws \UnexpectedValueException |
|
89 | - */ |
|
90 | - public function validateCheck($operator, $value) { |
|
91 | - if (!in_array($operator, ['is', '!is'])) { |
|
92 | - throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); |
|
93 | - } |
|
94 | - |
|
95 | - if (!$this->groupManager->groupExists($value)) { |
|
96 | - throw new \UnexpectedValueException($this->l->t('The given group does not exist'), 2); |
|
97 | - } |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * @param IUser $user |
|
102 | - * @return string[] |
|
103 | - */ |
|
104 | - protected function getUserGroups(IUser $user) { |
|
105 | - $uid = $user->getUID(); |
|
106 | - |
|
107 | - if ($this->cachedUser !== $uid) { |
|
108 | - $this->cachedUser = $uid; |
|
109 | - $this->cachedGroupMemberships = $this->groupManager->getUserGroupIds($user); |
|
110 | - } |
|
111 | - |
|
112 | - return $this->cachedGroupMemberships; |
|
113 | - } |
|
34 | + /** @var string */ |
|
35 | + protected $cachedUser; |
|
36 | + |
|
37 | + /** @var string[] */ |
|
38 | + protected $cachedGroupMemberships; |
|
39 | + |
|
40 | + /** @var IUserSession */ |
|
41 | + protected $userSession; |
|
42 | + |
|
43 | + /** @var IGroupManager */ |
|
44 | + protected $groupManager; |
|
45 | + |
|
46 | + /** @var IL10N */ |
|
47 | + protected $l; |
|
48 | + |
|
49 | + /** |
|
50 | + * @param IUserSession $userSession |
|
51 | + * @param IGroupManager $groupManager |
|
52 | + * @param IL10N $l |
|
53 | + */ |
|
54 | + public function __construct(IUserSession $userSession, IGroupManager $groupManager, IL10N $l) { |
|
55 | + $this->userSession = $userSession; |
|
56 | + $this->groupManager = $groupManager; |
|
57 | + $this->l = $l; |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * @param IStorage $storage |
|
62 | + * @param string $path |
|
63 | + */ |
|
64 | + public function setFileInfo(IStorage $storage, $path) { |
|
65 | + // A different path doesn't change group memberships, so nothing to do here. |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * @param string $operator |
|
70 | + * @param string $value |
|
71 | + * @return bool |
|
72 | + */ |
|
73 | + public function executeCheck($operator, $value) { |
|
74 | + $user = $this->userSession->getUser(); |
|
75 | + |
|
76 | + if ($user instanceof IUser) { |
|
77 | + $groupIds = $this->getUserGroups($user); |
|
78 | + return ($operator === 'is') === in_array($value, $groupIds); |
|
79 | + } else { |
|
80 | + return $operator !== 'is'; |
|
81 | + } |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * @param string $operator |
|
87 | + * @param string $value |
|
88 | + * @throws \UnexpectedValueException |
|
89 | + */ |
|
90 | + public function validateCheck($operator, $value) { |
|
91 | + if (!in_array($operator, ['is', '!is'])) { |
|
92 | + throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); |
|
93 | + } |
|
94 | + |
|
95 | + if (!$this->groupManager->groupExists($value)) { |
|
96 | + throw new \UnexpectedValueException($this->l->t('The given group does not exist'), 2); |
|
97 | + } |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * @param IUser $user |
|
102 | + * @return string[] |
|
103 | + */ |
|
104 | + protected function getUserGroups(IUser $user) { |
|
105 | + $uid = $user->getUID(); |
|
106 | + |
|
107 | + if ($this->cachedUser !== $uid) { |
|
108 | + $this->cachedUser = $uid; |
|
109 | + $this->cachedGroupMemberships = $this->groupManager->getUserGroupIds($user); |
|
110 | + } |
|
111 | + |
|
112 | + return $this->cachedGroupMemberships; |
|
113 | + } |
|
114 | 114 | } |
@@ -27,66 +27,66 @@ |
||
27 | 27 | |
28 | 28 | class RequestURL extends AbstractStringCheck { |
29 | 29 | |
30 | - /** @var string */ |
|
31 | - protected $url; |
|
30 | + /** @var string */ |
|
31 | + protected $url; |
|
32 | 32 | |
33 | - /** @var IRequest */ |
|
34 | - protected $request; |
|
33 | + /** @var IRequest */ |
|
34 | + protected $request; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param IL10N $l |
|
38 | - * @param IRequest $request |
|
39 | - */ |
|
40 | - public function __construct(IL10N $l, IRequest $request) { |
|
41 | - parent::__construct($l); |
|
42 | - $this->request = $request; |
|
43 | - } |
|
36 | + /** |
|
37 | + * @param IL10N $l |
|
38 | + * @param IRequest $request |
|
39 | + */ |
|
40 | + public function __construct(IL10N $l, IRequest $request) { |
|
41 | + parent::__construct($l); |
|
42 | + $this->request = $request; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param string $operator |
|
47 | - * @param string $value |
|
48 | - * @return bool |
|
49 | - */ |
|
50 | - public function executeCheck($operator, $value) { |
|
51 | - $actualValue = $this->getActualValue(); |
|
52 | - if (in_array($operator, ['is', '!is'])) { |
|
53 | - switch ($value) { |
|
54 | - case 'webdav': |
|
55 | - if ($operator === 'is') { |
|
56 | - return $this->isWebDAVRequest(); |
|
57 | - } else { |
|
58 | - return !$this->isWebDAVRequest(); |
|
59 | - } |
|
60 | - } |
|
61 | - } |
|
62 | - return $this->executeStringCheck($operator, $value, $actualValue); |
|
63 | - } |
|
45 | + /** |
|
46 | + * @param string $operator |
|
47 | + * @param string $value |
|
48 | + * @return bool |
|
49 | + */ |
|
50 | + public function executeCheck($operator, $value) { |
|
51 | + $actualValue = $this->getActualValue(); |
|
52 | + if (in_array($operator, ['is', '!is'])) { |
|
53 | + switch ($value) { |
|
54 | + case 'webdav': |
|
55 | + if ($operator === 'is') { |
|
56 | + return $this->isWebDAVRequest(); |
|
57 | + } else { |
|
58 | + return !$this->isWebDAVRequest(); |
|
59 | + } |
|
60 | + } |
|
61 | + } |
|
62 | + return $this->executeStringCheck($operator, $value, $actualValue); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - protected function getActualValue() { |
|
69 | - if ($this->url !== null) { |
|
70 | - return $this->url; |
|
71 | - } |
|
65 | + /** |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + protected function getActualValue() { |
|
69 | + if ($this->url !== null) { |
|
70 | + return $this->url; |
|
71 | + } |
|
72 | 72 | |
73 | - $this->url = $this->request->getServerProtocol() . '://';// E.g. http(s) + :// |
|
74 | - $this->url .= $this->request->getServerHost();// E.g. localhost |
|
75 | - $this->url .= $this->request->getScriptName();// E.g. /nextcloud/index.php |
|
76 | - $this->url .= $this->request->getPathInfo();// E.g. /apps/files_texteditor/ajax/loadfile |
|
73 | + $this->url = $this->request->getServerProtocol() . '://';// E.g. http(s) + :// |
|
74 | + $this->url .= $this->request->getServerHost();// E.g. localhost |
|
75 | + $this->url .= $this->request->getScriptName();// E.g. /nextcloud/index.php |
|
76 | + $this->url .= $this->request->getPathInfo();// E.g. /apps/files_texteditor/ajax/loadfile |
|
77 | 77 | |
78 | - return $this->url; // E.g. https://localhost/nextcloud/index.php/apps/files_texteditor/ajax/loadfile |
|
79 | - } |
|
78 | + return $this->url; // E.g. https://localhost/nextcloud/index.php/apps/files_texteditor/ajax/loadfile |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @return bool |
|
83 | - */ |
|
84 | - protected function isWebDAVRequest() { |
|
85 | - return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && ( |
|
86 | - $this->request->getPathInfo() === '/webdav' || |
|
87 | - strpos($this->request->getPathInfo(), '/webdav/') === 0 || |
|
88 | - $this->request->getPathInfo() === '/dav/files' || |
|
89 | - strpos($this->request->getPathInfo(), '/dav/files/') === 0 |
|
90 | - ); |
|
91 | - } |
|
81 | + /** |
|
82 | + * @return bool |
|
83 | + */ |
|
84 | + protected function isWebDAVRequest() { |
|
85 | + return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && ( |
|
86 | + $this->request->getPathInfo() === '/webdav' || |
|
87 | + strpos($this->request->getPathInfo(), '/webdav/') === 0 || |
|
88 | + $this->request->getPathInfo() === '/dav/files' || |
|
89 | + strpos($this->request->getPathInfo(), '/dav/files/') === 0 |
|
90 | + ); |
|
91 | + } |
|
92 | 92 | } |
@@ -20,11 +20,11 @@ |
||
20 | 20 | */ |
21 | 21 | |
22 | 22 | return [ |
23 | - 'routes' => [ |
|
24 | - ['name' => 'flowOperations#getOperations', 'url' => '/operations', 'verb' => 'GET'], |
|
25 | - ['name' => 'flowOperations#addOperation', 'url' => '/operations', 'verb' => 'POST'], |
|
26 | - ['name' => 'flowOperations#updateOperation', 'url' => '/operations/{id}', 'verb' => 'PUT'], |
|
27 | - ['name' => 'flowOperations#deleteOperation', 'url' => '/operations/{id}', 'verb' => 'DELETE'], |
|
28 | - ['name' => 'requestTime#getTimezones', 'url' => '/timezones', 'verb' => 'GET'], |
|
29 | - ] |
|
23 | + 'routes' => [ |
|
24 | + ['name' => 'flowOperations#getOperations', 'url' => '/operations', 'verb' => 'GET'], |
|
25 | + ['name' => 'flowOperations#addOperation', 'url' => '/operations', 'verb' => 'POST'], |
|
26 | + ['name' => 'flowOperations#updateOperation', 'url' => '/operations/{id}', 'verb' => 'PUT'], |
|
27 | + ['name' => 'flowOperations#deleteOperation', 'url' => '/operations/{id}', 'verb' => 'DELETE'], |
|
28 | + ['name' => 'requestTime#getTimezones', 'url' => '/timezones', 'verb' => 'GET'], |
|
29 | + ] |
|
30 | 30 | ]; |
@@ -34,23 +34,23 @@ |
||
34 | 34 | * ] |
35 | 35 | */ |
36 | 36 | class AlternativeHomeUserBackend extends \OC\User\Database { |
37 | - public function __construct() { |
|
38 | - parent::__construct(); |
|
39 | - } |
|
40 | - /** |
|
41 | - * get the user's home directory |
|
42 | - * @param string $uid the username |
|
43 | - * @return string|false |
|
44 | - */ |
|
45 | - public function getHome($uid) { |
|
46 | - if ($this->userExists($uid)) { |
|
47 | - // workaround to avoid killing the admin |
|
48 | - if ($uid !== 'admin') { |
|
49 | - $uid = md5($uid); |
|
50 | - } |
|
51 | - return \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $uid; |
|
52 | - } |
|
37 | + public function __construct() { |
|
38 | + parent::__construct(); |
|
39 | + } |
|
40 | + /** |
|
41 | + * get the user's home directory |
|
42 | + * @param string $uid the username |
|
43 | + * @return string|false |
|
44 | + */ |
|
45 | + public function getHome($uid) { |
|
46 | + if ($this->userExists($uid)) { |
|
47 | + // workaround to avoid killing the admin |
|
48 | + if ($uid !== 'admin') { |
|
49 | + $uid = md5($uid); |
|
50 | + } |
|
51 | + return \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $uid; |
|
52 | + } |
|
53 | 53 | |
54 | - return false; |
|
55 | - } |
|
54 | + return false; |
|
55 | + } |
|
56 | 56 | } |
@@ -33,30 +33,30 @@ |
||
33 | 33 | */ |
34 | 34 | class TokenHandler { |
35 | 35 | |
36 | - const TOKEN_LENGTH = 15; |
|
37 | - |
|
38 | - /** @var ISecureRandom */ |
|
39 | - private $secureRandom; |
|
40 | - |
|
41 | - /** |
|
42 | - * TokenHandler constructor. |
|
43 | - * |
|
44 | - * @param ISecureRandom $secureRandom |
|
45 | - */ |
|
46 | - public function __construct(ISecureRandom $secureRandom) { |
|
47 | - $this->secureRandom = $secureRandom; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * generate to token used to authenticate federated shares |
|
52 | - * |
|
53 | - * @return string |
|
54 | - */ |
|
55 | - public function generateToken() { |
|
56 | - $token = $this->secureRandom->generate( |
|
57 | - self::TOKEN_LENGTH, |
|
58 | - ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS); |
|
59 | - return $token; |
|
60 | - } |
|
36 | + const TOKEN_LENGTH = 15; |
|
37 | + |
|
38 | + /** @var ISecureRandom */ |
|
39 | + private $secureRandom; |
|
40 | + |
|
41 | + /** |
|
42 | + * TokenHandler constructor. |
|
43 | + * |
|
44 | + * @param ISecureRandom $secureRandom |
|
45 | + */ |
|
46 | + public function __construct(ISecureRandom $secureRandom) { |
|
47 | + $this->secureRandom = $secureRandom; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * generate to token used to authenticate federated shares |
|
52 | + * |
|
53 | + * @return string |
|
54 | + */ |
|
55 | + public function generateToken() { |
|
56 | + $token = $this->secureRandom->generate( |
|
57 | + self::TOKEN_LENGTH, |
|
58 | + ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS); |
|
59 | + return $token; |
|
60 | + } |
|
61 | 61 | |
62 | 62 | } |
@@ -28,10 +28,10 @@ |
||
28 | 28 | <?php if((int)$trustedServer['status'] === TrustedServers::STATUS_OK) { ?> |
29 | 29 | <span class="status success"></span> |
30 | 30 | <?php |
31 | - } elseif( |
|
32 | - (int)$trustedServer['status'] === TrustedServers::STATUS_PENDING || |
|
33 | - (int)$trustedServer['status'] === TrustedServers::STATUS_ACCESS_REVOKED |
|
34 | - ) { ?> |
|
31 | + } elseif( |
|
32 | + (int)$trustedServer['status'] === TrustedServers::STATUS_PENDING || |
|
33 | + (int)$trustedServer['status'] === TrustedServers::STATUS_ACCESS_REVOKED |
|
34 | + ) { ?> |
|
35 | 35 | <span class="status indeterminate"></span> |
36 | 36 | <?php } else {?> |
37 | 37 | <span class="status error"></span> |
@@ -29,41 +29,41 @@ |
||
29 | 29 | |
30 | 30 | class Admin implements ISettings { |
31 | 31 | |
32 | - /** @var TrustedServers */ |
|
33 | - private $trustedServers; |
|
32 | + /** @var TrustedServers */ |
|
33 | + private $trustedServers; |
|
34 | 34 | |
35 | - public function __construct(TrustedServers $trustedServers) { |
|
36 | - $this->trustedServers = $trustedServers; |
|
37 | - } |
|
35 | + public function __construct(TrustedServers $trustedServers) { |
|
36 | + $this->trustedServers = $trustedServers; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @return TemplateResponse |
|
41 | - */ |
|
42 | - public function getForm() { |
|
43 | - $parameters = [ |
|
44 | - 'trustedServers' => $this->trustedServers->getServers(), |
|
45 | - 'autoAddServers' => $this->trustedServers->getAutoAddServers(), |
|
46 | - ]; |
|
39 | + /** |
|
40 | + * @return TemplateResponse |
|
41 | + */ |
|
42 | + public function getForm() { |
|
43 | + $parameters = [ |
|
44 | + 'trustedServers' => $this->trustedServers->getServers(), |
|
45 | + 'autoAddServers' => $this->trustedServers->getAutoAddServers(), |
|
46 | + ]; |
|
47 | 47 | |
48 | - return new TemplateResponse('federation', 'settings-admin', $parameters, ''); |
|
49 | - } |
|
48 | + return new TemplateResponse('federation', 'settings-admin', $parameters, ''); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @return string the section ID, e.g. 'sharing' |
|
53 | - */ |
|
54 | - public function getSection() { |
|
55 | - return 'sharing'; |
|
56 | - } |
|
51 | + /** |
|
52 | + * @return string the section ID, e.g. 'sharing' |
|
53 | + */ |
|
54 | + public function getSection() { |
|
55 | + return 'sharing'; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return int whether the form should be rather on the top or bottom of |
|
60 | - * the admin section. The forms are arranged in ascending order of the |
|
61 | - * priority values. It is required to return a value between 0 and 100. |
|
62 | - * |
|
63 | - * E.g.: 70 |
|
64 | - */ |
|
65 | - public function getPriority() { |
|
66 | - return 30; |
|
67 | - } |
|
58 | + /** |
|
59 | + * @return int whether the form should be rather on the top or bottom of |
|
60 | + * the admin section. The forms are arranged in ascending order of the |
|
61 | + * priority values. It is required to return a value between 0 and 100. |
|
62 | + * |
|
63 | + * E.g.: 70 |
|
64 | + */ |
|
65 | + public function getPriority() { |
|
66 | + return 30; |
|
67 | + } |
|
68 | 68 | |
69 | 69 | } |
@@ -27,25 +27,25 @@ |
||
27 | 27 | |
28 | 28 | class Hooks { |
29 | 29 | |
30 | - /** @var TrustedServers */ |
|
31 | - private $trustedServers; |
|
32 | - |
|
33 | - public function __construct(TrustedServers $trustedServers) { |
|
34 | - $this->trustedServers = $trustedServers; |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * add servers to the list of trusted servers once a federated share was established |
|
39 | - * |
|
40 | - * @param array $params |
|
41 | - */ |
|
42 | - public function addServerHook($params) { |
|
43 | - if ( |
|
44 | - $this->trustedServers->getAutoAddServers() === true && |
|
45 | - $this->trustedServers->isTrustedServer($params['server']) === false |
|
46 | - ) { |
|
47 | - $this->trustedServers->addServer($params['server']); |
|
48 | - } |
|
49 | - } |
|
30 | + /** @var TrustedServers */ |
|
31 | + private $trustedServers; |
|
32 | + |
|
33 | + public function __construct(TrustedServers $trustedServers) { |
|
34 | + $this->trustedServers = $trustedServers; |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * add servers to the list of trusted servers once a federated share was established |
|
39 | + * |
|
40 | + * @param array $params |
|
41 | + */ |
|
42 | + public function addServerHook($params) { |
|
43 | + if ( |
|
44 | + $this->trustedServers->getAutoAddServers() === true && |
|
45 | + $this->trustedServers->isTrustedServer($params['server']) === false |
|
46 | + ) { |
|
47 | + $this->trustedServers->addServer($params['server']); |
|
48 | + } |
|
49 | + } |
|
50 | 50 | |
51 | 51 | } |