@@ -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 | } |
@@ -46,7 +46,7 @@ |
||
46 | 46 | /** |
47 | 47 | * @since 9.2.0 |
48 | 48 | */ |
49 | - const EVENT = self::class . ':' . 'PreviewRequested'; |
|
49 | + const EVENT = self::class.':'.'PreviewRequested'; |
|
50 | 50 | |
51 | 51 | const MODE_FILL = 'fill'; |
52 | 52 | const MODE_COVER = 'cover'; |
@@ -43,86 +43,86 @@ |
||
43 | 43 | */ |
44 | 44 | interface IPreview { |
45 | 45 | |
46 | - /** |
|
47 | - * @since 9.2.0 |
|
48 | - */ |
|
49 | - const EVENT = self::class . ':' . 'PreviewRequested'; |
|
46 | + /** |
|
47 | + * @since 9.2.0 |
|
48 | + */ |
|
49 | + const EVENT = self::class . ':' . 'PreviewRequested'; |
|
50 | 50 | |
51 | - const MODE_FILL = 'fill'; |
|
52 | - const MODE_COVER = 'cover'; |
|
51 | + const MODE_FILL = 'fill'; |
|
52 | + const MODE_COVER = 'cover'; |
|
53 | 53 | |
54 | - /** |
|
55 | - * In order to improve lazy loading a closure can be registered which will be |
|
56 | - * called in case preview providers are actually requested |
|
57 | - * |
|
58 | - * $callable has to return an instance of \OCP\Preview\IProvider |
|
59 | - * |
|
60 | - * @param string $mimeTypeRegex Regex with the mime types that are supported by this provider |
|
61 | - * @param \Closure $callable |
|
62 | - * @return void |
|
63 | - * @since 8.1.0 |
|
64 | - */ |
|
65 | - public function registerProvider($mimeTypeRegex, \Closure $callable); |
|
54 | + /** |
|
55 | + * In order to improve lazy loading a closure can be registered which will be |
|
56 | + * called in case preview providers are actually requested |
|
57 | + * |
|
58 | + * $callable has to return an instance of \OCP\Preview\IProvider |
|
59 | + * |
|
60 | + * @param string $mimeTypeRegex Regex with the mime types that are supported by this provider |
|
61 | + * @param \Closure $callable |
|
62 | + * @return void |
|
63 | + * @since 8.1.0 |
|
64 | + */ |
|
65 | + public function registerProvider($mimeTypeRegex, \Closure $callable); |
|
66 | 66 | |
67 | - /** |
|
68 | - * Get all providers |
|
69 | - * @return array |
|
70 | - * @since 8.1.0 |
|
71 | - */ |
|
72 | - public function getProviders(); |
|
67 | + /** |
|
68 | + * Get all providers |
|
69 | + * @return array |
|
70 | + * @since 8.1.0 |
|
71 | + */ |
|
72 | + public function getProviders(); |
|
73 | 73 | |
74 | - /** |
|
75 | - * Does the manager have any providers |
|
76 | - * @return bool |
|
77 | - * @since 8.1.0 |
|
78 | - */ |
|
79 | - public function hasProviders(); |
|
74 | + /** |
|
75 | + * Does the manager have any providers |
|
76 | + * @return bool |
|
77 | + * @since 8.1.0 |
|
78 | + */ |
|
79 | + public function hasProviders(); |
|
80 | 80 | |
81 | - /** |
|
82 | - * Return a preview of a file |
|
83 | - * @param string $file The path to the file where you want a thumbnail from |
|
84 | - * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image |
|
85 | - * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image |
|
86 | - * @param boolean $scaleUp Scale smaller images up to the thumbnail size or not. Might look ugly |
|
87 | - * @return \OCP\IImage |
|
88 | - * @since 6.0.0 |
|
89 | - * @deprecated 11 Use getPreview |
|
90 | - */ |
|
91 | - public function createPreview($file, $maxX = 100, $maxY = 75, $scaleUp = false); |
|
81 | + /** |
|
82 | + * Return a preview of a file |
|
83 | + * @param string $file The path to the file where you want a thumbnail from |
|
84 | + * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image |
|
85 | + * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image |
|
86 | + * @param boolean $scaleUp Scale smaller images up to the thumbnail size or not. Might look ugly |
|
87 | + * @return \OCP\IImage |
|
88 | + * @since 6.0.0 |
|
89 | + * @deprecated 11 Use getPreview |
|
90 | + */ |
|
91 | + public function createPreview($file, $maxX = 100, $maxY = 75, $scaleUp = false); |
|
92 | 92 | |
93 | - /** |
|
94 | - * Returns a preview of a file |
|
95 | - * |
|
96 | - * The cache is searched first and if nothing usable was found then a preview is |
|
97 | - * generated by one of the providers |
|
98 | - * |
|
99 | - * @param File $file |
|
100 | - * @param int $width |
|
101 | - * @param int $height |
|
102 | - * @param bool $crop |
|
103 | - * @param string $mode |
|
104 | - * @param string $mimeType To force a given mimetype for the file (files_versions needs this) |
|
105 | - * @return ISimpleFile |
|
106 | - * @throws NotFoundException |
|
107 | - * @throws \InvalidArgumentException if the preview would be invalid (in case the original image is invalid) |
|
108 | - * @since 11.0.0 - \InvalidArgumentException was added in 12.0.0 |
|
109 | - */ |
|
110 | - public function getPreview(File $file, $width = -1, $height = -1, $crop = false, $mode = IPreview::MODE_FILL, $mimeType = null); |
|
93 | + /** |
|
94 | + * Returns a preview of a file |
|
95 | + * |
|
96 | + * The cache is searched first and if nothing usable was found then a preview is |
|
97 | + * generated by one of the providers |
|
98 | + * |
|
99 | + * @param File $file |
|
100 | + * @param int $width |
|
101 | + * @param int $height |
|
102 | + * @param bool $crop |
|
103 | + * @param string $mode |
|
104 | + * @param string $mimeType To force a given mimetype for the file (files_versions needs this) |
|
105 | + * @return ISimpleFile |
|
106 | + * @throws NotFoundException |
|
107 | + * @throws \InvalidArgumentException if the preview would be invalid (in case the original image is invalid) |
|
108 | + * @since 11.0.0 - \InvalidArgumentException was added in 12.0.0 |
|
109 | + */ |
|
110 | + public function getPreview(File $file, $width = -1, $height = -1, $crop = false, $mode = IPreview::MODE_FILL, $mimeType = null); |
|
111 | 111 | |
112 | - /** |
|
113 | - * Returns true if the passed mime type is supported |
|
114 | - * @param string $mimeType |
|
115 | - * @return boolean |
|
116 | - * @since 6.0.0 |
|
117 | - */ |
|
118 | - public function isMimeSupported($mimeType = '*'); |
|
112 | + /** |
|
113 | + * Returns true if the passed mime type is supported |
|
114 | + * @param string $mimeType |
|
115 | + * @return boolean |
|
116 | + * @since 6.0.0 |
|
117 | + */ |
|
118 | + public function isMimeSupported($mimeType = '*'); |
|
119 | 119 | |
120 | - /** |
|
121 | - * Check if a preview can be generated for a file |
|
122 | - * |
|
123 | - * @param \OCP\Files\FileInfo $file |
|
124 | - * @return bool |
|
125 | - * @since 8.0.0 |
|
126 | - */ |
|
127 | - public function isAvailable(\OCP\Files\FileInfo $file); |
|
120 | + /** |
|
121 | + * Check if a preview can be generated for a file |
|
122 | + * |
|
123 | + * @param \OCP\Files\FileInfo $file |
|
124 | + * @return bool |
|
125 | + * @since 8.0.0 |
|
126 | + */ |
|
127 | + public function isAvailable(\OCP\Files\FileInfo $file); |
|
128 | 128 | } |
@@ -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 | } |
@@ -37,84 +37,84 @@ |
||
37 | 37 | |
38 | 38 | class Store implements IStore { |
39 | 39 | |
40 | - /** @var ISession */ |
|
41 | - private $session; |
|
42 | - |
|
43 | - /** @var ILogger */ |
|
44 | - private $logger; |
|
45 | - |
|
46 | - /** @var IProvider|null */ |
|
47 | - private $tokenProvider; |
|
48 | - |
|
49 | - /** |
|
50 | - * @param ISession $session |
|
51 | - * @param ILogger $logger |
|
52 | - * @param IProvider $tokenProvider |
|
53 | - */ |
|
54 | - public function __construct(ISession $session, ILogger $logger, IProvider $tokenProvider = null) { |
|
55 | - $this->session = $session; |
|
56 | - $this->logger = $logger; |
|
57 | - $this->tokenProvider = $tokenProvider; |
|
58 | - |
|
59 | - Util::connectHook('OC_User', 'post_login', $this, 'authenticate'); |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * Hook listener on post login |
|
64 | - * |
|
65 | - * @param array $params |
|
66 | - */ |
|
67 | - public function authenticate(array $params) { |
|
68 | - $this->session->set('login_credentials', json_encode($params)); |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * Replace the session implementation |
|
73 | - * |
|
74 | - * @param ISession $session |
|
75 | - */ |
|
76 | - public function setSession(ISession $session) { |
|
77 | - $this->session = $session; |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * @since 12 |
|
82 | - * |
|
83 | - * @return ICredentials the login credentials of the current user |
|
84 | - * @throws CredentialsUnavailableException |
|
85 | - */ |
|
86 | - public function getLoginCredentials() { |
|
87 | - if (is_null($this->tokenProvider)) { |
|
88 | - throw new CredentialsUnavailableException(); |
|
89 | - } |
|
90 | - |
|
91 | - $trySession = false; |
|
92 | - try { |
|
93 | - $sessionId = $this->session->getId(); |
|
94 | - $token = $this->tokenProvider->getToken($sessionId); |
|
95 | - |
|
96 | - $uid = $token->getUID(); |
|
97 | - $user = $token->getLoginName(); |
|
98 | - $password = $this->tokenProvider->getPassword($token, $sessionId); |
|
99 | - |
|
100 | - return new Credentials($uid, $user, $password); |
|
101 | - } catch (SessionNotAvailableException $ex) { |
|
102 | - $this->logger->debug('could not get login credentials because session is unavailable', ['app' => 'core']); |
|
103 | - } catch (InvalidTokenException $ex) { |
|
104 | - $this->logger->debug('could not get login credentials because the token is invalid', ['app' => 'core']); |
|
105 | - $trySession = true; |
|
106 | - } catch (PasswordlessTokenException $ex) { |
|
107 | - $this->logger->debug('could not get login credentials because the token has no password', ['app' => 'core']); |
|
108 | - $trySession = true; |
|
109 | - } |
|
110 | - |
|
111 | - if ($trySession && $this->session->exists('login_credentials')) { |
|
112 | - $creds = json_decode($this->session->get('login_credentials')); |
|
113 | - return new Credentials($creds->uid, $creds->uid, $creds->password); |
|
114 | - } |
|
115 | - |
|
116 | - // If we reach this line, an exception was thrown. |
|
117 | - throw new CredentialsUnavailableException(); |
|
118 | - } |
|
40 | + /** @var ISession */ |
|
41 | + private $session; |
|
42 | + |
|
43 | + /** @var ILogger */ |
|
44 | + private $logger; |
|
45 | + |
|
46 | + /** @var IProvider|null */ |
|
47 | + private $tokenProvider; |
|
48 | + |
|
49 | + /** |
|
50 | + * @param ISession $session |
|
51 | + * @param ILogger $logger |
|
52 | + * @param IProvider $tokenProvider |
|
53 | + */ |
|
54 | + public function __construct(ISession $session, ILogger $logger, IProvider $tokenProvider = null) { |
|
55 | + $this->session = $session; |
|
56 | + $this->logger = $logger; |
|
57 | + $this->tokenProvider = $tokenProvider; |
|
58 | + |
|
59 | + Util::connectHook('OC_User', 'post_login', $this, 'authenticate'); |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Hook listener on post login |
|
64 | + * |
|
65 | + * @param array $params |
|
66 | + */ |
|
67 | + public function authenticate(array $params) { |
|
68 | + $this->session->set('login_credentials', json_encode($params)); |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * Replace the session implementation |
|
73 | + * |
|
74 | + * @param ISession $session |
|
75 | + */ |
|
76 | + public function setSession(ISession $session) { |
|
77 | + $this->session = $session; |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * @since 12 |
|
82 | + * |
|
83 | + * @return ICredentials the login credentials of the current user |
|
84 | + * @throws CredentialsUnavailableException |
|
85 | + */ |
|
86 | + public function getLoginCredentials() { |
|
87 | + if (is_null($this->tokenProvider)) { |
|
88 | + throw new CredentialsUnavailableException(); |
|
89 | + } |
|
90 | + |
|
91 | + $trySession = false; |
|
92 | + try { |
|
93 | + $sessionId = $this->session->getId(); |
|
94 | + $token = $this->tokenProvider->getToken($sessionId); |
|
95 | + |
|
96 | + $uid = $token->getUID(); |
|
97 | + $user = $token->getLoginName(); |
|
98 | + $password = $this->tokenProvider->getPassword($token, $sessionId); |
|
99 | + |
|
100 | + return new Credentials($uid, $user, $password); |
|
101 | + } catch (SessionNotAvailableException $ex) { |
|
102 | + $this->logger->debug('could not get login credentials because session is unavailable', ['app' => 'core']); |
|
103 | + } catch (InvalidTokenException $ex) { |
|
104 | + $this->logger->debug('could not get login credentials because the token is invalid', ['app' => 'core']); |
|
105 | + $trySession = true; |
|
106 | + } catch (PasswordlessTokenException $ex) { |
|
107 | + $this->logger->debug('could not get login credentials because the token has no password', ['app' => 'core']); |
|
108 | + $trySession = true; |
|
109 | + } |
|
110 | + |
|
111 | + if ($trySession && $this->session->exists('login_credentials')) { |
|
112 | + $creds = json_decode($this->session->get('login_credentials')); |
|
113 | + return new Credentials($creds->uid, $creds->uid, $creds->password); |
|
114 | + } |
|
115 | + |
|
116 | + // If we reach this line, an exception was thrown. |
|
117 | + throw new CredentialsUnavailableException(); |
|
118 | + } |
|
119 | 119 | |
120 | 120 | } |
@@ -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 |
@@ -30,134 +30,134 @@ |
||
30 | 30 | |
31 | 31 | class DefaultTokenMapper extends Mapper { |
32 | 32 | |
33 | - public function __construct(IDBConnection $db) { |
|
34 | - parent::__construct($db, 'authtoken'); |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * Invalidate (delete) a given token |
|
39 | - * |
|
40 | - * @param string $token |
|
41 | - */ |
|
42 | - public function invalidate($token) { |
|
43 | - /* @var $qb IQueryBuilder */ |
|
44 | - $qb = $this->db->getQueryBuilder(); |
|
45 | - $qb->delete('authtoken') |
|
46 | - ->where($qb->expr()->eq('token', $qb->createParameter('token'))) |
|
47 | - ->setParameter('token', $token) |
|
48 | - ->execute(); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * @param int $olderThan |
|
53 | - * @param int $remember |
|
54 | - */ |
|
55 | - public function invalidateOld($olderThan, $remember = IToken::DO_NOT_REMEMBER) { |
|
56 | - /* @var $qb IQueryBuilder */ |
|
57 | - $qb = $this->db->getQueryBuilder(); |
|
58 | - $qb->delete('authtoken') |
|
59 | - ->where($qb->expr()->lt('last_activity', $qb->createNamedParameter($olderThan, IQueryBuilder::PARAM_INT))) |
|
60 | - ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter(IToken::TEMPORARY_TOKEN, IQueryBuilder::PARAM_INT))) |
|
61 | - ->andWhere($qb->expr()->eq('remember', $qb->createNamedParameter($remember, IQueryBuilder::PARAM_INT))) |
|
62 | - ->execute(); |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * Get the user UID for the given token |
|
67 | - * |
|
68 | - * @param string $token |
|
69 | - * @throws DoesNotExistException |
|
70 | - * @return DefaultToken |
|
71 | - */ |
|
72 | - public function getToken($token) { |
|
73 | - /* @var $qb IQueryBuilder */ |
|
74 | - $qb = $this->db->getQueryBuilder(); |
|
75 | - $result = $qb->select('id', 'uid', 'login_name', 'password', 'name', 'type', 'remember', 'token', 'last_activity', 'last_check', 'scope') |
|
76 | - ->from('authtoken') |
|
77 | - ->where($qb->expr()->eq('token', $qb->createNamedParameter($token))) |
|
78 | - ->execute(); |
|
79 | - |
|
80 | - $data = $result->fetch(); |
|
81 | - $result->closeCursor(); |
|
82 | - if ($data === false) { |
|
83 | - throw new DoesNotExistException('token does not exist'); |
|
84 | - } |
|
85 | - return DefaultToken::fromRow($data); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Get the token for $id |
|
90 | - * |
|
91 | - * @param string $id |
|
92 | - * @throws DoesNotExistException |
|
93 | - * @return DefaultToken |
|
94 | - */ |
|
95 | - public function getTokenById($id) { |
|
96 | - /* @var $qb IQueryBuilder */ |
|
97 | - $qb = $this->db->getQueryBuilder(); |
|
98 | - $result = $qb->select('id', 'uid', 'login_name', 'password', 'name', 'type', 'token', 'last_activity', 'last_check', 'scope') |
|
99 | - ->from('authtoken') |
|
100 | - ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) |
|
101 | - ->execute(); |
|
102 | - |
|
103 | - $data = $result->fetch(); |
|
104 | - $result->closeCursor(); |
|
105 | - if ($data === false) { |
|
106 | - throw new DoesNotExistException('token does not exist'); |
|
107 | - } |
|
108 | - return DefaultToken::fromRow($data); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Get all tokens of a user |
|
113 | - * |
|
114 | - * The provider may limit the number of result rows in case of an abuse |
|
115 | - * where a high number of (session) tokens is generated |
|
116 | - * |
|
117 | - * @param IUser $user |
|
118 | - * @return DefaultToken[] |
|
119 | - */ |
|
120 | - public function getTokenByUser(IUser $user) { |
|
121 | - /* @var $qb IQueryBuilder */ |
|
122 | - $qb = $this->db->getQueryBuilder(); |
|
123 | - $qb->select('id', 'uid', 'login_name', 'password', 'name', 'type', 'remember', 'token', 'last_activity', 'last_check', 'scope') |
|
124 | - ->from('authtoken') |
|
125 | - ->where($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID()))) |
|
126 | - ->setMaxResults(1000); |
|
127 | - $result = $qb->execute(); |
|
128 | - $data = $result->fetchAll(); |
|
129 | - $result->closeCursor(); |
|
130 | - |
|
131 | - $entities = array_map(function ($row) { |
|
132 | - return DefaultToken::fromRow($row); |
|
133 | - }, $data); |
|
134 | - |
|
135 | - return $entities; |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * @param IUser $user |
|
140 | - * @param int $id |
|
141 | - */ |
|
142 | - public function deleteById(IUser $user, $id) { |
|
143 | - /* @var $qb IQueryBuilder */ |
|
144 | - $qb = $this->db->getQueryBuilder(); |
|
145 | - $qb->delete('authtoken') |
|
146 | - ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) |
|
147 | - ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID()))); |
|
148 | - $qb->execute(); |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * delete all auth token which belong to a specific client if the client was deleted |
|
153 | - * |
|
154 | - * @param string $name |
|
155 | - */ |
|
156 | - public function deleteByName($name) { |
|
157 | - $qb = $this->db->getQueryBuilder(); |
|
158 | - $qb->delete('authtoken') |
|
159 | - ->where($qb->expr()->eq('name', $qb->createNamedParameter($name), IQueryBuilder::PARAM_STR)); |
|
160 | - $qb->execute(); |
|
161 | - } |
|
33 | + public function __construct(IDBConnection $db) { |
|
34 | + parent::__construct($db, 'authtoken'); |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * Invalidate (delete) a given token |
|
39 | + * |
|
40 | + * @param string $token |
|
41 | + */ |
|
42 | + public function invalidate($token) { |
|
43 | + /* @var $qb IQueryBuilder */ |
|
44 | + $qb = $this->db->getQueryBuilder(); |
|
45 | + $qb->delete('authtoken') |
|
46 | + ->where($qb->expr()->eq('token', $qb->createParameter('token'))) |
|
47 | + ->setParameter('token', $token) |
|
48 | + ->execute(); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * @param int $olderThan |
|
53 | + * @param int $remember |
|
54 | + */ |
|
55 | + public function invalidateOld($olderThan, $remember = IToken::DO_NOT_REMEMBER) { |
|
56 | + /* @var $qb IQueryBuilder */ |
|
57 | + $qb = $this->db->getQueryBuilder(); |
|
58 | + $qb->delete('authtoken') |
|
59 | + ->where($qb->expr()->lt('last_activity', $qb->createNamedParameter($olderThan, IQueryBuilder::PARAM_INT))) |
|
60 | + ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter(IToken::TEMPORARY_TOKEN, IQueryBuilder::PARAM_INT))) |
|
61 | + ->andWhere($qb->expr()->eq('remember', $qb->createNamedParameter($remember, IQueryBuilder::PARAM_INT))) |
|
62 | + ->execute(); |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * Get the user UID for the given token |
|
67 | + * |
|
68 | + * @param string $token |
|
69 | + * @throws DoesNotExistException |
|
70 | + * @return DefaultToken |
|
71 | + */ |
|
72 | + public function getToken($token) { |
|
73 | + /* @var $qb IQueryBuilder */ |
|
74 | + $qb = $this->db->getQueryBuilder(); |
|
75 | + $result = $qb->select('id', 'uid', 'login_name', 'password', 'name', 'type', 'remember', 'token', 'last_activity', 'last_check', 'scope') |
|
76 | + ->from('authtoken') |
|
77 | + ->where($qb->expr()->eq('token', $qb->createNamedParameter($token))) |
|
78 | + ->execute(); |
|
79 | + |
|
80 | + $data = $result->fetch(); |
|
81 | + $result->closeCursor(); |
|
82 | + if ($data === false) { |
|
83 | + throw new DoesNotExistException('token does not exist'); |
|
84 | + } |
|
85 | + return DefaultToken::fromRow($data); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Get the token for $id |
|
90 | + * |
|
91 | + * @param string $id |
|
92 | + * @throws DoesNotExistException |
|
93 | + * @return DefaultToken |
|
94 | + */ |
|
95 | + public function getTokenById($id) { |
|
96 | + /* @var $qb IQueryBuilder */ |
|
97 | + $qb = $this->db->getQueryBuilder(); |
|
98 | + $result = $qb->select('id', 'uid', 'login_name', 'password', 'name', 'type', 'token', 'last_activity', 'last_check', 'scope') |
|
99 | + ->from('authtoken') |
|
100 | + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) |
|
101 | + ->execute(); |
|
102 | + |
|
103 | + $data = $result->fetch(); |
|
104 | + $result->closeCursor(); |
|
105 | + if ($data === false) { |
|
106 | + throw new DoesNotExistException('token does not exist'); |
|
107 | + } |
|
108 | + return DefaultToken::fromRow($data); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Get all tokens of a user |
|
113 | + * |
|
114 | + * The provider may limit the number of result rows in case of an abuse |
|
115 | + * where a high number of (session) tokens is generated |
|
116 | + * |
|
117 | + * @param IUser $user |
|
118 | + * @return DefaultToken[] |
|
119 | + */ |
|
120 | + public function getTokenByUser(IUser $user) { |
|
121 | + /* @var $qb IQueryBuilder */ |
|
122 | + $qb = $this->db->getQueryBuilder(); |
|
123 | + $qb->select('id', 'uid', 'login_name', 'password', 'name', 'type', 'remember', 'token', 'last_activity', 'last_check', 'scope') |
|
124 | + ->from('authtoken') |
|
125 | + ->where($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID()))) |
|
126 | + ->setMaxResults(1000); |
|
127 | + $result = $qb->execute(); |
|
128 | + $data = $result->fetchAll(); |
|
129 | + $result->closeCursor(); |
|
130 | + |
|
131 | + $entities = array_map(function ($row) { |
|
132 | + return DefaultToken::fromRow($row); |
|
133 | + }, $data); |
|
134 | + |
|
135 | + return $entities; |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * @param IUser $user |
|
140 | + * @param int $id |
|
141 | + */ |
|
142 | + public function deleteById(IUser $user, $id) { |
|
143 | + /* @var $qb IQueryBuilder */ |
|
144 | + $qb = $this->db->getQueryBuilder(); |
|
145 | + $qb->delete('authtoken') |
|
146 | + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) |
|
147 | + ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID()))); |
|
148 | + $qb->execute(); |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * delete all auth token which belong to a specific client if the client was deleted |
|
153 | + * |
|
154 | + * @param string $name |
|
155 | + */ |
|
156 | + public function deleteByName($name) { |
|
157 | + $qb = $this->db->getQueryBuilder(); |
|
158 | + $qb->delete('authtoken') |
|
159 | + ->where($qb->expr()->eq('name', $qb->createNamedParameter($name), IQueryBuilder::PARAM_STR)); |
|
160 | + $qb->execute(); |
|
161 | + } |
|
162 | 162 | |
163 | 163 | } |
@@ -42,135 +42,135 @@ |
||
42 | 42 | */ |
43 | 43 | class DefaultToken extends Entity implements IToken { |
44 | 44 | |
45 | - /** |
|
46 | - * @var string user UID |
|
47 | - */ |
|
48 | - protected $uid; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var string login name used for generating the token |
|
52 | - */ |
|
53 | - protected $loginName; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var string encrypted user password |
|
57 | - */ |
|
58 | - protected $password; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var string token name (e.g. browser/OS) |
|
62 | - */ |
|
63 | - protected $name; |
|
64 | - |
|
65 | - /** |
|
66 | - * @var string |
|
67 | - */ |
|
68 | - protected $token; |
|
69 | - |
|
70 | - /** |
|
71 | - * @var int |
|
72 | - */ |
|
73 | - protected $type; |
|
74 | - |
|
75 | - /** |
|
76 | - * @var int |
|
77 | - */ |
|
78 | - protected $remember; |
|
79 | - |
|
80 | - /** |
|
81 | - * @var int |
|
82 | - */ |
|
83 | - protected $lastActivity; |
|
84 | - |
|
85 | - /** |
|
86 | - * @var int |
|
87 | - */ |
|
88 | - protected $lastCheck; |
|
89 | - |
|
90 | - /** |
|
91 | - * @var string |
|
92 | - */ |
|
93 | - protected $scope; |
|
94 | - |
|
95 | - public function __construct() { |
|
96 | - $this->addType('type', 'int'); |
|
97 | - $this->addType('lastActivity', 'int'); |
|
98 | - $this->addType('lastCheck', 'int'); |
|
99 | - } |
|
100 | - |
|
101 | - public function getId() { |
|
102 | - return $this->id; |
|
103 | - } |
|
104 | - |
|
105 | - public function getUID() { |
|
106 | - return $this->uid; |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Get the login name used when generating the token |
|
111 | - * |
|
112 | - * @return string |
|
113 | - */ |
|
114 | - public function getLoginName() { |
|
115 | - return parent::getLoginName(); |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * Get the (encrypted) login password |
|
120 | - * |
|
121 | - * @return string |
|
122 | - */ |
|
123 | - public function getPassword() { |
|
124 | - return parent::getPassword(); |
|
125 | - } |
|
126 | - |
|
127 | - public function jsonSerialize() { |
|
128 | - return [ |
|
129 | - 'id' => $this->id, |
|
130 | - 'name' => $this->name, |
|
131 | - 'lastActivity' => $this->lastActivity, |
|
132 | - 'type' => $this->type, |
|
133 | - 'scope' => $this->getScopeAsArray() |
|
134 | - ]; |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * Get the timestamp of the last password check |
|
139 | - * |
|
140 | - * @return int |
|
141 | - */ |
|
142 | - public function getLastCheck() { |
|
143 | - return parent::getLastCheck(); |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * Get the timestamp of the last password check |
|
148 | - * |
|
149 | - * @param int $time |
|
150 | - */ |
|
151 | - public function setLastCheck($time) { |
|
152 | - return parent::setLastCheck($time); |
|
153 | - } |
|
154 | - |
|
155 | - public function getScope() { |
|
156 | - return parent::getScope(); |
|
157 | - } |
|
158 | - |
|
159 | - public function getScopeAsArray() { |
|
160 | - $scope = json_decode($this->getScope(), true); |
|
161 | - if (!$scope) { |
|
162 | - return [ |
|
163 | - 'filesystem'=> true |
|
164 | - ]; |
|
165 | - } |
|
166 | - return $scope; |
|
167 | - } |
|
168 | - |
|
169 | - public function setScope($scope) { |
|
170 | - if (is_array($scope)) { |
|
171 | - parent::setScope(json_encode($scope)); |
|
172 | - } else { |
|
173 | - parent::setScope((string)$scope); |
|
174 | - } |
|
175 | - } |
|
45 | + /** |
|
46 | + * @var string user UID |
|
47 | + */ |
|
48 | + protected $uid; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var string login name used for generating the token |
|
52 | + */ |
|
53 | + protected $loginName; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var string encrypted user password |
|
57 | + */ |
|
58 | + protected $password; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var string token name (e.g. browser/OS) |
|
62 | + */ |
|
63 | + protected $name; |
|
64 | + |
|
65 | + /** |
|
66 | + * @var string |
|
67 | + */ |
|
68 | + protected $token; |
|
69 | + |
|
70 | + /** |
|
71 | + * @var int |
|
72 | + */ |
|
73 | + protected $type; |
|
74 | + |
|
75 | + /** |
|
76 | + * @var int |
|
77 | + */ |
|
78 | + protected $remember; |
|
79 | + |
|
80 | + /** |
|
81 | + * @var int |
|
82 | + */ |
|
83 | + protected $lastActivity; |
|
84 | + |
|
85 | + /** |
|
86 | + * @var int |
|
87 | + */ |
|
88 | + protected $lastCheck; |
|
89 | + |
|
90 | + /** |
|
91 | + * @var string |
|
92 | + */ |
|
93 | + protected $scope; |
|
94 | + |
|
95 | + public function __construct() { |
|
96 | + $this->addType('type', 'int'); |
|
97 | + $this->addType('lastActivity', 'int'); |
|
98 | + $this->addType('lastCheck', 'int'); |
|
99 | + } |
|
100 | + |
|
101 | + public function getId() { |
|
102 | + return $this->id; |
|
103 | + } |
|
104 | + |
|
105 | + public function getUID() { |
|
106 | + return $this->uid; |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Get the login name used when generating the token |
|
111 | + * |
|
112 | + * @return string |
|
113 | + */ |
|
114 | + public function getLoginName() { |
|
115 | + return parent::getLoginName(); |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * Get the (encrypted) login password |
|
120 | + * |
|
121 | + * @return string |
|
122 | + */ |
|
123 | + public function getPassword() { |
|
124 | + return parent::getPassword(); |
|
125 | + } |
|
126 | + |
|
127 | + public function jsonSerialize() { |
|
128 | + return [ |
|
129 | + 'id' => $this->id, |
|
130 | + 'name' => $this->name, |
|
131 | + 'lastActivity' => $this->lastActivity, |
|
132 | + 'type' => $this->type, |
|
133 | + 'scope' => $this->getScopeAsArray() |
|
134 | + ]; |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * Get the timestamp of the last password check |
|
139 | + * |
|
140 | + * @return int |
|
141 | + */ |
|
142 | + public function getLastCheck() { |
|
143 | + return parent::getLastCheck(); |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * Get the timestamp of the last password check |
|
148 | + * |
|
149 | + * @param int $time |
|
150 | + */ |
|
151 | + public function setLastCheck($time) { |
|
152 | + return parent::setLastCheck($time); |
|
153 | + } |
|
154 | + |
|
155 | + public function getScope() { |
|
156 | + return parent::getScope(); |
|
157 | + } |
|
158 | + |
|
159 | + public function getScopeAsArray() { |
|
160 | + $scope = json_decode($this->getScope(), true); |
|
161 | + if (!$scope) { |
|
162 | + return [ |
|
163 | + 'filesystem'=> true |
|
164 | + ]; |
|
165 | + } |
|
166 | + return $scope; |
|
167 | + } |
|
168 | + |
|
169 | + public function setScope($scope) { |
|
170 | + if (is_array($scope)) { |
|
171 | + parent::setScope(json_encode($scope)); |
|
172 | + } else { |
|
173 | + parent::setScope((string)$scope); |
|
174 | + } |
|
175 | + } |
|
176 | 176 | } |
@@ -170,7 +170,7 @@ |
||
170 | 170 | if (is_array($scope)) { |
171 | 171 | parent::setScope(json_encode($scope)); |
172 | 172 | } else { |
173 | - parent::setScope((string)$scope); |
|
173 | + parent::setScope((string) $scope); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | } |
@@ -26,71 +26,71 @@ |
||
26 | 26 | |
27 | 27 | interface IToken extends JsonSerializable { |
28 | 28 | |
29 | - const TEMPORARY_TOKEN = 0; |
|
30 | - const PERMANENT_TOKEN = 1; |
|
31 | - const DO_NOT_REMEMBER = 0; |
|
32 | - const REMEMBER = 1; |
|
29 | + const TEMPORARY_TOKEN = 0; |
|
30 | + const PERMANENT_TOKEN = 1; |
|
31 | + const DO_NOT_REMEMBER = 0; |
|
32 | + const REMEMBER = 1; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Get the token ID |
|
36 | - * |
|
37 | - * @return int |
|
38 | - */ |
|
39 | - public function getId(); |
|
34 | + /** |
|
35 | + * Get the token ID |
|
36 | + * |
|
37 | + * @return int |
|
38 | + */ |
|
39 | + public function getId(); |
|
40 | 40 | |
41 | - /** |
|
42 | - * Get the user UID |
|
43 | - * |
|
44 | - * @return string |
|
45 | - */ |
|
46 | - public function getUID(); |
|
41 | + /** |
|
42 | + * Get the user UID |
|
43 | + * |
|
44 | + * @return string |
|
45 | + */ |
|
46 | + public function getUID(); |
|
47 | 47 | |
48 | - /** |
|
49 | - * Get the login name used when generating the token |
|
50 | - * |
|
51 | - * @return string |
|
52 | - */ |
|
53 | - public function getLoginName(); |
|
48 | + /** |
|
49 | + * Get the login name used when generating the token |
|
50 | + * |
|
51 | + * @return string |
|
52 | + */ |
|
53 | + public function getLoginName(); |
|
54 | 54 | |
55 | - /** |
|
56 | - * Get the (encrypted) login password |
|
57 | - * |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function getPassword(); |
|
55 | + /** |
|
56 | + * Get the (encrypted) login password |
|
57 | + * |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function getPassword(); |
|
61 | 61 | |
62 | - /** |
|
63 | - * Get the timestamp of the last password check |
|
64 | - * |
|
65 | - * @return int |
|
66 | - */ |
|
67 | - public function getLastCheck(); |
|
62 | + /** |
|
63 | + * Get the timestamp of the last password check |
|
64 | + * |
|
65 | + * @return int |
|
66 | + */ |
|
67 | + public function getLastCheck(); |
|
68 | 68 | |
69 | - /** |
|
70 | - * Set the timestamp of the last password check |
|
71 | - * |
|
72 | - * @param int $time |
|
73 | - */ |
|
74 | - public function setLastCheck($time); |
|
69 | + /** |
|
70 | + * Set the timestamp of the last password check |
|
71 | + * |
|
72 | + * @param int $time |
|
73 | + */ |
|
74 | + public function setLastCheck($time); |
|
75 | 75 | |
76 | - /** |
|
77 | - * Get the authentication scope for this token |
|
78 | - * |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function getScope(); |
|
76 | + /** |
|
77 | + * Get the authentication scope for this token |
|
78 | + * |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function getScope(); |
|
82 | 82 | |
83 | - /** |
|
84 | - * Get the authentication scope for this token |
|
85 | - * |
|
86 | - * @return array |
|
87 | - */ |
|
88 | - public function getScopeAsArray(); |
|
83 | + /** |
|
84 | + * Get the authentication scope for this token |
|
85 | + * |
|
86 | + * @return array |
|
87 | + */ |
|
88 | + public function getScopeAsArray(); |
|
89 | 89 | |
90 | - /** |
|
91 | - * Set the authentication scope for this token |
|
92 | - * |
|
93 | - * @param array $scope |
|
94 | - */ |
|
95 | - public function setScope($scope); |
|
90 | + /** |
|
91 | + * Set the authentication scope for this token |
|
92 | + * |
|
93 | + * @param array $scope |
|
94 | + */ |
|
95 | + public function setScope($scope); |
|
96 | 96 | } |