diff options
Diffstat (limited to 'apps/workflowengine/lib/Check/RequestRemoteAddress.php')
-rw-r--r-- | apps/workflowengine/lib/Check/RequestRemoteAddress.php | 84 |
1 files changed, 41 insertions, 43 deletions
diff --git a/apps/workflowengine/lib/Check/RequestRemoteAddress.php b/apps/workflowengine/lib/Check/RequestRemoteAddress.php index de9738fb631..b6f8fef5aed 100644 --- a/apps/workflowengine/lib/Check/RequestRemoteAddress.php +++ b/apps/workflowengine/lib/Check/RequestRemoteAddress.php @@ -1,55 +1,25 @@ <?php + /** - * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> - * - * @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 <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ - namespace OCA\WorkflowEngine\Check; - -use OCP\Files\Storage\IStorage; use OCP\IL10N; use OCP\IRequest; use OCP\WorkflowEngine\ICheck; class RequestRemoteAddress implements ICheck { - /** @var IL10N */ - protected $l; - - /** @var IRequest */ - protected $request; - /** * @param IL10N $l * @param IRequest $request */ - public function __construct(IL10N $l, IRequest $request) { - $this->l = $l; - $this->request = $request; - } - - /** - * @param IStorage $storage - * @param string $path - */ - public function setFileInfo(IStorage $storage, $path) { - // A different path doesn't change time, so nothing to do here. + public function __construct( + protected IL10N $l, + protected IRequest $request, + ) { } /** @@ -63,9 +33,9 @@ class RequestRemoteAddress implements ICheck { if ($operator === 'matchesIPv4') { return $this->matchIPv4($actualValue, $decodedValue[0], $decodedValue[1]); - } else if ($operator === '!matchesIPv4') { + } elseif ($operator === '!matchesIPv4') { return !$this->matchIPv4($actualValue, $decodedValue[0], $decodedValue[1]); - } else if ($operator === 'matchesIPv6') { + } elseif ($operator === 'matchesIPv6') { return $this->matchIPv6($actualValue, $decodedValue[0], $decodedValue[1]); } else { return !$this->matchIPv6($actualValue, $decodedValue[0], $decodedValue[1]); @@ -83,7 +53,7 @@ class RequestRemoteAddress implements ICheck { } $decodedValue = explode('/', $value); - if (sizeof($decodedValue) !== 2) { + if (count($decodedValue) !== 2) { throw new \UnexpectedValueException($this->l->t('The given IP range is invalid'), 2); } @@ -105,7 +75,7 @@ class RequestRemoteAddress implements ICheck { } /** - * Based on http://stackoverflow.com/a/594134 + * Based on https://stackoverflow.com/a/594134 * @param string $ip * @param string $rangeIp * @param int $bits @@ -119,7 +89,7 @@ class RequestRemoteAddress implements ICheck { } /** - * Based on http://stackoverflow.com/a/7951507 + * Based on https://stackoverflow.com/a/7951507 * @param string $ip * @param string $rangeIp * @param int $bits @@ -138,7 +108,7 @@ class RequestRemoteAddress implements ICheck { } /** - * Based on http://stackoverflow.com/a/7951507 + * Based on https://stackoverflow.com/a/7951507 * @param string $packedIp * @return string */ @@ -151,4 +121,32 @@ class RequestRemoteAddress implements ICheck { } return str_pad($binaryIp, 128, '0', STR_PAD_RIGHT); } + + /** + * returns a list of Entities the checker supports. The values must match + * the class name of the entity. + * + * An empty result means the check is universally available. + * + * @since 18.0.0 + */ + public function supportedEntities(): array { + return []; + } + + /** + * returns whether the operation can be used in the requested scope. + * + * Scope IDs are defined as constants in OCP\WorkflowEngine\IManager. At + * time of writing these are SCOPE_ADMIN and SCOPE_USER. + * + * For possibly unknown future scopes the recommended behaviour is: if + * user scope is permitted, the default behaviour should return `true`, + * otherwise `false`. + * + * @since 18.0.0 + */ + public function isAvailableForScope(int $scope): bool { + return true; + } } |