From b82e25ea7a13e98212201a905718309a3d1415ae Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Mon, 23 Oct 2023 10:18:20 +0200 Subject: Move Exceptions used in OCP to OCP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- .../Exceptions/ExpiredTokenException.php | 19 +++------- .../Exceptions/InvalidTokenException.php | 7 ++-- .../Exceptions/WipeTokenException.php | 19 +++------- .../Exceptions/ExpiredTokenException.php | 40 ++++++++++++++++++++++ .../Exceptions/InvalidTokenException.php | 30 ++++++++++++++++ .../Exceptions/WipeTokenException.php | 40 ++++++++++++++++++++++ lib/public/Authentication/Token/IProvider.php | 4 +++ 7 files changed, 126 insertions(+), 33 deletions(-) create mode 100644 lib/public/Authentication/Exceptions/ExpiredTokenException.php create mode 100644 lib/public/Authentication/Exceptions/InvalidTokenException.php create mode 100644 lib/public/Authentication/Exceptions/WipeTokenException.php (limited to 'lib') diff --git a/lib/private/Authentication/Exceptions/ExpiredTokenException.php b/lib/private/Authentication/Exceptions/ExpiredTokenException.php index 0dc92b45920..c23a1176fae 100644 --- a/lib/private/Authentication/Exceptions/ExpiredTokenException.php +++ b/lib/private/Authentication/Exceptions/ExpiredTokenException.php @@ -25,19 +25,8 @@ declare(strict_types=1); */ namespace OC\Authentication\Exceptions; -use OC\Authentication\Token\IToken; - -class ExpiredTokenException extends InvalidTokenException { - /** @var IToken */ - private $token; - - public function __construct(IToken $token) { - parent::__construct(); - - $this->token = $token; - } - - public function getToken(): IToken { - return $this->token; - } +/** + * @deprecated 28.0.0 use OCP version instead + */ +class ExpiredTokenException extends \OCP\Authentication\Exceptions\ExpiredTokenException { } diff --git a/lib/private/Authentication/Exceptions/InvalidTokenException.php b/lib/private/Authentication/Exceptions/InvalidTokenException.php index acaabff6b88..7de6e1522fa 100644 --- a/lib/private/Authentication/Exceptions/InvalidTokenException.php +++ b/lib/private/Authentication/Exceptions/InvalidTokenException.php @@ -24,7 +24,8 @@ declare(strict_types=1); */ namespace OC\Authentication\Exceptions; -use Exception; - -class InvalidTokenException extends Exception { +/** + * @deprecated 28.0.0 use OCP version instead + */ +class InvalidTokenException extends \OCP\Authentication\Exceptions\InvalidTokenException { } diff --git a/lib/private/Authentication/Exceptions/WipeTokenException.php b/lib/private/Authentication/Exceptions/WipeTokenException.php index 1c60ab9da78..8ae4f74e4d7 100644 --- a/lib/private/Authentication/Exceptions/WipeTokenException.php +++ b/lib/private/Authentication/Exceptions/WipeTokenException.php @@ -25,19 +25,8 @@ declare(strict_types=1); */ namespace OC\Authentication\Exceptions; -use OC\Authentication\Token\IToken; - -class WipeTokenException extends InvalidTokenException { - /** @var IToken */ - private $token; - - public function __construct(IToken $token) { - parent::__construct(); - - $this->token = $token; - } - - public function getToken(): IToken { - return $this->token; - } +/** + * @deprecated 28.0.0 use OCP version instead + */ +class WipeTokenException extends \OCP\Authentication\Exceptions\WipeTokenException { } diff --git a/lib/public/Authentication/Exceptions/ExpiredTokenException.php b/lib/public/Authentication/Exceptions/ExpiredTokenException.php new file mode 100644 index 00000000000..eab68ba4eff --- /dev/null +++ b/lib/public/Authentication/Exceptions/ExpiredTokenException.php @@ -0,0 +1,40 @@ + + * + * @author Roeland Jago Douma + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +namespace OCP\Authentication\Exceptions; + +use OCP\Authentication\Token\IToken; + +class ExpiredTokenException extends InvalidTokenException { + public function __construct( + private IToken $token, + ) { + parent::__construct(); + } + + public function getToken(): IToken { + return $this->token; + } +} diff --git a/lib/public/Authentication/Exceptions/InvalidTokenException.php b/lib/public/Authentication/Exceptions/InvalidTokenException.php new file mode 100644 index 00000000000..2556e191d63 --- /dev/null +++ b/lib/public/Authentication/Exceptions/InvalidTokenException.php @@ -0,0 +1,30 @@ + + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ +namespace OCP\Authentication\Exceptions; + +use Exception; + +class InvalidTokenException extends Exception { +} diff --git a/lib/public/Authentication/Exceptions/WipeTokenException.php b/lib/public/Authentication/Exceptions/WipeTokenException.php new file mode 100644 index 00000000000..aa2da6739e6 --- /dev/null +++ b/lib/public/Authentication/Exceptions/WipeTokenException.php @@ -0,0 +1,40 @@ + + * + * @author Roeland Jago Douma + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +namespace OCP\Authentication\Exceptions; + +use OCP\Authentication\Token\IToken; + +class WipeTokenException extends InvalidTokenException { + public function __construct( + private IToken $token, + ) { + parent::__construct(); + } + + public function getToken(): IToken { + return $this->token; + } +} diff --git a/lib/public/Authentication/Token/IProvider.php b/lib/public/Authentication/Token/IProvider.php index 4c324d685b7..59d2b8f3649 100644 --- a/lib/public/Authentication/Token/IProvider.php +++ b/lib/public/Authentication/Token/IProvider.php @@ -24,6 +24,10 @@ declare(strict_types=1); */ namespace OCP\Authentication\Token; +use OCP\Authentication\Exceptions\ExpiredTokenException; +use OCP\Authentication\Exceptions\InvalidTokenException; +use OCP\Authentication\Exceptions\WipeTokenException; + /** * @since 24.0.8 */ -- cgit v1.2.3