From 1bdf952fdeab6305785cae3522eb4807c0e68c99 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Mon, 23 Oct 2023 10:57:26 +0200 Subject: [PATCH] Make sure that OC interfaces returns OC interfaces for backward compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- .../lib/Controller/AuthSettingsController.php | 3 +-- .../Exceptions/ExpiredTokenException.php | 13 +++++++++++++ .../Exceptions/WipeTokenException.php | 13 +++++++++++++ .../Exceptions/ExpiredTokenException.php | 9 +++++++++ .../Exceptions/InvalidTokenException.php | 3 +++ .../Exceptions/WipeTokenException.php | 9 +++++++++ 6 files changed, 48 insertions(+), 2 deletions(-) diff --git a/apps/settings/lib/Controller/AuthSettingsController.php b/apps/settings/lib/Controller/AuthSettingsController.php index 38db7be1e91..305908e5e0a 100644 --- a/apps/settings/lib/Controller/AuthSettingsController.php +++ b/apps/settings/lib/Controller/AuthSettingsController.php @@ -53,14 +53,13 @@ use OCP\Session\Exceptions\SessionNotAvailableException; use Psr\Log\LoggerInterface; class AuthSettingsController extends Controller { - /** @var IProvider */ private $tokenProvider; /** @var ISession */ private $session; - /** IUserSession */ + /** @var IUserSession */ private $userSession; /** @var string */ diff --git a/lib/private/Authentication/Exceptions/ExpiredTokenException.php b/lib/private/Authentication/Exceptions/ExpiredTokenException.php index c23a1176fae..18618a557f3 100644 --- a/lib/private/Authentication/Exceptions/ExpiredTokenException.php +++ b/lib/private/Authentication/Exceptions/ExpiredTokenException.php @@ -25,8 +25,21 @@ declare(strict_types=1); */ namespace OC\Authentication\Exceptions; +use OC\Authentication\Token\IToken; + /** * @deprecated 28.0.0 use OCP version instead */ class ExpiredTokenException extends \OCP\Authentication\Exceptions\ExpiredTokenException { + public function __construct( + IToken $token, + ) { + parent::__construct($token); + } + + public function getToken(): IToken { + $token = parent::getToken(); + /** @var IToken $token We know that we passed OC interface from constructor */ + return $token; + } } diff --git a/lib/private/Authentication/Exceptions/WipeTokenException.php b/lib/private/Authentication/Exceptions/WipeTokenException.php index 8ae4f74e4d7..9b24ca24430 100644 --- a/lib/private/Authentication/Exceptions/WipeTokenException.php +++ b/lib/private/Authentication/Exceptions/WipeTokenException.php @@ -25,8 +25,21 @@ declare(strict_types=1); */ namespace OC\Authentication\Exceptions; +use OC\Authentication\Token\IToken; + /** * @deprecated 28.0.0 use OCP version instead */ class WipeTokenException extends \OCP\Authentication\Exceptions\WipeTokenException { + public function __construct( + IToken $token, + ) { + parent::__construct($token); + } + + public function getToken(): IToken { + $token = parent::getToken(); + /** @var IToken $token We know that we passed OC interface from constructor */ + return $token; + } } diff --git a/lib/public/Authentication/Exceptions/ExpiredTokenException.php b/lib/public/Authentication/Exceptions/ExpiredTokenException.php index eab68ba4eff..58f2f22d5c7 100644 --- a/lib/public/Authentication/Exceptions/ExpiredTokenException.php +++ b/lib/public/Authentication/Exceptions/ExpiredTokenException.php @@ -27,13 +27,22 @@ namespace OCP\Authentication\Exceptions; use OCP\Authentication\Token\IToken; +/** + * @since 28.0 + */ class ExpiredTokenException extends InvalidTokenException { + /** + * @since 28.0 + */ public function __construct( private IToken $token, ) { parent::__construct(); } + /** + * @since 28.0 + */ public function getToken(): IToken { return $this->token; } diff --git a/lib/public/Authentication/Exceptions/InvalidTokenException.php b/lib/public/Authentication/Exceptions/InvalidTokenException.php index 2556e191d63..7d55694d3ea 100644 --- a/lib/public/Authentication/Exceptions/InvalidTokenException.php +++ b/lib/public/Authentication/Exceptions/InvalidTokenException.php @@ -26,5 +26,8 @@ namespace OCP\Authentication\Exceptions; use Exception; +/** + * @since 28.0 + */ class InvalidTokenException extends Exception { } diff --git a/lib/public/Authentication/Exceptions/WipeTokenException.php b/lib/public/Authentication/Exceptions/WipeTokenException.php index aa2da6739e6..9e80432ef52 100644 --- a/lib/public/Authentication/Exceptions/WipeTokenException.php +++ b/lib/public/Authentication/Exceptions/WipeTokenException.php @@ -27,13 +27,22 @@ namespace OCP\Authentication\Exceptions; use OCP\Authentication\Token\IToken; +/** + * @since 28.0 + */ class WipeTokenException extends InvalidTokenException { + /** + * @since 28.0 + */ public function __construct( private IToken $token, ) { parent::__construct(); } + /** + * @since 28.0 + */ public function getToken(): IToken { return $this->token; } -- 2.39.5