2019-12-03 13:57:53 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2019-11-19 13:18:00 -05:00
|
|
|
|
|
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2019-11-19 13:18:00 -05:00
|
|
|
*/
|
|
|
|
|
namespace OCP\Security\Events;
|
|
|
|
|
|
|
|
|
|
use OCP\EventDispatcher\Event;
|
2024-08-21 14:23:27 -04:00
|
|
|
use OCP\Security\PasswordContext;
|
2019-11-19 13:18:00 -05:00
|
|
|
|
|
|
|
|
/**
|
2024-08-21 14:23:27 -04:00
|
|
|
* This event can be emitted to request a validation of a password.
|
|
|
|
|
*
|
|
|
|
|
* If a password policy app is installed and the password
|
|
|
|
|
* is invalid, an `\OCP\HintException` will be thrown.
|
2019-11-19 13:18:00 -05:00
|
|
|
* @since 18.0.0
|
|
|
|
|
*/
|
|
|
|
|
class ValidatePasswordPolicyEvent extends Event {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 18.0.0
|
2024-08-21 14:23:27 -04:00
|
|
|
* @since 31.0.0 - $context parameter added
|
2019-11-19 13:18:00 -05:00
|
|
|
*/
|
2024-08-21 14:23:27 -04:00
|
|
|
public function __construct(
|
|
|
|
|
private string $password,
|
|
|
|
|
private PasswordContext $context = PasswordContext::ACCOUNT,
|
|
|
|
|
) {
|
2019-11-19 13:18:00 -05:00
|
|
|
parent::__construct();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-08-21 14:23:27 -04:00
|
|
|
* Get the password that should be validated.
|
2019-11-19 13:18:00 -05:00
|
|
|
* @since 18.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function getPassword(): string {
|
|
|
|
|
return $this->password;
|
|
|
|
|
}
|
2024-08-21 14:23:27 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the context this password should validated for.
|
|
|
|
|
* @since 31.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function getContext(): PasswordContext {
|
|
|
|
|
return $this->context;
|
|
|
|
|
}
|
2019-11-19 13:18:00 -05:00
|
|
|
}
|