*/
public function updateToken(IToken $token) {
if (!($token instanceof DefaultToken)) {
- throw new InvalidTokenException();
+ throw new InvalidTokenException("Invalid token type");
}
$this->mapper->update($token);
}
*/
public function updateTokenActivity(IToken $token) {
if (!($token instanceof DefaultToken)) {
- throw new InvalidTokenException();
+ throw new InvalidTokenException("Invalid token type");
}
/** @var DefaultToken $token */
$now = $this->time->getTime();
try {
$token = $this->mapper->getToken($this->hashToken($tokenId));
} catch (DoesNotExistException $ex) {
- throw new InvalidTokenException();
+ throw new InvalidTokenException("Token does not exist", 0, $ex);
}
if ((int)$token->getExpires() !== 0 && $token->getExpires() < $this->time->getTime()) {
try {
$token = $this->mapper->getTokenById($tokenId);
} catch (DoesNotExistException $ex) {
- throw new InvalidTokenException();
+ throw new InvalidTokenException("Token with ID $tokenId does not exist", 0, $ex);
}
if ((int)$token->getExpires() !== 0 && $token->getExpires() < $this->time->getTime()) {
*/
public function setPassword(IToken $token, string $tokenId, string $password) {
if (!($token instanceof DefaultToken)) {
- throw new InvalidTokenException();
+ throw new InvalidTokenException("Invalid token type");
}
/** @var DefaultToken $token */
$token->setPassword($this->encryptPassword($password, $tokenId));
} catch (Exception $ex) {
// Delete the invalid token
$this->invalidateToken($token);
- throw new InvalidTokenException();
+ throw new InvalidTokenException("Can not decrypt token password: " . $ex->getMessage(), 0, $ex);
}
}
public function markPasswordInvalid(IToken $token, string $tokenId) {
if (!($token instanceof DefaultToken)) {
- throw new InvalidTokenException();
+ throw new InvalidTokenException("Invalid token type");
}
//No need to mark as invalid. We just invalide default tokens
$token = $this->mapper->getToken($this->hashToken($tokenId));
$this->cache[$token->getToken()] = $token;
} catch (DoesNotExistException $ex) {
- throw new InvalidTokenException();
+ throw new InvalidTokenException("Token does not exist: " . $ex->getMessage(), 0, $ex);
}
}
try {
$token = $this->mapper->getTokenById($tokenId);
} catch (DoesNotExistException $ex) {
- throw new InvalidTokenException();
+ throw new InvalidTokenException("Token with ID $tokenId does not exist: " . $ex->getMessage(), 0, $ex);
}
if ((int)$token->getExpires() !== 0 && $token->getExpires() < $this->time->getTime()) {
$token = $this->getToken($oldSessionId);
if (!($token instanceof PublicKeyToken)) {
- throw new InvalidTokenException();
+ throw new InvalidTokenException("Invalid token type");
}
$password = null;
$this->cache->clear();
if (!($token instanceof PublicKeyToken)) {
- throw new InvalidTokenException();
+ throw new InvalidTokenException("Invalid token type");
}
$this->mapper->update($token);
}
$this->cache->clear();
if (!($token instanceof PublicKeyToken)) {
- throw new InvalidTokenException();
+ throw new InvalidTokenException("Invalid token type");
}
/** @var DefaultToken $token */
$now = $this->time->getTime();
public function getPassword(IToken $token, string $tokenId): string {
if (!($token instanceof PublicKeyToken)) {
- throw new InvalidTokenException();
+ throw new InvalidTokenException("Invalid token type");
}
if ($token->getPassword() === null) {
$this->cache->clear();
if (!($token instanceof PublicKeyToken)) {
- throw new InvalidTokenException();
+ throw new InvalidTokenException("Invalid token type");
}
// When changing passwords all temp tokens are deleted
$this->cache->clear();
if (!($token instanceof PublicKeyToken)) {
- throw new InvalidTokenException();
+ throw new InvalidTokenException("Invalid token type");
}
// Decrypt private key with oldTokenId
} catch (\Exception $ex) {
// Delete the invalid token
$this->invalidateToken($token);
- throw new InvalidTokenException();
+ throw new InvalidTokenException("Could not decrypt token password: " . $ex->getMessage(), 0, $ex);
}
}
$this->cache->clear();
if (!($token instanceof PublicKeyToken)) {
- throw new InvalidTokenException();
+ throw new InvalidTokenException("Invalid token type");
}
$token->setPasswordInvalid(true);