@@ -29,12 +29,12 @@ |
||
29 | 29 | * @since 12.0.0 |
30 | 30 | */ |
31 | 31 | interface IRenameChange extends IChange { |
32 | - /** |
|
33 | - * Get the new path of the renamed file relative to the storage root |
|
34 | - * |
|
35 | - * @return string |
|
36 | - * |
|
37 | - * @since 12.0.0 |
|
38 | - */ |
|
39 | - public function getTargetPath(); |
|
32 | + /** |
|
33 | + * Get the new path of the renamed file relative to the storage root |
|
34 | + * |
|
35 | + * @return string |
|
36 | + * |
|
37 | + * @since 12.0.0 |
|
38 | + */ |
|
39 | + public function getTargetPath(); |
|
40 | 40 | } |
@@ -35,19 +35,19 @@ |
||
35 | 35 | */ |
36 | 36 | interface ILDAPProviderFactory { |
37 | 37 | |
38 | - /** |
|
39 | - * Constructor for the LDAP provider factory |
|
40 | - * |
|
41 | - * @param IServerContainer $serverContainer server container |
|
42 | - * @since 11.0.0 |
|
43 | - */ |
|
44 | - public function __construct(IServerContainer $serverContainer); |
|
38 | + /** |
|
39 | + * Constructor for the LDAP provider factory |
|
40 | + * |
|
41 | + * @param IServerContainer $serverContainer server container |
|
42 | + * @since 11.0.0 |
|
43 | + */ |
|
44 | + public function __construct(IServerContainer $serverContainer); |
|
45 | 45 | |
46 | - /** |
|
47 | - * creates and returns an instance of the ILDAPProvider |
|
48 | - * |
|
49 | - * @return ILDAPProvider |
|
50 | - * @since 11.0.0 |
|
51 | - */ |
|
52 | - public function getLDAPProvider(); |
|
46 | + /** |
|
47 | + * creates and returns an instance of the ILDAPProvider |
|
48 | + * |
|
49 | + * @return ILDAPProvider |
|
50 | + * @since 11.0.0 |
|
51 | + */ |
|
52 | + public function getLDAPProvider(); |
|
53 | 53 | } |
@@ -27,12 +27,12 @@ |
||
27 | 27 | * @since 8.2.0 |
28 | 28 | */ |
29 | 29 | class AutoloadNotAllowedException extends \DomainException { |
30 | - /** |
|
31 | - * @param string $path |
|
32 | - * @since 8.2.0 |
|
33 | - */ |
|
34 | - public function __construct($path) { |
|
35 | - parent::__construct('Autoload path not allowed: '.$path); |
|
36 | - } |
|
30 | + /** |
|
31 | + * @param string $path |
|
32 | + * @since 8.2.0 |
|
33 | + */ |
|
34 | + public function __construct($path) { |
|
35 | + parent::__construct('Autoload path not allowed: '.$path); |
|
36 | + } |
|
37 | 37 | } |
38 | 38 |
@@ -84,7 +84,7 @@ |
||
84 | 84 | * @since 9.0.0 |
85 | 85 | */ |
86 | 86 | public function getGroups() { |
87 | - return array_map(function ($group) { |
|
87 | + return array_map(function($group) { |
|
88 | 88 | /** @var \OCP\IGroup $group */ |
89 | 89 | return $group->getGID(); |
90 | 90 | }, $this->groups); |
@@ -32,61 +32,61 @@ |
||
32 | 32 | * @since 9.0.0 |
33 | 33 | */ |
34 | 34 | class ManagerEvent extends Event { |
35 | - public const EVENT_APP_ENABLE = 'OCP\App\IAppManager::enableApp'; |
|
36 | - public const EVENT_APP_ENABLE_FOR_GROUPS = 'OCP\App\IAppManager::enableAppForGroups'; |
|
37 | - public const EVENT_APP_DISABLE = 'OCP\App\IAppManager::disableApp'; |
|
35 | + public const EVENT_APP_ENABLE = 'OCP\App\IAppManager::enableApp'; |
|
36 | + public const EVENT_APP_ENABLE_FOR_GROUPS = 'OCP\App\IAppManager::enableAppForGroups'; |
|
37 | + public const EVENT_APP_DISABLE = 'OCP\App\IAppManager::disableApp'; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @since 9.1.0 |
|
41 | - */ |
|
42 | - public const EVENT_APP_UPDATE = 'OCP\App\IAppManager::updateApp'; |
|
39 | + /** |
|
40 | + * @since 9.1.0 |
|
41 | + */ |
|
42 | + public const EVENT_APP_UPDATE = 'OCP\App\IAppManager::updateApp'; |
|
43 | 43 | |
44 | - /** @var string */ |
|
45 | - protected $event; |
|
46 | - /** @var string */ |
|
47 | - protected $appID; |
|
48 | - /** @var \OCP\IGroup[]|null */ |
|
49 | - protected $groups; |
|
44 | + /** @var string */ |
|
45 | + protected $event; |
|
46 | + /** @var string */ |
|
47 | + protected $appID; |
|
48 | + /** @var \OCP\IGroup[]|null */ |
|
49 | + protected $groups; |
|
50 | 50 | |
51 | - /** |
|
52 | - * DispatcherEvent constructor. |
|
53 | - * |
|
54 | - * @param string $event |
|
55 | - * @param $appID |
|
56 | - * @param \OCP\IGroup[]|null $groups |
|
57 | - * @since 9.0.0 |
|
58 | - */ |
|
59 | - public function __construct($event, $appID, array $groups = null) { |
|
60 | - $this->event = $event; |
|
61 | - $this->appID = $appID; |
|
62 | - $this->groups = $groups; |
|
63 | - } |
|
51 | + /** |
|
52 | + * DispatcherEvent constructor. |
|
53 | + * |
|
54 | + * @param string $event |
|
55 | + * @param $appID |
|
56 | + * @param \OCP\IGroup[]|null $groups |
|
57 | + * @since 9.0.0 |
|
58 | + */ |
|
59 | + public function __construct($event, $appID, array $groups = null) { |
|
60 | + $this->event = $event; |
|
61 | + $this->appID = $appID; |
|
62 | + $this->groups = $groups; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @return string |
|
67 | - * @since 9.0.0 |
|
68 | - */ |
|
69 | - public function getEvent() { |
|
70 | - return $this->event; |
|
71 | - } |
|
65 | + /** |
|
66 | + * @return string |
|
67 | + * @since 9.0.0 |
|
68 | + */ |
|
69 | + public function getEvent() { |
|
70 | + return $this->event; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @return string |
|
75 | - * @since 9.0.0 |
|
76 | - */ |
|
77 | - public function getAppID() { |
|
78 | - return $this->appID; |
|
79 | - } |
|
73 | + /** |
|
74 | + * @return string |
|
75 | + * @since 9.0.0 |
|
76 | + */ |
|
77 | + public function getAppID() { |
|
78 | + return $this->appID; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * returns the group Ids |
|
83 | - * @return string[] |
|
84 | - * @since 9.0.0 |
|
85 | - */ |
|
86 | - public function getGroups() { |
|
87 | - return array_map(function ($group) { |
|
88 | - /** @var \OCP\IGroup $group */ |
|
89 | - return $group->getGID(); |
|
90 | - }, $this->groups); |
|
91 | - } |
|
81 | + /** |
|
82 | + * returns the group Ids |
|
83 | + * @return string[] |
|
84 | + * @since 9.0.0 |
|
85 | + */ |
|
86 | + public function getGroups() { |
|
87 | + return array_map(function ($group) { |
|
88 | + /** @var \OCP\IGroup $group */ |
|
89 | + return $group->getGID(); |
|
90 | + }, $this->groups); |
|
91 | + } |
|
92 | 92 | } |
@@ -32,13 +32,13 @@ |
||
32 | 32 | */ |
33 | 33 | interface IFile { |
34 | 34 | |
35 | - /** |
|
36 | - * get list of users with access to the file |
|
37 | - * |
|
38 | - * @param string $path to the file |
|
39 | - * @return array |
|
40 | - * @since 8.1.0 |
|
41 | - */ |
|
42 | - public function getAccessList($path); |
|
35 | + /** |
|
36 | + * get list of users with access to the file |
|
37 | + * |
|
38 | + * @param string $path to the file |
|
39 | + * @return array |
|
40 | + * @since 8.1.0 |
|
41 | + */ |
|
42 | + public function getAccessList($path); |
|
43 | 43 | |
44 | 44 | } |
@@ -34,67 +34,67 @@ |
||
34 | 34 | */ |
35 | 35 | interface IManager { |
36 | 36 | |
37 | - /** |
|
38 | - * Check if encryption is available (at least one encryption module needs to be enabled) |
|
39 | - * |
|
40 | - * @return bool true if enabled, false if not |
|
41 | - * @since 8.1.0 |
|
42 | - */ |
|
43 | - public function isEnabled(); |
|
37 | + /** |
|
38 | + * Check if encryption is available (at least one encryption module needs to be enabled) |
|
39 | + * |
|
40 | + * @return bool true if enabled, false if not |
|
41 | + * @since 8.1.0 |
|
42 | + */ |
|
43 | + public function isEnabled(); |
|
44 | 44 | |
45 | - /** |
|
46 | - * Registers an callback function which must return an encryption module instance |
|
47 | - * |
|
48 | - * @param string $id |
|
49 | - * @param string $displayName |
|
50 | - * @param callable $callback |
|
51 | - * @throws ModuleAlreadyExistsException |
|
52 | - * @since 8.1.0 |
|
53 | - */ |
|
54 | - public function registerEncryptionModule($id, $displayName, callable $callback); |
|
45 | + /** |
|
46 | + * Registers an callback function which must return an encryption module instance |
|
47 | + * |
|
48 | + * @param string $id |
|
49 | + * @param string $displayName |
|
50 | + * @param callable $callback |
|
51 | + * @throws ModuleAlreadyExistsException |
|
52 | + * @since 8.1.0 |
|
53 | + */ |
|
54 | + public function registerEncryptionModule($id, $displayName, callable $callback); |
|
55 | 55 | |
56 | - /** |
|
57 | - * Unregisters an encryption module |
|
58 | - * |
|
59 | - * @param string $moduleId |
|
60 | - * @since 8.1.0 |
|
61 | - */ |
|
62 | - public function unregisterEncryptionModule($moduleId); |
|
56 | + /** |
|
57 | + * Unregisters an encryption module |
|
58 | + * |
|
59 | + * @param string $moduleId |
|
60 | + * @since 8.1.0 |
|
61 | + */ |
|
62 | + public function unregisterEncryptionModule($moduleId); |
|
63 | 63 | |
64 | - /** |
|
65 | - * get a list of all encryption modules |
|
66 | - * |
|
67 | - * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]] |
|
68 | - * @since 8.1.0 |
|
69 | - */ |
|
70 | - public function getEncryptionModules(); |
|
64 | + /** |
|
65 | + * get a list of all encryption modules |
|
66 | + * |
|
67 | + * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]] |
|
68 | + * @since 8.1.0 |
|
69 | + */ |
|
70 | + public function getEncryptionModules(); |
|
71 | 71 | |
72 | 72 | |
73 | - /** |
|
74 | - * get a specific encryption module |
|
75 | - * |
|
76 | - * @param string $moduleId Empty to get the default module |
|
77 | - * @return IEncryptionModule |
|
78 | - * @throws ModuleDoesNotExistsException |
|
79 | - * @since 8.1.0 |
|
80 | - */ |
|
81 | - public function getEncryptionModule($moduleId = ''); |
|
73 | + /** |
|
74 | + * get a specific encryption module |
|
75 | + * |
|
76 | + * @param string $moduleId Empty to get the default module |
|
77 | + * @return IEncryptionModule |
|
78 | + * @throws ModuleDoesNotExistsException |
|
79 | + * @since 8.1.0 |
|
80 | + */ |
|
81 | + public function getEncryptionModule($moduleId = ''); |
|
82 | 82 | |
83 | - /** |
|
84 | - * get default encryption module Id |
|
85 | - * |
|
86 | - * @return string |
|
87 | - * @since 8.1.0 |
|
88 | - */ |
|
89 | - public function getDefaultEncryptionModuleId(); |
|
83 | + /** |
|
84 | + * get default encryption module Id |
|
85 | + * |
|
86 | + * @return string |
|
87 | + * @since 8.1.0 |
|
88 | + */ |
|
89 | + public function getDefaultEncryptionModuleId(); |
|
90 | 90 | |
91 | - /** |
|
92 | - * set default encryption module Id |
|
93 | - * |
|
94 | - * @param string $moduleId |
|
95 | - * @return string |
|
96 | - * @since 8.1.0 |
|
97 | - */ |
|
98 | - public function setDefaultEncryptionModule($moduleId); |
|
91 | + /** |
|
92 | + * set default encryption module Id |
|
93 | + * |
|
94 | + * @param string $moduleId |
|
95 | + * @return string |
|
96 | + * @since 8.1.0 |
|
97 | + */ |
|
98 | + public function setDefaultEncryptionModule($moduleId); |
|
99 | 99 | |
100 | 100 | } |
@@ -33,151 +33,151 @@ |
||
33 | 33 | */ |
34 | 34 | interface IStorage { |
35 | 35 | |
36 | - /** |
|
37 | - * get user specific key |
|
38 | - * |
|
39 | - * @param string $uid ID if the user for whom we want the key |
|
40 | - * @param string $keyId id of the key |
|
41 | - * @param string $encryptionModuleId |
|
42 | - * |
|
43 | - * @return mixed key |
|
44 | - * @since 8.1.0 |
|
45 | - */ |
|
46 | - public function getUserKey($uid, $keyId, $encryptionModuleId); |
|
36 | + /** |
|
37 | + * get user specific key |
|
38 | + * |
|
39 | + * @param string $uid ID if the user for whom we want the key |
|
40 | + * @param string $keyId id of the key |
|
41 | + * @param string $encryptionModuleId |
|
42 | + * |
|
43 | + * @return mixed key |
|
44 | + * @since 8.1.0 |
|
45 | + */ |
|
46 | + public function getUserKey($uid, $keyId, $encryptionModuleId); |
|
47 | 47 | |
48 | - /** |
|
49 | - * get file specific key |
|
50 | - * |
|
51 | - * @param string $path path to file |
|
52 | - * @param string $keyId id of the key |
|
53 | - * @param string $encryptionModuleId |
|
54 | - * |
|
55 | - * @return mixed key |
|
56 | - * @since 8.1.0 |
|
57 | - */ |
|
58 | - public function getFileKey($path, $keyId, $encryptionModuleId); |
|
48 | + /** |
|
49 | + * get file specific key |
|
50 | + * |
|
51 | + * @param string $path path to file |
|
52 | + * @param string $keyId id of the key |
|
53 | + * @param string $encryptionModuleId |
|
54 | + * |
|
55 | + * @return mixed key |
|
56 | + * @since 8.1.0 |
|
57 | + */ |
|
58 | + public function getFileKey($path, $keyId, $encryptionModuleId); |
|
59 | 59 | |
60 | - /** |
|
61 | - * get system-wide encryption keys not related to a specific user, |
|
62 | - * e.g something like a key for public link shares |
|
63 | - * |
|
64 | - * @param string $keyId id of the key |
|
65 | - * @param string $encryptionModuleId |
|
66 | - * |
|
67 | - * @return mixed key |
|
68 | - * @since 8.1.0 |
|
69 | - */ |
|
70 | - public function getSystemUserKey($keyId, $encryptionModuleId); |
|
60 | + /** |
|
61 | + * get system-wide encryption keys not related to a specific user, |
|
62 | + * e.g something like a key for public link shares |
|
63 | + * |
|
64 | + * @param string $keyId id of the key |
|
65 | + * @param string $encryptionModuleId |
|
66 | + * |
|
67 | + * @return mixed key |
|
68 | + * @since 8.1.0 |
|
69 | + */ |
|
70 | + public function getSystemUserKey($keyId, $encryptionModuleId); |
|
71 | 71 | |
72 | - /** |
|
73 | - * set user specific key |
|
74 | - * |
|
75 | - * @param string $uid ID if the user for whom we want the key |
|
76 | - * @param string $keyId id of the key |
|
77 | - * @param mixed $key |
|
78 | - * @param string $encryptionModuleId |
|
79 | - * @since 8.1.0 |
|
80 | - */ |
|
81 | - public function setUserKey($uid, $keyId, $key, $encryptionModuleId); |
|
72 | + /** |
|
73 | + * set user specific key |
|
74 | + * |
|
75 | + * @param string $uid ID if the user for whom we want the key |
|
76 | + * @param string $keyId id of the key |
|
77 | + * @param mixed $key |
|
78 | + * @param string $encryptionModuleId |
|
79 | + * @since 8.1.0 |
|
80 | + */ |
|
81 | + public function setUserKey($uid, $keyId, $key, $encryptionModuleId); |
|
82 | 82 | |
83 | - /** |
|
84 | - * set file specific key |
|
85 | - * |
|
86 | - * @param string $path path to file |
|
87 | - * @param string $keyId id of the key |
|
88 | - * @param mixed $key |
|
89 | - * @param string $encryptionModuleId |
|
90 | - * @since 8.1.0 |
|
91 | - */ |
|
92 | - public function setFileKey($path, $keyId, $key, $encryptionModuleId); |
|
83 | + /** |
|
84 | + * set file specific key |
|
85 | + * |
|
86 | + * @param string $path path to file |
|
87 | + * @param string $keyId id of the key |
|
88 | + * @param mixed $key |
|
89 | + * @param string $encryptionModuleId |
|
90 | + * @since 8.1.0 |
|
91 | + */ |
|
92 | + public function setFileKey($path, $keyId, $key, $encryptionModuleId); |
|
93 | 93 | |
94 | - /** |
|
95 | - * set system-wide encryption keys not related to a specific user, |
|
96 | - * e.g something like a key for public link shares |
|
97 | - * |
|
98 | - * @param string $keyId id of the key |
|
99 | - * @param mixed $key |
|
100 | - * @param string $encryptionModuleId |
|
101 | - * |
|
102 | - * @return mixed key |
|
103 | - * @since 8.1.0 |
|
104 | - */ |
|
105 | - public function setSystemUserKey($keyId, $key, $encryptionModuleId); |
|
94 | + /** |
|
95 | + * set system-wide encryption keys not related to a specific user, |
|
96 | + * e.g something like a key for public link shares |
|
97 | + * |
|
98 | + * @param string $keyId id of the key |
|
99 | + * @param mixed $key |
|
100 | + * @param string $encryptionModuleId |
|
101 | + * |
|
102 | + * @return mixed key |
|
103 | + * @since 8.1.0 |
|
104 | + */ |
|
105 | + public function setSystemUserKey($keyId, $key, $encryptionModuleId); |
|
106 | 106 | |
107 | - /** |
|
108 | - * delete user specific key |
|
109 | - * |
|
110 | - * @param string $uid ID if the user for whom we want to delete the key |
|
111 | - * @param string $keyId id of the key |
|
112 | - * @param string $encryptionModuleId |
|
113 | - * |
|
114 | - * @return boolean False when the key could not be deleted |
|
115 | - * @since 8.1.0 |
|
116 | - */ |
|
117 | - public function deleteUserKey($uid, $keyId, $encryptionModuleId); |
|
107 | + /** |
|
108 | + * delete user specific key |
|
109 | + * |
|
110 | + * @param string $uid ID if the user for whom we want to delete the key |
|
111 | + * @param string $keyId id of the key |
|
112 | + * @param string $encryptionModuleId |
|
113 | + * |
|
114 | + * @return boolean False when the key could not be deleted |
|
115 | + * @since 8.1.0 |
|
116 | + */ |
|
117 | + public function deleteUserKey($uid, $keyId, $encryptionModuleId); |
|
118 | 118 | |
119 | - /** |
|
120 | - * delete file specific key |
|
121 | - * |
|
122 | - * @param string $path path to file |
|
123 | - * @param string $keyId id of the key |
|
124 | - * @param string $encryptionModuleId |
|
125 | - * |
|
126 | - * @return boolean False when the key could not be deleted |
|
127 | - * @since 8.1.0 |
|
128 | - */ |
|
129 | - public function deleteFileKey($path, $keyId, $encryptionModuleId); |
|
119 | + /** |
|
120 | + * delete file specific key |
|
121 | + * |
|
122 | + * @param string $path path to file |
|
123 | + * @param string $keyId id of the key |
|
124 | + * @param string $encryptionModuleId |
|
125 | + * |
|
126 | + * @return boolean False when the key could not be deleted |
|
127 | + * @since 8.1.0 |
|
128 | + */ |
|
129 | + public function deleteFileKey($path, $keyId, $encryptionModuleId); |
|
130 | 130 | |
131 | - /** |
|
132 | - * delete all file keys for a given file |
|
133 | - * |
|
134 | - * @param string $path to the file |
|
135 | - * |
|
136 | - * @return boolean False when the keys could not be deleted |
|
137 | - * @since 8.1.0 |
|
138 | - */ |
|
139 | - public function deleteAllFileKeys($path); |
|
131 | + /** |
|
132 | + * delete all file keys for a given file |
|
133 | + * |
|
134 | + * @param string $path to the file |
|
135 | + * |
|
136 | + * @return boolean False when the keys could not be deleted |
|
137 | + * @since 8.1.0 |
|
138 | + */ |
|
139 | + public function deleteAllFileKeys($path); |
|
140 | 140 | |
141 | - /** |
|
142 | - * delete system-wide encryption keys not related to a specific user, |
|
143 | - * e.g something like a key for public link shares |
|
144 | - * |
|
145 | - * @param string $keyId id of the key |
|
146 | - * @param string $encryptionModuleId |
|
147 | - * |
|
148 | - * @return boolean False when the key could not be deleted |
|
149 | - * @since 8.1.0 |
|
150 | - */ |
|
151 | - public function deleteSystemUserKey($keyId, $encryptionModuleId); |
|
141 | + /** |
|
142 | + * delete system-wide encryption keys not related to a specific user, |
|
143 | + * e.g something like a key for public link shares |
|
144 | + * |
|
145 | + * @param string $keyId id of the key |
|
146 | + * @param string $encryptionModuleId |
|
147 | + * |
|
148 | + * @return boolean False when the key could not be deleted |
|
149 | + * @since 8.1.0 |
|
150 | + */ |
|
151 | + public function deleteSystemUserKey($keyId, $encryptionModuleId); |
|
152 | 152 | |
153 | - /** |
|
154 | - * copy keys if a file was renamed |
|
155 | - * |
|
156 | - * @param string $source |
|
157 | - * @param string $target |
|
158 | - * @return boolean |
|
159 | - * @since 8.1.0 |
|
160 | - */ |
|
161 | - public function renameKeys($source, $target); |
|
153 | + /** |
|
154 | + * copy keys if a file was renamed |
|
155 | + * |
|
156 | + * @param string $source |
|
157 | + * @param string $target |
|
158 | + * @return boolean |
|
159 | + * @since 8.1.0 |
|
160 | + */ |
|
161 | + public function renameKeys($source, $target); |
|
162 | 162 | |
163 | - /** |
|
164 | - * move keys if a file was renamed |
|
165 | - * |
|
166 | - * @param string $source |
|
167 | - * @param string $target |
|
168 | - * @return boolean |
|
169 | - * @since 8.1.0 |
|
170 | - */ |
|
171 | - public function copyKeys($source, $target); |
|
163 | + /** |
|
164 | + * move keys if a file was renamed |
|
165 | + * |
|
166 | + * @param string $source |
|
167 | + * @param string $target |
|
168 | + * @return boolean |
|
169 | + * @since 8.1.0 |
|
170 | + */ |
|
171 | + public function copyKeys($source, $target); |
|
172 | 172 | |
173 | - /** |
|
174 | - * backup keys of a given encryption module |
|
175 | - * |
|
176 | - * @param string $encryptionModuleId |
|
177 | - * @param string $purpose |
|
178 | - * @param string $uid |
|
179 | - * @return bool |
|
180 | - * @since 12.0.0 |
|
181 | - */ |
|
182 | - public function backupUserKeys($encryptionModuleId, $purpose, $uid); |
|
173 | + /** |
|
174 | + * backup keys of a given encryption module |
|
175 | + * |
|
176 | + * @param string $encryptionModuleId |
|
177 | + * @param string $purpose |
|
178 | + * @param string $uid |
|
179 | + * @return bool |
|
180 | + * @since 12.0.0 |
|
181 | + */ |
|
182 | + public function backupUserKeys($encryptionModuleId, $purpose, $uid); |
|
183 | 183 | } |
@@ -28,45 +28,45 @@ |
||
28 | 28 | |
29 | 29 | class Credentials implements ICredentials { |
30 | 30 | |
31 | - /** @var string */ |
|
32 | - private $uid; |
|
31 | + /** @var string */ |
|
32 | + private $uid; |
|
33 | 33 | |
34 | - /** @var string */ |
|
35 | - private $loginName; |
|
34 | + /** @var string */ |
|
35 | + private $loginName; |
|
36 | 36 | |
37 | - /** @var string */ |
|
38 | - private $password; |
|
37 | + /** @var string */ |
|
38 | + private $password; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @param string $uid |
|
42 | - * @param string $loginName |
|
43 | - * @param string $password |
|
44 | - */ |
|
45 | - public function __construct($uid, $loginName, $password) { |
|
46 | - $this->uid = $uid; |
|
47 | - $this->loginName = $loginName; |
|
48 | - $this->password = $password; |
|
49 | - } |
|
40 | + /** |
|
41 | + * @param string $uid |
|
42 | + * @param string $loginName |
|
43 | + * @param string $password |
|
44 | + */ |
|
45 | + public function __construct($uid, $loginName, $password) { |
|
46 | + $this->uid = $uid; |
|
47 | + $this->loginName = $loginName; |
|
48 | + $this->password = $password; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - public function getUID() { |
|
55 | - return $this->uid; |
|
56 | - } |
|
51 | + /** |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + public function getUID() { |
|
55 | + return $this->uid; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return string |
|
60 | - */ |
|
61 | - public function getLoginName() { |
|
62 | - return $this->loginName; |
|
63 | - } |
|
58 | + /** |
|
59 | + * @return string |
|
60 | + */ |
|
61 | + public function getLoginName() { |
|
62 | + return $this->loginName; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function getPassword() { |
|
69 | - return $this->password; |
|
70 | - } |
|
65 | + /** |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function getPassword() { |
|
69 | + return $this->password; |
|
70 | + } |
|
71 | 71 | |
72 | 72 | } |
@@ -129,7 +129,7 @@ |
||
129 | 129 | $data = $result->fetchAll(); |
130 | 130 | $result->closeCursor(); |
131 | 131 | |
132 | - $entities = array_map(function ($row) { |
|
132 | + $entities = array_map(function($row) { |
|
133 | 133 | return DefaultToken::fromRow($row); |
134 | 134 | }, $data); |
135 | 135 |
@@ -39,135 +39,135 @@ |
||
39 | 39 | * @template-extends QBMapper<DefaultToken> |
40 | 40 | */ |
41 | 41 | class DefaultTokenMapper extends QBMapper { |
42 | - public function __construct(IDBConnection $db) { |
|
43 | - parent::__construct($db, 'authtoken'); |
|
44 | - } |
|
45 | - |
|
46 | - /** |
|
47 | - * Invalidate (delete) a given token |
|
48 | - * |
|
49 | - * @param string $token |
|
50 | - */ |
|
51 | - public function invalidate(string $token) { |
|
52 | - /* @var $qb IQueryBuilder */ |
|
53 | - $qb = $this->db->getQueryBuilder(); |
|
54 | - $qb->delete('authtoken') |
|
55 | - ->where($qb->expr()->eq('token', $qb->createNamedParameter($token, IQueryBuilder::PARAM_STR))) |
|
56 | - ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
57 | - ->execute(); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * @param int $olderThan |
|
62 | - * @param int $remember |
|
63 | - */ |
|
64 | - public function invalidateOld(int $olderThan, int $remember = IToken::DO_NOT_REMEMBER) { |
|
65 | - /* @var $qb IQueryBuilder */ |
|
66 | - $qb = $this->db->getQueryBuilder(); |
|
67 | - $qb->delete('authtoken') |
|
68 | - ->where($qb->expr()->lt('last_activity', $qb->createNamedParameter($olderThan, IQueryBuilder::PARAM_INT))) |
|
69 | - ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter(IToken::TEMPORARY_TOKEN, IQueryBuilder::PARAM_INT))) |
|
70 | - ->andWhere($qb->expr()->eq('remember', $qb->createNamedParameter($remember, IQueryBuilder::PARAM_INT))) |
|
71 | - ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
72 | - ->execute(); |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Get the user UID for the given token |
|
77 | - * |
|
78 | - * @param string $token |
|
79 | - * @throws DoesNotExistException |
|
80 | - * @return DefaultToken |
|
81 | - */ |
|
82 | - public function getToken(string $token): DefaultToken { |
|
83 | - /* @var $qb IQueryBuilder */ |
|
84 | - $qb = $this->db->getQueryBuilder(); |
|
85 | - $result = $qb->select('id', 'uid', 'login_name', 'password', 'name', 'token', 'type', 'remember', 'last_activity', 'last_check', 'scope', 'expires', 'version') |
|
86 | - ->from('authtoken') |
|
87 | - ->where($qb->expr()->eq('token', $qb->createNamedParameter($token))) |
|
88 | - ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
89 | - ->execute(); |
|
90 | - |
|
91 | - $data = $result->fetch(); |
|
92 | - $result->closeCursor(); |
|
93 | - if ($data === false) { |
|
94 | - throw new DoesNotExistException('token does not exist'); |
|
95 | - } |
|
96 | - return DefaultToken::fromRow($data); |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Get the token for $id |
|
101 | - * |
|
102 | - * @param int $id |
|
103 | - * @throws DoesNotExistException |
|
104 | - * @return DefaultToken |
|
105 | - */ |
|
106 | - public function getTokenById(int $id): DefaultToken { |
|
107 | - /* @var $qb IQueryBuilder */ |
|
108 | - $qb = $this->db->getQueryBuilder(); |
|
109 | - $result = $qb->select('id', 'uid', 'login_name', 'password', 'name', 'token', 'type', 'remember', 'last_activity', 'last_check', 'scope', 'expires', 'version') |
|
110 | - ->from('authtoken') |
|
111 | - ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) |
|
112 | - ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
113 | - ->execute(); |
|
114 | - |
|
115 | - $data = $result->fetch(); |
|
116 | - $result->closeCursor(); |
|
117 | - if ($data === false) { |
|
118 | - throw new DoesNotExistException('token does not exist'); |
|
119 | - } |
|
120 | - return DefaultToken::fromRow($data); |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Get all tokens of a user |
|
125 | - * |
|
126 | - * The provider may limit the number of result rows in case of an abuse |
|
127 | - * where a high number of (session) tokens is generated |
|
128 | - * |
|
129 | - * @param string $uid |
|
130 | - * @return DefaultToken[] |
|
131 | - */ |
|
132 | - public function getTokenByUser(string $uid): array { |
|
133 | - /* @var $qb IQueryBuilder */ |
|
134 | - $qb = $this->db->getQueryBuilder(); |
|
135 | - $qb->select('id', 'uid', 'login_name', 'password', 'name', 'token', 'type', 'remember', 'last_activity', 'last_check', 'scope', 'expires', 'version') |
|
136 | - ->from('authtoken') |
|
137 | - ->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid))) |
|
138 | - ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
139 | - ->setMaxResults(1000); |
|
140 | - $result = $qb->execute(); |
|
141 | - $data = $result->fetchAll(); |
|
142 | - $result->closeCursor(); |
|
143 | - |
|
144 | - $entities = array_map(function ($row) { |
|
145 | - return DefaultToken::fromRow($row); |
|
146 | - }, $data); |
|
147 | - |
|
148 | - return $entities; |
|
149 | - } |
|
150 | - |
|
151 | - public function deleteById(string $uid, int $id) { |
|
152 | - /* @var $qb IQueryBuilder */ |
|
153 | - $qb = $this->db->getQueryBuilder(); |
|
154 | - $qb->delete('authtoken') |
|
155 | - ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) |
|
156 | - ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($uid))) |
|
157 | - ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT))); |
|
158 | - $qb->execute(); |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * delete all auth token which belong to a specific client if the client was deleted |
|
163 | - * |
|
164 | - * @param string $name |
|
165 | - */ |
|
166 | - public function deleteByName(string $name) { |
|
167 | - $qb = $this->db->getQueryBuilder(); |
|
168 | - $qb->delete('authtoken') |
|
169 | - ->where($qb->expr()->eq('name', $qb->createNamedParameter($name), IQueryBuilder::PARAM_STR)) |
|
170 | - ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT))); |
|
171 | - $qb->execute(); |
|
172 | - } |
|
42 | + public function __construct(IDBConnection $db) { |
|
43 | + parent::__construct($db, 'authtoken'); |
|
44 | + } |
|
45 | + |
|
46 | + /** |
|
47 | + * Invalidate (delete) a given token |
|
48 | + * |
|
49 | + * @param string $token |
|
50 | + */ |
|
51 | + public function invalidate(string $token) { |
|
52 | + /* @var $qb IQueryBuilder */ |
|
53 | + $qb = $this->db->getQueryBuilder(); |
|
54 | + $qb->delete('authtoken') |
|
55 | + ->where($qb->expr()->eq('token', $qb->createNamedParameter($token, IQueryBuilder::PARAM_STR))) |
|
56 | + ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
57 | + ->execute(); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * @param int $olderThan |
|
62 | + * @param int $remember |
|
63 | + */ |
|
64 | + public function invalidateOld(int $olderThan, int $remember = IToken::DO_NOT_REMEMBER) { |
|
65 | + /* @var $qb IQueryBuilder */ |
|
66 | + $qb = $this->db->getQueryBuilder(); |
|
67 | + $qb->delete('authtoken') |
|
68 | + ->where($qb->expr()->lt('last_activity', $qb->createNamedParameter($olderThan, IQueryBuilder::PARAM_INT))) |
|
69 | + ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter(IToken::TEMPORARY_TOKEN, IQueryBuilder::PARAM_INT))) |
|
70 | + ->andWhere($qb->expr()->eq('remember', $qb->createNamedParameter($remember, IQueryBuilder::PARAM_INT))) |
|
71 | + ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
72 | + ->execute(); |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Get the user UID for the given token |
|
77 | + * |
|
78 | + * @param string $token |
|
79 | + * @throws DoesNotExistException |
|
80 | + * @return DefaultToken |
|
81 | + */ |
|
82 | + public function getToken(string $token): DefaultToken { |
|
83 | + /* @var $qb IQueryBuilder */ |
|
84 | + $qb = $this->db->getQueryBuilder(); |
|
85 | + $result = $qb->select('id', 'uid', 'login_name', 'password', 'name', 'token', 'type', 'remember', 'last_activity', 'last_check', 'scope', 'expires', 'version') |
|
86 | + ->from('authtoken') |
|
87 | + ->where($qb->expr()->eq('token', $qb->createNamedParameter($token))) |
|
88 | + ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
89 | + ->execute(); |
|
90 | + |
|
91 | + $data = $result->fetch(); |
|
92 | + $result->closeCursor(); |
|
93 | + if ($data === false) { |
|
94 | + throw new DoesNotExistException('token does not exist'); |
|
95 | + } |
|
96 | + return DefaultToken::fromRow($data); |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Get the token for $id |
|
101 | + * |
|
102 | + * @param int $id |
|
103 | + * @throws DoesNotExistException |
|
104 | + * @return DefaultToken |
|
105 | + */ |
|
106 | + public function getTokenById(int $id): DefaultToken { |
|
107 | + /* @var $qb IQueryBuilder */ |
|
108 | + $qb = $this->db->getQueryBuilder(); |
|
109 | + $result = $qb->select('id', 'uid', 'login_name', 'password', 'name', 'token', 'type', 'remember', 'last_activity', 'last_check', 'scope', 'expires', 'version') |
|
110 | + ->from('authtoken') |
|
111 | + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) |
|
112 | + ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
113 | + ->execute(); |
|
114 | + |
|
115 | + $data = $result->fetch(); |
|
116 | + $result->closeCursor(); |
|
117 | + if ($data === false) { |
|
118 | + throw new DoesNotExistException('token does not exist'); |
|
119 | + } |
|
120 | + return DefaultToken::fromRow($data); |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Get all tokens of a user |
|
125 | + * |
|
126 | + * The provider may limit the number of result rows in case of an abuse |
|
127 | + * where a high number of (session) tokens is generated |
|
128 | + * |
|
129 | + * @param string $uid |
|
130 | + * @return DefaultToken[] |
|
131 | + */ |
|
132 | + public function getTokenByUser(string $uid): array { |
|
133 | + /* @var $qb IQueryBuilder */ |
|
134 | + $qb = $this->db->getQueryBuilder(); |
|
135 | + $qb->select('id', 'uid', 'login_name', 'password', 'name', 'token', 'type', 'remember', 'last_activity', 'last_check', 'scope', 'expires', 'version') |
|
136 | + ->from('authtoken') |
|
137 | + ->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid))) |
|
138 | + ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
139 | + ->setMaxResults(1000); |
|
140 | + $result = $qb->execute(); |
|
141 | + $data = $result->fetchAll(); |
|
142 | + $result->closeCursor(); |
|
143 | + |
|
144 | + $entities = array_map(function ($row) { |
|
145 | + return DefaultToken::fromRow($row); |
|
146 | + }, $data); |
|
147 | + |
|
148 | + return $entities; |
|
149 | + } |
|
150 | + |
|
151 | + public function deleteById(string $uid, int $id) { |
|
152 | + /* @var $qb IQueryBuilder */ |
|
153 | + $qb = $this->db->getQueryBuilder(); |
|
154 | + $qb->delete('authtoken') |
|
155 | + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) |
|
156 | + ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($uid))) |
|
157 | + ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT))); |
|
158 | + $qb->execute(); |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * delete all auth token which belong to a specific client if the client was deleted |
|
163 | + * |
|
164 | + * @param string $name |
|
165 | + */ |
|
166 | + public function deleteByName(string $name) { |
|
167 | + $qb = $this->db->getQueryBuilder(); |
|
168 | + $qb->delete('authtoken') |
|
169 | + ->where($qb->expr()->eq('name', $qb->createNamedParameter($name), IQueryBuilder::PARAM_STR)) |
|
170 | + ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(DefaultToken::VERSION, IQueryBuilder::PARAM_INT))); |
|
171 | + $qb->execute(); |
|
172 | + } |
|
173 | 173 | } |