/** * Get a token by token id * * @param string $tokenId * @throws InvalidTokenException * @return DefaultToken */ public function getToken($tokenId) { try { return $this->mapper->getToken($this->hashToken($tokenId)); } catch (DoesNotExistException $ex) { throw new InvalidTokenException(); } }
/** * @param string $token * @throws InvalidTokenException * @return DefaultToken user UID */ public function validateToken($token) { try { $dbToken = $this->mapper->getToken($this->hashToken($token)); $this->logger->debug('valid default token for ' . $dbToken->getUID()); return $dbToken; } catch (DoesNotExistException $ex) { throw new InvalidTokenException(); } }
/** * @expectedException \OCP\AppFramework\Db\DoesNotExistException */ public function testGetInvalidToken() { $token = 'thisisaninvalidtokenthatisnotinthedatabase'; $this->mapper->getToken($token); }