@@ -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 PublicKeyToken::fromRow($row); |
134 | 134 | }, $data); |
135 | 135 |
@@ -36,197 +36,197 @@ |
||
36 | 36 | * @template-extends QBMapper<PublicKeyToken> |
37 | 37 | */ |
38 | 38 | class PublicKeyTokenMapper extends QBMapper { |
39 | - public function __construct(IDBConnection $db) { |
|
40 | - parent::__construct($db, 'authtoken'); |
|
41 | - } |
|
42 | - |
|
43 | - /** |
|
44 | - * Invalidate (delete) a given token |
|
45 | - * |
|
46 | - * @param string $token |
|
47 | - */ |
|
48 | - public function invalidate(string $token) { |
|
49 | - /* @var $qb IQueryBuilder */ |
|
50 | - $qb = $this->db->getQueryBuilder(); |
|
51 | - $qb->delete($this->tableName) |
|
52 | - ->where($qb->expr()->eq('token', $qb->createNamedParameter($token))) |
|
53 | - ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
54 | - ->execute(); |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @param int $olderThan |
|
59 | - * @param int $remember |
|
60 | - */ |
|
61 | - public function invalidateOld(int $olderThan, int $remember = IToken::DO_NOT_REMEMBER) { |
|
62 | - /* @var $qb IQueryBuilder */ |
|
63 | - $qb = $this->db->getQueryBuilder(); |
|
64 | - $qb->delete($this->tableName) |
|
65 | - ->where($qb->expr()->lt('last_activity', $qb->createNamedParameter($olderThan, IQueryBuilder::PARAM_INT))) |
|
66 | - ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter(IToken::TEMPORARY_TOKEN, IQueryBuilder::PARAM_INT))) |
|
67 | - ->andWhere($qb->expr()->eq('remember', $qb->createNamedParameter($remember, IQueryBuilder::PARAM_INT))) |
|
68 | - ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
69 | - ->execute(); |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * Get the user UID for the given token |
|
74 | - * |
|
75 | - * @throws DoesNotExistException |
|
76 | - */ |
|
77 | - public function getToken(string $token): PublicKeyToken { |
|
78 | - /* @var $qb IQueryBuilder */ |
|
79 | - $qb = $this->db->getQueryBuilder(); |
|
80 | - $result = $qb->select('*') |
|
81 | - ->from($this->tableName) |
|
82 | - ->where($qb->expr()->eq('token', $qb->createNamedParameter($token))) |
|
83 | - ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
84 | - ->execute(); |
|
85 | - |
|
86 | - $data = $result->fetch(); |
|
87 | - $result->closeCursor(); |
|
88 | - if ($data === false) { |
|
89 | - throw new DoesNotExistException('token does not exist'); |
|
90 | - } |
|
91 | - return PublicKeyToken::fromRow($data); |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Get the token for $id |
|
96 | - * |
|
97 | - * @throws DoesNotExistException |
|
98 | - */ |
|
99 | - public function getTokenById(int $id): PublicKeyToken { |
|
100 | - /* @var $qb IQueryBuilder */ |
|
101 | - $qb = $this->db->getQueryBuilder(); |
|
102 | - $result = $qb->select('*') |
|
103 | - ->from($this->tableName) |
|
104 | - ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) |
|
105 | - ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
106 | - ->execute(); |
|
107 | - |
|
108 | - $data = $result->fetch(); |
|
109 | - $result->closeCursor(); |
|
110 | - if ($data === false) { |
|
111 | - throw new DoesNotExistException('token does not exist'); |
|
112 | - } |
|
113 | - return PublicKeyToken::fromRow($data); |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Get all tokens of a user |
|
118 | - * |
|
119 | - * The provider may limit the number of result rows in case of an abuse |
|
120 | - * where a high number of (session) tokens is generated |
|
121 | - * |
|
122 | - * @param string $uid |
|
123 | - * @return PublicKeyToken[] |
|
124 | - */ |
|
125 | - public function getTokenByUser(string $uid): array { |
|
126 | - /* @var $qb IQueryBuilder */ |
|
127 | - $qb = $this->db->getQueryBuilder(); |
|
128 | - $qb->select('*') |
|
129 | - ->from($this->tableName) |
|
130 | - ->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid))) |
|
131 | - ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
132 | - ->setMaxResults(1000); |
|
133 | - $result = $qb->execute(); |
|
134 | - $data = $result->fetchAll(); |
|
135 | - $result->closeCursor(); |
|
136 | - |
|
137 | - $entities = array_map(function ($row) { |
|
138 | - return PublicKeyToken::fromRow($row); |
|
139 | - }, $data); |
|
140 | - |
|
141 | - return $entities; |
|
142 | - } |
|
143 | - |
|
144 | - public function deleteById(string $uid, int $id) { |
|
145 | - /* @var $qb IQueryBuilder */ |
|
146 | - $qb = $this->db->getQueryBuilder(); |
|
147 | - $qb->delete($this->tableName) |
|
148 | - ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) |
|
149 | - ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($uid))) |
|
150 | - ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))); |
|
151 | - $qb->execute(); |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * delete all auth token which belong to a specific client if the client was deleted |
|
156 | - * |
|
157 | - * @param string $name |
|
158 | - */ |
|
159 | - public function deleteByName(string $name) { |
|
160 | - $qb = $this->db->getQueryBuilder(); |
|
161 | - $qb->delete($this->tableName) |
|
162 | - ->where($qb->expr()->eq('name', $qb->createNamedParameter($name), IQueryBuilder::PARAM_STR)) |
|
163 | - ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))); |
|
164 | - $qb->execute(); |
|
165 | - } |
|
166 | - |
|
167 | - public function deleteTempToken(PublicKeyToken $except) { |
|
168 | - $qb = $this->db->getQueryBuilder(); |
|
169 | - |
|
170 | - $qb->delete($this->tableName) |
|
171 | - ->where($qb->expr()->eq('uid', $qb->createNamedParameter($except->getUID()))) |
|
172 | - ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter(IToken::TEMPORARY_TOKEN))) |
|
173 | - ->andWhere($qb->expr()->neq('id', $qb->createNamedParameter($except->getId()))) |
|
174 | - ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))); |
|
175 | - |
|
176 | - $qb->execute(); |
|
177 | - } |
|
178 | - |
|
179 | - public function hasExpiredTokens(string $uid): bool { |
|
180 | - $qb = $this->db->getQueryBuilder(); |
|
181 | - $qb->select('*') |
|
182 | - ->from($this->tableName) |
|
183 | - ->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid))) |
|
184 | - ->andWhere($qb->expr()->eq('password_invalid', $qb->createNamedParameter(true), IQueryBuilder::PARAM_BOOL)) |
|
185 | - ->setMaxResults(1); |
|
186 | - |
|
187 | - $cursor = $qb->execute(); |
|
188 | - $data = $cursor->fetchAll(); |
|
189 | - $cursor->closeCursor(); |
|
190 | - |
|
191 | - return count($data) === 1; |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * Update the last activity timestamp |
|
196 | - * |
|
197 | - * In highly concurrent setups it can happen that two parallel processes |
|
198 | - * trigger the update at (nearly) the same time. In that special case it's |
|
199 | - * not necessary to hit the database with two actual updates. Therefore the |
|
200 | - * target last activity is included in the WHERE clause with a few seconds |
|
201 | - * of tolerance. |
|
202 | - * |
|
203 | - * Example: |
|
204 | - * - process 1 (P1) reads the token at timestamp 1500 |
|
205 | - * - process 1 (P2) reads the token at timestamp 1501 |
|
206 | - * - activity update interval is 100 |
|
207 | - * |
|
208 | - * This means |
|
209 | - * |
|
210 | - * - P1 will see a last_activity smaller than the current time and update |
|
211 | - * the token row |
|
212 | - * - If P2 reads after P1 had written, it will see 1600 as last activity |
|
213 | - * and the comparison on last_activity won't be truthy. This means no rows |
|
214 | - * need to be updated a second time |
|
215 | - * - If P2 reads before P1 had written, it will see 1501 as last activity, |
|
216 | - * but the comparison on last_activity will still not be truthy and the |
|
217 | - * token row is not updated a second time |
|
218 | - * |
|
219 | - * @param IToken $token |
|
220 | - * @param int $now |
|
221 | - */ |
|
222 | - public function updateActivity(IToken $token, int $now): void { |
|
223 | - $qb = $this->db->getQueryBuilder(); |
|
224 | - $update = $qb->update($this->getTableName()) |
|
225 | - ->set('last_activity', $qb->createNamedParameter($now, IQueryBuilder::PARAM_INT)) |
|
226 | - ->where( |
|
227 | - $qb->expr()->eq('id', $qb->createNamedParameter($token->getId(), IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT), |
|
228 | - $qb->expr()->lt('last_activity', $qb->createNamedParameter($now - 15, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT) |
|
229 | - ); |
|
230 | - $update->executeStatement(); |
|
231 | - } |
|
39 | + public function __construct(IDBConnection $db) { |
|
40 | + parent::__construct($db, 'authtoken'); |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * Invalidate (delete) a given token |
|
45 | + * |
|
46 | + * @param string $token |
|
47 | + */ |
|
48 | + public function invalidate(string $token) { |
|
49 | + /* @var $qb IQueryBuilder */ |
|
50 | + $qb = $this->db->getQueryBuilder(); |
|
51 | + $qb->delete($this->tableName) |
|
52 | + ->where($qb->expr()->eq('token', $qb->createNamedParameter($token))) |
|
53 | + ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
54 | + ->execute(); |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @param int $olderThan |
|
59 | + * @param int $remember |
|
60 | + */ |
|
61 | + public function invalidateOld(int $olderThan, int $remember = IToken::DO_NOT_REMEMBER) { |
|
62 | + /* @var $qb IQueryBuilder */ |
|
63 | + $qb = $this->db->getQueryBuilder(); |
|
64 | + $qb->delete($this->tableName) |
|
65 | + ->where($qb->expr()->lt('last_activity', $qb->createNamedParameter($olderThan, IQueryBuilder::PARAM_INT))) |
|
66 | + ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter(IToken::TEMPORARY_TOKEN, IQueryBuilder::PARAM_INT))) |
|
67 | + ->andWhere($qb->expr()->eq('remember', $qb->createNamedParameter($remember, IQueryBuilder::PARAM_INT))) |
|
68 | + ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
69 | + ->execute(); |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * Get the user UID for the given token |
|
74 | + * |
|
75 | + * @throws DoesNotExistException |
|
76 | + */ |
|
77 | + public function getToken(string $token): PublicKeyToken { |
|
78 | + /* @var $qb IQueryBuilder */ |
|
79 | + $qb = $this->db->getQueryBuilder(); |
|
80 | + $result = $qb->select('*') |
|
81 | + ->from($this->tableName) |
|
82 | + ->where($qb->expr()->eq('token', $qb->createNamedParameter($token))) |
|
83 | + ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
84 | + ->execute(); |
|
85 | + |
|
86 | + $data = $result->fetch(); |
|
87 | + $result->closeCursor(); |
|
88 | + if ($data === false) { |
|
89 | + throw new DoesNotExistException('token does not exist'); |
|
90 | + } |
|
91 | + return PublicKeyToken::fromRow($data); |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Get the token for $id |
|
96 | + * |
|
97 | + * @throws DoesNotExistException |
|
98 | + */ |
|
99 | + public function getTokenById(int $id): PublicKeyToken { |
|
100 | + /* @var $qb IQueryBuilder */ |
|
101 | + $qb = $this->db->getQueryBuilder(); |
|
102 | + $result = $qb->select('*') |
|
103 | + ->from($this->tableName) |
|
104 | + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) |
|
105 | + ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
106 | + ->execute(); |
|
107 | + |
|
108 | + $data = $result->fetch(); |
|
109 | + $result->closeCursor(); |
|
110 | + if ($data === false) { |
|
111 | + throw new DoesNotExistException('token does not exist'); |
|
112 | + } |
|
113 | + return PublicKeyToken::fromRow($data); |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Get all tokens of a user |
|
118 | + * |
|
119 | + * The provider may limit the number of result rows in case of an abuse |
|
120 | + * where a high number of (session) tokens is generated |
|
121 | + * |
|
122 | + * @param string $uid |
|
123 | + * @return PublicKeyToken[] |
|
124 | + */ |
|
125 | + public function getTokenByUser(string $uid): array { |
|
126 | + /* @var $qb IQueryBuilder */ |
|
127 | + $qb = $this->db->getQueryBuilder(); |
|
128 | + $qb->select('*') |
|
129 | + ->from($this->tableName) |
|
130 | + ->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid))) |
|
131 | + ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))) |
|
132 | + ->setMaxResults(1000); |
|
133 | + $result = $qb->execute(); |
|
134 | + $data = $result->fetchAll(); |
|
135 | + $result->closeCursor(); |
|
136 | + |
|
137 | + $entities = array_map(function ($row) { |
|
138 | + return PublicKeyToken::fromRow($row); |
|
139 | + }, $data); |
|
140 | + |
|
141 | + return $entities; |
|
142 | + } |
|
143 | + |
|
144 | + public function deleteById(string $uid, int $id) { |
|
145 | + /* @var $qb IQueryBuilder */ |
|
146 | + $qb = $this->db->getQueryBuilder(); |
|
147 | + $qb->delete($this->tableName) |
|
148 | + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) |
|
149 | + ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($uid))) |
|
150 | + ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))); |
|
151 | + $qb->execute(); |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * delete all auth token which belong to a specific client if the client was deleted |
|
156 | + * |
|
157 | + * @param string $name |
|
158 | + */ |
|
159 | + public function deleteByName(string $name) { |
|
160 | + $qb = $this->db->getQueryBuilder(); |
|
161 | + $qb->delete($this->tableName) |
|
162 | + ->where($qb->expr()->eq('name', $qb->createNamedParameter($name), IQueryBuilder::PARAM_STR)) |
|
163 | + ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))); |
|
164 | + $qb->execute(); |
|
165 | + } |
|
166 | + |
|
167 | + public function deleteTempToken(PublicKeyToken $except) { |
|
168 | + $qb = $this->db->getQueryBuilder(); |
|
169 | + |
|
170 | + $qb->delete($this->tableName) |
|
171 | + ->where($qb->expr()->eq('uid', $qb->createNamedParameter($except->getUID()))) |
|
172 | + ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter(IToken::TEMPORARY_TOKEN))) |
|
173 | + ->andWhere($qb->expr()->neq('id', $qb->createNamedParameter($except->getId()))) |
|
174 | + ->andWhere($qb->expr()->eq('version', $qb->createNamedParameter(PublicKeyToken::VERSION, IQueryBuilder::PARAM_INT))); |
|
175 | + |
|
176 | + $qb->execute(); |
|
177 | + } |
|
178 | + |
|
179 | + public function hasExpiredTokens(string $uid): bool { |
|
180 | + $qb = $this->db->getQueryBuilder(); |
|
181 | + $qb->select('*') |
|
182 | + ->from($this->tableName) |
|
183 | + ->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid))) |
|
184 | + ->andWhere($qb->expr()->eq('password_invalid', $qb->createNamedParameter(true), IQueryBuilder::PARAM_BOOL)) |
|
185 | + ->setMaxResults(1); |
|
186 | + |
|
187 | + $cursor = $qb->execute(); |
|
188 | + $data = $cursor->fetchAll(); |
|
189 | + $cursor->closeCursor(); |
|
190 | + |
|
191 | + return count($data) === 1; |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * Update the last activity timestamp |
|
196 | + * |
|
197 | + * In highly concurrent setups it can happen that two parallel processes |
|
198 | + * trigger the update at (nearly) the same time. In that special case it's |
|
199 | + * not necessary to hit the database with two actual updates. Therefore the |
|
200 | + * target last activity is included in the WHERE clause with a few seconds |
|
201 | + * of tolerance. |
|
202 | + * |
|
203 | + * Example: |
|
204 | + * - process 1 (P1) reads the token at timestamp 1500 |
|
205 | + * - process 1 (P2) reads the token at timestamp 1501 |
|
206 | + * - activity update interval is 100 |
|
207 | + * |
|
208 | + * This means |
|
209 | + * |
|
210 | + * - P1 will see a last_activity smaller than the current time and update |
|
211 | + * the token row |
|
212 | + * - If P2 reads after P1 had written, it will see 1600 as last activity |
|
213 | + * and the comparison on last_activity won't be truthy. This means no rows |
|
214 | + * need to be updated a second time |
|
215 | + * - If P2 reads before P1 had written, it will see 1501 as last activity, |
|
216 | + * but the comparison on last_activity will still not be truthy and the |
|
217 | + * token row is not updated a second time |
|
218 | + * |
|
219 | + * @param IToken $token |
|
220 | + * @param int $now |
|
221 | + */ |
|
222 | + public function updateActivity(IToken $token, int $now): void { |
|
223 | + $qb = $this->db->getQueryBuilder(); |
|
224 | + $update = $qb->update($this->getTableName()) |
|
225 | + ->set('last_activity', $qb->createNamedParameter($now, IQueryBuilder::PARAM_INT)) |
|
226 | + ->where( |
|
227 | + $qb->expr()->eq('id', $qb->createNamedParameter($token->getId(), IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT), |
|
228 | + $qb->expr()->lt('last_activity', $qb->createNamedParameter($now - 15, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT) |
|
229 | + ); |
|
230 | + $update->executeStatement(); |
|
231 | + } |
|
232 | 232 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | $l = \OC::$server->getL10N('federation'); |
37 | 37 | $this->parameterList = $missingParameters; |
38 | 38 | $parameterList = implode(',', $missingParameters); |
39 | - $message = 'Parameters missing in order to complete the request. Missing Parameters: ' . $parameterList; |
|
39 | + $message = 'Parameters missing in order to complete the request. Missing Parameters: '.$parameterList; |
|
40 | 40 | $hint = $l->t('Parameters missing in order to complete the request. Missing Parameters: "%s"', [$parameterList]); |
41 | 41 | parent::__construct($message, $hint); |
42 | 42 | } |
@@ -32,45 +32,45 @@ |
||
32 | 32 | * @since 14.0.0 |
33 | 33 | */ |
34 | 34 | class BadRequestException extends HintException { |
35 | - private $parameterList; |
|
35 | + private $parameterList; |
|
36 | 36 | |
37 | - /** |
|
38 | - * BadRequestException constructor. |
|
39 | - * |
|
40 | - * @since 14.0.0 |
|
41 | - * |
|
42 | - * @param array $missingParameters |
|
43 | - */ |
|
44 | - public function __construct(array $missingParameters) { |
|
45 | - $l = \OC::$server->getL10N('federation'); |
|
46 | - $this->parameterList = $missingParameters; |
|
47 | - $parameterList = implode(',', $missingParameters); |
|
48 | - $message = 'Parameters missing in order to complete the request. Missing Parameters: ' . $parameterList; |
|
49 | - $hint = $l->t('Parameters missing in order to complete the request. Missing Parameters: "%s"', [$parameterList]); |
|
50 | - parent::__construct($message, $hint); |
|
51 | - } |
|
37 | + /** |
|
38 | + * BadRequestException constructor. |
|
39 | + * |
|
40 | + * @since 14.0.0 |
|
41 | + * |
|
42 | + * @param array $missingParameters |
|
43 | + */ |
|
44 | + public function __construct(array $missingParameters) { |
|
45 | + $l = \OC::$server->getL10N('federation'); |
|
46 | + $this->parameterList = $missingParameters; |
|
47 | + $parameterList = implode(',', $missingParameters); |
|
48 | + $message = 'Parameters missing in order to complete the request. Missing Parameters: ' . $parameterList; |
|
49 | + $hint = $l->t('Parameters missing in order to complete the request. Missing Parameters: "%s"', [$parameterList]); |
|
50 | + parent::__construct($message, $hint); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * get array with the return message as defined in the OCM API |
|
55 | - * |
|
56 | - * @since 14.0.0 |
|
57 | - * |
|
58 | - * @return array |
|
59 | - */ |
|
60 | - public function getReturnMessage() { |
|
61 | - $result = [ |
|
62 | - 'message' => 'RESOURCE_NOT_FOUND', |
|
63 | - 'validationErrors' => [ |
|
64 | - ] |
|
65 | - ]; |
|
53 | + /** |
|
54 | + * get array with the return message as defined in the OCM API |
|
55 | + * |
|
56 | + * @since 14.0.0 |
|
57 | + * |
|
58 | + * @return array |
|
59 | + */ |
|
60 | + public function getReturnMessage() { |
|
61 | + $result = [ |
|
62 | + 'message' => 'RESOURCE_NOT_FOUND', |
|
63 | + 'validationErrors' => [ |
|
64 | + ] |
|
65 | + ]; |
|
66 | 66 | |
67 | - foreach ($this->parameterList as $missingParameter) { |
|
68 | - $result['validationErrors'] = [ |
|
69 | - 'name' => $missingParameter, |
|
70 | - 'message' => 'NOT_FOUND' |
|
71 | - ]; |
|
72 | - } |
|
67 | + foreach ($this->parameterList as $missingParameter) { |
|
68 | + $result['validationErrors'] = [ |
|
69 | + 'name' => $missingParameter, |
|
70 | + 'message' => 'NOT_FOUND' |
|
71 | + ]; |
|
72 | + } |
|
73 | 73 | |
74 | - return $result; |
|
75 | - } |
|
74 | + return $result; |
|
75 | + } |
|
76 | 76 | } |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | private function getBlobClient() { |
60 | 60 | if (!$this->blobClient) { |
61 | 61 | $protocol = $this->endpoint ? substr($this->endpoint, 0, strpos($this->endpoint, ':')) : 'https'; |
62 | - $connectionString = "DefaultEndpointsProtocol=" . $protocol . ";AccountName=" . $this->accountName . ";AccountKey=" . $this->accountKey; |
|
62 | + $connectionString = "DefaultEndpointsProtocol=".$protocol.";AccountName=".$this->accountName.";AccountKey=".$this->accountKey; |
|
63 | 63 | if ($this->endpoint) { |
64 | - $connectionString .= ';BlobEndpoint=' . $this->endpoint; |
|
64 | + $connectionString .= ';BlobEndpoint='.$this->endpoint; |
|
65 | 65 | } |
66 | 66 | $this->blobClient = BlobRestProxy::createBlobService($connectionString); |
67 | 67 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @return string the container or bucket name where objects are stored |
77 | 77 | */ |
78 | 78 | public function getStorageId() { |
79 | - return 'azure::blob::' . $this->containerName; |
|
79 | + return 'azure::blob::'.$this->containerName; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -29,109 +29,109 @@ |
||
29 | 29 | use OCP\Files\ObjectStore\IObjectStore; |
30 | 30 | |
31 | 31 | class Azure implements IObjectStore { |
32 | - /** @var string */ |
|
33 | - private $containerName; |
|
34 | - /** @var string */ |
|
35 | - private $accountName; |
|
36 | - /** @var string */ |
|
37 | - private $accountKey; |
|
38 | - /** @var BlobRestProxy|null */ |
|
39 | - private $blobClient = null; |
|
40 | - /** @var string|null */ |
|
41 | - private $endpoint = null; |
|
42 | - /** @var bool */ |
|
43 | - private $autoCreate = false; |
|
32 | + /** @var string */ |
|
33 | + private $containerName; |
|
34 | + /** @var string */ |
|
35 | + private $accountName; |
|
36 | + /** @var string */ |
|
37 | + private $accountKey; |
|
38 | + /** @var BlobRestProxy|null */ |
|
39 | + private $blobClient = null; |
|
40 | + /** @var string|null */ |
|
41 | + private $endpoint = null; |
|
42 | + /** @var bool */ |
|
43 | + private $autoCreate = false; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param array $parameters |
|
47 | - */ |
|
48 | - public function __construct($parameters) { |
|
49 | - $this->containerName = $parameters['container']; |
|
50 | - $this->accountName = $parameters['account_name']; |
|
51 | - $this->accountKey = $parameters['account_key']; |
|
52 | - if (isset($parameters['endpoint'])) { |
|
53 | - $this->endpoint = $parameters['endpoint']; |
|
54 | - } |
|
55 | - if (isset($parameters['autocreate'])) { |
|
56 | - $this->autoCreate = $parameters['autocreate']; |
|
57 | - } |
|
58 | - } |
|
45 | + /** |
|
46 | + * @param array $parameters |
|
47 | + */ |
|
48 | + public function __construct($parameters) { |
|
49 | + $this->containerName = $parameters['container']; |
|
50 | + $this->accountName = $parameters['account_name']; |
|
51 | + $this->accountKey = $parameters['account_key']; |
|
52 | + if (isset($parameters['endpoint'])) { |
|
53 | + $this->endpoint = $parameters['endpoint']; |
|
54 | + } |
|
55 | + if (isset($parameters['autocreate'])) { |
|
56 | + $this->autoCreate = $parameters['autocreate']; |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @return BlobRestProxy |
|
62 | - */ |
|
63 | - private function getBlobClient() { |
|
64 | - if (!$this->blobClient) { |
|
65 | - $protocol = $this->endpoint ? substr($this->endpoint, 0, strpos($this->endpoint, ':')) : 'https'; |
|
66 | - $connectionString = "DefaultEndpointsProtocol=" . $protocol . ";AccountName=" . $this->accountName . ";AccountKey=" . $this->accountKey; |
|
67 | - if ($this->endpoint) { |
|
68 | - $connectionString .= ';BlobEndpoint=' . $this->endpoint; |
|
69 | - } |
|
70 | - $this->blobClient = BlobRestProxy::createBlobService($connectionString); |
|
60 | + /** |
|
61 | + * @return BlobRestProxy |
|
62 | + */ |
|
63 | + private function getBlobClient() { |
|
64 | + if (!$this->blobClient) { |
|
65 | + $protocol = $this->endpoint ? substr($this->endpoint, 0, strpos($this->endpoint, ':')) : 'https'; |
|
66 | + $connectionString = "DefaultEndpointsProtocol=" . $protocol . ";AccountName=" . $this->accountName . ";AccountKey=" . $this->accountKey; |
|
67 | + if ($this->endpoint) { |
|
68 | + $connectionString .= ';BlobEndpoint=' . $this->endpoint; |
|
69 | + } |
|
70 | + $this->blobClient = BlobRestProxy::createBlobService($connectionString); |
|
71 | 71 | |
72 | - if ($this->autoCreate) { |
|
73 | - try { |
|
74 | - $this->blobClient->createContainer($this->containerName); |
|
75 | - } catch (ServiceException $e) { |
|
76 | - if ($e->getCode() === 409) { |
|
77 | - // already exists |
|
78 | - } else { |
|
79 | - throw $e; |
|
80 | - } |
|
81 | - } |
|
82 | - } |
|
83 | - } |
|
84 | - return $this->blobClient; |
|
85 | - } |
|
72 | + if ($this->autoCreate) { |
|
73 | + try { |
|
74 | + $this->blobClient->createContainer($this->containerName); |
|
75 | + } catch (ServiceException $e) { |
|
76 | + if ($e->getCode() === 409) { |
|
77 | + // already exists |
|
78 | + } else { |
|
79 | + throw $e; |
|
80 | + } |
|
81 | + } |
|
82 | + } |
|
83 | + } |
|
84 | + return $this->blobClient; |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @return string the container or bucket name where objects are stored |
|
89 | - */ |
|
90 | - public function getStorageId() { |
|
91 | - return 'azure::blob::' . $this->containerName; |
|
92 | - } |
|
87 | + /** |
|
88 | + * @return string the container or bucket name where objects are stored |
|
89 | + */ |
|
90 | + public function getStorageId() { |
|
91 | + return 'azure::blob::' . $this->containerName; |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * @param string $urn the unified resource name used to identify the object |
|
96 | - * @return resource stream with the read data |
|
97 | - * @throws \Exception when something goes wrong, message will be logged |
|
98 | - */ |
|
99 | - public function readObject($urn) { |
|
100 | - $blob = $this->getBlobClient()->getBlob($this->containerName, $urn); |
|
101 | - return $blob->getContentStream(); |
|
102 | - } |
|
94 | + /** |
|
95 | + * @param string $urn the unified resource name used to identify the object |
|
96 | + * @return resource stream with the read data |
|
97 | + * @throws \Exception when something goes wrong, message will be logged |
|
98 | + */ |
|
99 | + public function readObject($urn) { |
|
100 | + $blob = $this->getBlobClient()->getBlob($this->containerName, $urn); |
|
101 | + return $blob->getContentStream(); |
|
102 | + } |
|
103 | 103 | |
104 | - public function writeObject($urn, $stream, string $mimetype = null) { |
|
105 | - $options = new CreateBlockBlobOptions(); |
|
106 | - if ($mimetype) { |
|
107 | - $options->setContentType($mimetype); |
|
108 | - } |
|
109 | - $this->getBlobClient()->createBlockBlob($this->containerName, $urn, $stream, $options); |
|
110 | - } |
|
104 | + public function writeObject($urn, $stream, string $mimetype = null) { |
|
105 | + $options = new CreateBlockBlobOptions(); |
|
106 | + if ($mimetype) { |
|
107 | + $options->setContentType($mimetype); |
|
108 | + } |
|
109 | + $this->getBlobClient()->createBlockBlob($this->containerName, $urn, $stream, $options); |
|
110 | + } |
|
111 | 111 | |
112 | - /** |
|
113 | - * @param string $urn the unified resource name used to identify the object |
|
114 | - * @return void |
|
115 | - * @throws \Exception when something goes wrong, message will be logged |
|
116 | - */ |
|
117 | - public function deleteObject($urn) { |
|
118 | - $this->getBlobClient()->deleteBlob($this->containerName, $urn); |
|
119 | - } |
|
112 | + /** |
|
113 | + * @param string $urn the unified resource name used to identify the object |
|
114 | + * @return void |
|
115 | + * @throws \Exception when something goes wrong, message will be logged |
|
116 | + */ |
|
117 | + public function deleteObject($urn) { |
|
118 | + $this->getBlobClient()->deleteBlob($this->containerName, $urn); |
|
119 | + } |
|
120 | 120 | |
121 | - public function objectExists($urn) { |
|
122 | - try { |
|
123 | - $this->getBlobClient()->getBlobMetadata($this->containerName, $urn); |
|
124 | - return true; |
|
125 | - } catch (ServiceException $e) { |
|
126 | - if ($e->getCode() === 404) { |
|
127 | - return false; |
|
128 | - } else { |
|
129 | - throw $e; |
|
130 | - } |
|
131 | - } |
|
132 | - } |
|
121 | + public function objectExists($urn) { |
|
122 | + try { |
|
123 | + $this->getBlobClient()->getBlobMetadata($this->containerName, $urn); |
|
124 | + return true; |
|
125 | + } catch (ServiceException $e) { |
|
126 | + if ($e->getCode() === 404) { |
|
127 | + return false; |
|
128 | + } else { |
|
129 | + throw $e; |
|
130 | + } |
|
131 | + } |
|
132 | + } |
|
133 | 133 | |
134 | - public function copyObject($from, $to) { |
|
135 | - $this->getBlobClient()->copyBlob($this->containerName, $to, $this->containerName, $from); |
|
136 | - } |
|
134 | + public function copyObject($from, $to) { |
|
135 | + $this->getBlobClient()->copyBlob($this->containerName, $to, $this->containerName, $from); |
|
136 | + } |
|
137 | 137 | } |
@@ -30,24 +30,24 @@ |
||
30 | 30 | */ |
31 | 31 | interface ICloudFederationNotification { |
32 | 32 | |
33 | - /** |
|
34 | - * add a message to the notification |
|
35 | - * |
|
36 | - * @param string $notificationType (e.g. SHARE_ACCEPTED) |
|
37 | - * @param string $resourceType (e.g. file, calendar, contact,...) |
|
38 | - * @param $providerId id of the share |
|
39 | - * @param array $notification , payload of the notification |
|
40 | - * |
|
41 | - * @since 14.0.0 |
|
42 | - */ |
|
43 | - public function setMessage($notificationType, $resourceType, $providerId, array $notification); |
|
33 | + /** |
|
34 | + * add a message to the notification |
|
35 | + * |
|
36 | + * @param string $notificationType (e.g. SHARE_ACCEPTED) |
|
37 | + * @param string $resourceType (e.g. file, calendar, contact,...) |
|
38 | + * @param $providerId id of the share |
|
39 | + * @param array $notification , payload of the notification |
|
40 | + * |
|
41 | + * @since 14.0.0 |
|
42 | + */ |
|
43 | + public function setMessage($notificationType, $resourceType, $providerId, array $notification); |
|
44 | 44 | |
45 | - /** |
|
46 | - * get message, ready to send out |
|
47 | - * |
|
48 | - * @return array |
|
49 | - * |
|
50 | - * @since 14.0.0 |
|
51 | - */ |
|
52 | - public function getMessage(); |
|
45 | + /** |
|
46 | + * get message, ready to send out |
|
47 | + * |
|
48 | + * @return array |
|
49 | + * |
|
50 | + * @since 14.0.0 |
|
51 | + */ |
|
52 | + public function getMessage(); |
|
53 | 53 | } |
@@ -30,221 +30,221 @@ |
||
30 | 30 | */ |
31 | 31 | interface ICloudFederationShare { |
32 | 32 | |
33 | - /** |
|
34 | - * set uid of the recipient |
|
35 | - * |
|
36 | - * @param string $user |
|
37 | - * |
|
38 | - * @since 14.0.0 |
|
39 | - */ |
|
40 | - public function setShareWith($user); |
|
41 | - |
|
42 | - /** |
|
43 | - * set resource name (e.g. file, calendar, contact,...) |
|
44 | - * |
|
45 | - * @param string $name |
|
46 | - * |
|
47 | - * @since 14.0.0 |
|
48 | - */ |
|
49 | - public function setResourceName($name); |
|
50 | - |
|
51 | - /** |
|
52 | - * set resource type (e.g. file, calendar, contact,...) |
|
53 | - * |
|
54 | - * @param string $resourceType |
|
55 | - * |
|
56 | - * @since 14.0.0 |
|
57 | - */ |
|
58 | - public function setResourceType($resourceType); |
|
59 | - |
|
60 | - /** |
|
61 | - * set resource description (optional) |
|
62 | - * |
|
63 | - * @param string $description |
|
64 | - * |
|
65 | - * @since 14.0.0 |
|
66 | - */ |
|
67 | - public function setDescription($description); |
|
68 | - |
|
69 | - /** |
|
70 | - * set provider ID (e.g. file ID) |
|
71 | - * |
|
72 | - * @param string $providerId |
|
73 | - * |
|
74 | - * @since 14.0.0 |
|
75 | - */ |
|
76 | - public function setProviderId($providerId); |
|
77 | - |
|
78 | - /** |
|
79 | - * set owner UID |
|
80 | - * |
|
81 | - * @param string $owner |
|
82 | - * |
|
83 | - * @since 14.0.0 |
|
84 | - */ |
|
85 | - public function setOwner($owner); |
|
86 | - |
|
87 | - /** |
|
88 | - * set owner display name |
|
89 | - * |
|
90 | - * @param string $ownerDisplayName |
|
91 | - * |
|
92 | - * @since 14.0.0 |
|
93 | - */ |
|
94 | - public function setOwnerDisplayName($ownerDisplayName); |
|
95 | - |
|
96 | - /** |
|
97 | - * set UID of the user who sends the share |
|
98 | - * |
|
99 | - * @param string $sharedBy |
|
100 | - * |
|
101 | - * @since 14.0.0 |
|
102 | - */ |
|
103 | - public function setSharedBy($sharedBy); |
|
104 | - |
|
105 | - /** |
|
106 | - * set display name of the user who sends the share |
|
107 | - * |
|
108 | - * @param $sharedByDisplayName |
|
109 | - * |
|
110 | - * @since 14.0.0 |
|
111 | - */ |
|
112 | - public function setSharedByDisplayName($sharedByDisplayName); |
|
113 | - |
|
114 | - /** |
|
115 | - * set protocol specification |
|
116 | - * |
|
117 | - * @param array $protocol |
|
118 | - * |
|
119 | - * @since 14.0.0 |
|
120 | - */ |
|
121 | - public function setProtocol(array $protocol); |
|
122 | - |
|
123 | - /** |
|
124 | - * share type (group or user) |
|
125 | - * |
|
126 | - * @param string $shareType |
|
127 | - * |
|
128 | - * @since 14.0.0 |
|
129 | - */ |
|
130 | - public function setShareType($shareType); |
|
131 | - |
|
132 | - /** |
|
133 | - * get the whole share, ready to send out |
|
134 | - * |
|
135 | - * @return array |
|
136 | - * |
|
137 | - * @since 14.0.0 |
|
138 | - */ |
|
139 | - public function getShare(); |
|
140 | - |
|
141 | - /** |
|
142 | - * get uid of the recipient |
|
143 | - * |
|
144 | - * @return string |
|
145 | - * |
|
146 | - * @since 14.0.0 |
|
147 | - */ |
|
148 | - public function getShareWith(); |
|
149 | - |
|
150 | - /** |
|
151 | - * get resource name (e.g. file, calendar, contact,...) |
|
152 | - * |
|
153 | - * @return string |
|
154 | - * |
|
155 | - * @since 14.0.0 |
|
156 | - */ |
|
157 | - public function getResourceName(); |
|
158 | - |
|
159 | - /** |
|
160 | - * get resource type (e.g. file, calendar, contact,...) |
|
161 | - * |
|
162 | - * @return string |
|
163 | - * |
|
164 | - * @since 14.0.0 |
|
165 | - */ |
|
166 | - public function getResourceType(); |
|
167 | - |
|
168 | - /** |
|
169 | - * get resource description (optional) |
|
170 | - * |
|
171 | - * @return string |
|
172 | - * |
|
173 | - * @since 14.0.0 |
|
174 | - */ |
|
175 | - public function getDescription(); |
|
176 | - |
|
177 | - /** |
|
178 | - * get provider ID (e.g. file ID) |
|
179 | - * |
|
180 | - * @return string |
|
181 | - * |
|
182 | - * @since 14.0.0 |
|
183 | - */ |
|
184 | - public function getProviderId(); |
|
185 | - |
|
186 | - /** |
|
187 | - * get owner UID |
|
188 | - * |
|
189 | - * @return string |
|
190 | - * |
|
191 | - * @since 14.0.0 |
|
192 | - */ |
|
193 | - public function getOwner(); |
|
194 | - |
|
195 | - /** |
|
196 | - * get owner display name |
|
197 | - * |
|
198 | - * @return string |
|
199 | - * |
|
200 | - * @since 14.0.0 |
|
201 | - */ |
|
202 | - public function getOwnerDisplayName(); |
|
203 | - |
|
204 | - /** |
|
205 | - * get UID of the user who sends the share |
|
206 | - * |
|
207 | - * @return string |
|
208 | - * |
|
209 | - * @since 14.0.0 |
|
210 | - */ |
|
211 | - public function getSharedBy(); |
|
212 | - |
|
213 | - /** |
|
214 | - * get display name of the user who sends the share |
|
215 | - * |
|
216 | - * @return string |
|
217 | - * |
|
218 | - * @since 14.0.0 |
|
219 | - */ |
|
220 | - public function getSharedByDisplayName(); |
|
221 | - |
|
222 | - /** |
|
223 | - * get share type (group or user) |
|
224 | - * |
|
225 | - * @return string |
|
226 | - * |
|
227 | - * @since 14.0.0 |
|
228 | - */ |
|
229 | - public function getShareType(); |
|
230 | - |
|
231 | - /** |
|
232 | - * get share Secret |
|
233 | - * |
|
234 | - * @return string |
|
235 | - * |
|
236 | - * @since 14.0.0 |
|
237 | - */ |
|
238 | - public function getShareSecret(); |
|
239 | - |
|
240 | - |
|
241 | - /** |
|
242 | - * get protocol specification |
|
243 | - * |
|
244 | - * @return array |
|
245 | - * |
|
246 | - * @since 14.0.0 |
|
247 | - */ |
|
248 | - public function getProtocol(); |
|
33 | + /** |
|
34 | + * set uid of the recipient |
|
35 | + * |
|
36 | + * @param string $user |
|
37 | + * |
|
38 | + * @since 14.0.0 |
|
39 | + */ |
|
40 | + public function setShareWith($user); |
|
41 | + |
|
42 | + /** |
|
43 | + * set resource name (e.g. file, calendar, contact,...) |
|
44 | + * |
|
45 | + * @param string $name |
|
46 | + * |
|
47 | + * @since 14.0.0 |
|
48 | + */ |
|
49 | + public function setResourceName($name); |
|
50 | + |
|
51 | + /** |
|
52 | + * set resource type (e.g. file, calendar, contact,...) |
|
53 | + * |
|
54 | + * @param string $resourceType |
|
55 | + * |
|
56 | + * @since 14.0.0 |
|
57 | + */ |
|
58 | + public function setResourceType($resourceType); |
|
59 | + |
|
60 | + /** |
|
61 | + * set resource description (optional) |
|
62 | + * |
|
63 | + * @param string $description |
|
64 | + * |
|
65 | + * @since 14.0.0 |
|
66 | + */ |
|
67 | + public function setDescription($description); |
|
68 | + |
|
69 | + /** |
|
70 | + * set provider ID (e.g. file ID) |
|
71 | + * |
|
72 | + * @param string $providerId |
|
73 | + * |
|
74 | + * @since 14.0.0 |
|
75 | + */ |
|
76 | + public function setProviderId($providerId); |
|
77 | + |
|
78 | + /** |
|
79 | + * set owner UID |
|
80 | + * |
|
81 | + * @param string $owner |
|
82 | + * |
|
83 | + * @since 14.0.0 |
|
84 | + */ |
|
85 | + public function setOwner($owner); |
|
86 | + |
|
87 | + /** |
|
88 | + * set owner display name |
|
89 | + * |
|
90 | + * @param string $ownerDisplayName |
|
91 | + * |
|
92 | + * @since 14.0.0 |
|
93 | + */ |
|
94 | + public function setOwnerDisplayName($ownerDisplayName); |
|
95 | + |
|
96 | + /** |
|
97 | + * set UID of the user who sends the share |
|
98 | + * |
|
99 | + * @param string $sharedBy |
|
100 | + * |
|
101 | + * @since 14.0.0 |
|
102 | + */ |
|
103 | + public function setSharedBy($sharedBy); |
|
104 | + |
|
105 | + /** |
|
106 | + * set display name of the user who sends the share |
|
107 | + * |
|
108 | + * @param $sharedByDisplayName |
|
109 | + * |
|
110 | + * @since 14.0.0 |
|
111 | + */ |
|
112 | + public function setSharedByDisplayName($sharedByDisplayName); |
|
113 | + |
|
114 | + /** |
|
115 | + * set protocol specification |
|
116 | + * |
|
117 | + * @param array $protocol |
|
118 | + * |
|
119 | + * @since 14.0.0 |
|
120 | + */ |
|
121 | + public function setProtocol(array $protocol); |
|
122 | + |
|
123 | + /** |
|
124 | + * share type (group or user) |
|
125 | + * |
|
126 | + * @param string $shareType |
|
127 | + * |
|
128 | + * @since 14.0.0 |
|
129 | + */ |
|
130 | + public function setShareType($shareType); |
|
131 | + |
|
132 | + /** |
|
133 | + * get the whole share, ready to send out |
|
134 | + * |
|
135 | + * @return array |
|
136 | + * |
|
137 | + * @since 14.0.0 |
|
138 | + */ |
|
139 | + public function getShare(); |
|
140 | + |
|
141 | + /** |
|
142 | + * get uid of the recipient |
|
143 | + * |
|
144 | + * @return string |
|
145 | + * |
|
146 | + * @since 14.0.0 |
|
147 | + */ |
|
148 | + public function getShareWith(); |
|
149 | + |
|
150 | + /** |
|
151 | + * get resource name (e.g. file, calendar, contact,...) |
|
152 | + * |
|
153 | + * @return string |
|
154 | + * |
|
155 | + * @since 14.0.0 |
|
156 | + */ |
|
157 | + public function getResourceName(); |
|
158 | + |
|
159 | + /** |
|
160 | + * get resource type (e.g. file, calendar, contact,...) |
|
161 | + * |
|
162 | + * @return string |
|
163 | + * |
|
164 | + * @since 14.0.0 |
|
165 | + */ |
|
166 | + public function getResourceType(); |
|
167 | + |
|
168 | + /** |
|
169 | + * get resource description (optional) |
|
170 | + * |
|
171 | + * @return string |
|
172 | + * |
|
173 | + * @since 14.0.0 |
|
174 | + */ |
|
175 | + public function getDescription(); |
|
176 | + |
|
177 | + /** |
|
178 | + * get provider ID (e.g. file ID) |
|
179 | + * |
|
180 | + * @return string |
|
181 | + * |
|
182 | + * @since 14.0.0 |
|
183 | + */ |
|
184 | + public function getProviderId(); |
|
185 | + |
|
186 | + /** |
|
187 | + * get owner UID |
|
188 | + * |
|
189 | + * @return string |
|
190 | + * |
|
191 | + * @since 14.0.0 |
|
192 | + */ |
|
193 | + public function getOwner(); |
|
194 | + |
|
195 | + /** |
|
196 | + * get owner display name |
|
197 | + * |
|
198 | + * @return string |
|
199 | + * |
|
200 | + * @since 14.0.0 |
|
201 | + */ |
|
202 | + public function getOwnerDisplayName(); |
|
203 | + |
|
204 | + /** |
|
205 | + * get UID of the user who sends the share |
|
206 | + * |
|
207 | + * @return string |
|
208 | + * |
|
209 | + * @since 14.0.0 |
|
210 | + */ |
|
211 | + public function getSharedBy(); |
|
212 | + |
|
213 | + /** |
|
214 | + * get display name of the user who sends the share |
|
215 | + * |
|
216 | + * @return string |
|
217 | + * |
|
218 | + * @since 14.0.0 |
|
219 | + */ |
|
220 | + public function getSharedByDisplayName(); |
|
221 | + |
|
222 | + /** |
|
223 | + * get share type (group or user) |
|
224 | + * |
|
225 | + * @return string |
|
226 | + * |
|
227 | + * @since 14.0.0 |
|
228 | + */ |
|
229 | + public function getShareType(); |
|
230 | + |
|
231 | + /** |
|
232 | + * get share Secret |
|
233 | + * |
|
234 | + * @return string |
|
235 | + * |
|
236 | + * @since 14.0.0 |
|
237 | + */ |
|
238 | + public function getShareSecret(); |
|
239 | + |
|
240 | + |
|
241 | + /** |
|
242 | + * get protocol specification |
|
243 | + * |
|
244 | + * @return array |
|
245 | + * |
|
246 | + * @since 14.0.0 |
|
247 | + */ |
|
248 | + public function getProtocol(); |
|
249 | 249 | |
250 | 250 | } |
@@ -33,19 +33,19 @@ |
||
33 | 33 | */ |
34 | 34 | class ProviderCouldNotAddShareException extends HintException { |
35 | 35 | |
36 | - /** |
|
37 | - * ProviderCouldNotAddShareException constructor. |
|
38 | - * |
|
39 | - * @since 14.0.0 |
|
40 | - * |
|
41 | - * @param string $message |
|
42 | - * @param string $hint |
|
43 | - * @param int $code |
|
44 | - * @param \Exception|null $previous |
|
45 | - */ |
|
46 | - public function __construct($message, $hint = '', $code = Http::STATUS_BAD_REQUEST, \Exception $previous = null) { |
|
47 | - parent::__construct($message, $hint, $code, $previous); |
|
48 | - } |
|
36 | + /** |
|
37 | + * ProviderCouldNotAddShareException constructor. |
|
38 | + * |
|
39 | + * @since 14.0.0 |
|
40 | + * |
|
41 | + * @param string $message |
|
42 | + * @param string $hint |
|
43 | + * @param int $code |
|
44 | + * @param \Exception|null $previous |
|
45 | + */ |
|
46 | + public function __construct($message, $hint = '', $code = Http::STATUS_BAD_REQUEST, \Exception $previous = null) { |
|
47 | + parent::__construct($message, $hint, $code, $previous); |
|
48 | + } |
|
49 | 49 | |
50 | 50 | |
51 | 51 | } |
@@ -30,33 +30,33 @@ |
||
30 | 30 | */ |
31 | 31 | interface ICloudFederationFactory { |
32 | 32 | |
33 | - /** |
|
34 | - * get a CloudFederationShare Object to prepare a share you want to send |
|
35 | - * |
|
36 | - * @param string $shareWith |
|
37 | - * @param string $name resource name (e.g. document.odt) |
|
38 | - * @param string $description share description (optional) |
|
39 | - * @param string $providerId resource UID on the provider side |
|
40 | - * @param string $owner provider specific UID of the user who owns the resource |
|
41 | - * @param string $ownerDisplayName display name of the user who shared the item |
|
42 | - * @param string $sharedBy provider specific UID of the user who shared the resource |
|
43 | - * @param string $sharedByDisplayName display name of the user who shared the resource |
|
44 | - * @param string $sharedSecret used to authenticate requests across servers |
|
45 | - * @param string $shareType ('group' or 'user' share) |
|
46 | - * @param $resourceType ('file', 'calendar',...) |
|
47 | - * @return ICloudFederationShare |
|
48 | - * |
|
49 | - * @since 14.0.0 |
|
50 | - */ |
|
51 | - public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $sharedSecret, $shareType, $resourceType); |
|
33 | + /** |
|
34 | + * get a CloudFederationShare Object to prepare a share you want to send |
|
35 | + * |
|
36 | + * @param string $shareWith |
|
37 | + * @param string $name resource name (e.g. document.odt) |
|
38 | + * @param string $description share description (optional) |
|
39 | + * @param string $providerId resource UID on the provider side |
|
40 | + * @param string $owner provider specific UID of the user who owns the resource |
|
41 | + * @param string $ownerDisplayName display name of the user who shared the item |
|
42 | + * @param string $sharedBy provider specific UID of the user who shared the resource |
|
43 | + * @param string $sharedByDisplayName display name of the user who shared the resource |
|
44 | + * @param string $sharedSecret used to authenticate requests across servers |
|
45 | + * @param string $shareType ('group' or 'user' share) |
|
46 | + * @param $resourceType ('file', 'calendar',...) |
|
47 | + * @return ICloudFederationShare |
|
48 | + * |
|
49 | + * @since 14.0.0 |
|
50 | + */ |
|
51 | + public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $sharedSecret, $shareType, $resourceType); |
|
52 | 52 | |
53 | - /** |
|
54 | - * get a Cloud FederationNotification object to prepare a notification you |
|
55 | - * want to send |
|
56 | - * |
|
57 | - * @return ICloudFederationNotification |
|
58 | - * |
|
59 | - * @since 14.0.0 |
|
60 | - */ |
|
61 | - public function getCloudFederationNotification(); |
|
53 | + /** |
|
54 | + * get a Cloud FederationNotification object to prepare a notification you |
|
55 | + * want to send |
|
56 | + * |
|
57 | + * @return ICloudFederationNotification |
|
58 | + * |
|
59 | + * @since 14.0.0 |
|
60 | + */ |
|
61 | + public function getCloudFederationNotification(); |
|
62 | 62 | } |
@@ -32,17 +32,17 @@ |
||
32 | 32 | */ |
33 | 33 | class AuthenticationFailedException extends HintException { |
34 | 34 | |
35 | - /** |
|
36 | - * BadRequestException constructor. |
|
37 | - * |
|
38 | - * @since 14.0.0 |
|
39 | - * |
|
40 | - */ |
|
41 | - public function __construct() { |
|
42 | - $l = \OC::$server->getL10N('federation'); |
|
43 | - $message = 'Authentication failed, wrong token or provider ID given'; |
|
44 | - $hint = $l->t('Authentication failed, wrong token or provider ID given'); |
|
45 | - parent::__construct($message, $hint); |
|
46 | - } |
|
35 | + /** |
|
36 | + * BadRequestException constructor. |
|
37 | + * |
|
38 | + * @since 14.0.0 |
|
39 | + * |
|
40 | + */ |
|
41 | + public function __construct() { |
|
42 | + $l = \OC::$server->getL10N('federation'); |
|
43 | + $message = 'Authentication failed, wrong token or provider ID given'; |
|
44 | + $hint = $l->t('Authentication failed, wrong token or provider ID given'); |
|
45 | + parent::__construct($message, $hint); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | } |
@@ -42,10 +42,10 @@ |
||
42 | 42 | */ |
43 | 43 | class StrictInlineContentSecurityPolicy extends ContentSecurityPolicy { |
44 | 44 | |
45 | - /** |
|
46 | - * @since 14.0.0 |
|
47 | - */ |
|
48 | - public function __construct() { |
|
49 | - $this->inlineStyleAllowed = false; |
|
50 | - } |
|
45 | + /** |
|
46 | + * @since 14.0.0 |
|
47 | + */ |
|
48 | + public function __construct() { |
|
49 | + $this->inlineStyleAllowed = false; |
|
50 | + } |
|
51 | 51 | } |