Exemple #1
0
 /**
  * Based on the given token the share information will be returned - password protected shares will be verified
  * @param string $token
  * @param bool $checkPasswordProtection
  * @return array|boolean false will be returned in case the token is unknown or unauthorized
  */
 public static function getShareByToken($token, $checkPasswordProtection = true)
 {
     $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `token` = ?', 1);
     $result = $query->execute(array($token));
     if (\OC_DB::isError($result)) {
         \OCP\Util::writeLog('OCP\\Share', \OC_DB::getErrorMessage() . ', token=' . $token, \OCP\Util::ERROR);
     }
     $row = $result->fetchRow();
     if ($row === false) {
         return false;
     }
     if (is_array($row) and self::expireItem($row)) {
         return false;
     }
     // password protected shares need to be authenticated
     if ($checkPasswordProtection && !\OCP\Share::checkPasswordProtectedShare($row)) {
         return false;
     }
     return $row;
 }
Exemple #2
0
 /**
  * @dataProvider checkPasswordProtectedShareDataProvider
  * @param $expected
  * @param $item
  */
 public function testCheckPasswordProtectedShare($expected, $item)
 {
     \OC::$server->getSession()->set('public_link_authenticated', '100');
     $result = \OCP\Share::checkPasswordProtectedShare($item);
     $this->assertEquals($expected, $result);
 }