summaryrefslogtreecommitdiffstats
path: root/lib/private/share20/manager.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/share20/manager.php')
-rw-r--r--lib/private/share20/manager.php40
1 files changed, 37 insertions, 3 deletions
diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php
index 035026b47ea..2be8fb5174d 100644
--- a/lib/private/share20/manager.php
+++ b/lib/private/share20/manager.php
@@ -665,13 +665,47 @@ class Manager {
* Get the share by token possible with password
*
* @param string $token
- * @param string $password
- *
* @return Share
*
* @throws ShareNotFound
*/
- public function getShareByToken($token, $password=null) {
+ public function getShareByToken($token) {
+ $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_LINK);
+
+ $share = $provider->getShareByToken($token);
+
+ //TODO check if share expired
+
+ return $share;
+ }
+
+ /**
+ * Verify the password of a public share
+ *
+ * @param IShare $share
+ * @param string $password
+ * @return bool
+ */
+ public function checkPassword(IShare $share, $password) {
+ if ($share->getShareType() !== \OCP\Share::SHARE_TYPE_LINK) {
+ //TODO maybe exception?
+ return false;
+ }
+
+ if ($password === null || $share->getPassword() === null) {
+ return false;
+ }
+
+ $newHash = '';
+ if (!$this->hasher->verify($password, $share->getPassword(), $newHash)) {
+ return false;
+ }
+
+ if (!empty($newHash)) {
+ //TODO update hash!
+ }
+
+ return true;
}
/**