| 1: | <?php |
| 2: | /* |
| 3: | * SimpleID |
| 4: | * |
| 5: | * Copyright (C) Kelvin Mo 2023-2025 |
| 6: | * |
| 7: | * This program is free software; you can redistribute it and/or |
| 8: | * modify it under the terms of the GNU General Public |
| 9: | * License as published by the Free Software Foundation; either |
| 10: | * version 2 of the License, or (at your option) any later version. |
| 11: | * |
| 12: | * This program is distributed in the hope that it will be useful, |
| 13: | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14: | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15: | * General Public License for more details. |
| 16: | * |
| 17: | * You should have received a copy of the GNU General Public |
| 18: | * License along with this program; if not, write to the Free |
| 19: | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20: | * |
| 21: | */ |
| 22: | |
| 23: | namespace SimpleID\Protocols; |
| 24: | |
| 25: | use SimpleID\Base\AuditEvent; |
| 26: | use SimpleID\Models\Client; |
| 27: | use SimpleID\Models\User; |
| 28: | |
| 29: | /** |
| 30: | * Event trigging when a final, non-error assertion result is returned |
| 31: | * under an identity protocol. |
| 32: | * |
| 33: | */ |
| 34: | class ProtocolResultEvent extends AuditEvent implements ProtocolResult { |
| 35: | /** @var int */ |
| 36: | protected $result; |
| 37: | |
| 38: | /** |
| 39: | * Creates an event with an assertion result. |
| 40: | * |
| 41: | * The result must be one of the constants defined in |
| 42: | * {@link SimpleID\Protocols\ProtocolResult}. |
| 43: | * |
| 44: | * @param int $result the assertion result |
| 45: | * @param User $user the user the assertion result is about |
| 46: | * @param Client $client the client the assertion result is provided |
| 47: | * to |
| 48: | */ |
| 49: | public function __construct(int $result, User $user, Client $client) { |
| 50: | parent::__construct($user, $client); |
| 51: | $this->result = $result; |
| 52: | } |
| 53: | |
| 54: | /** |
| 55: | * Returns the assertion result. |
| 56: | * |
| 57: | * @return int the assertion result |
| 58: | */ |
| 59: | public function getResult() { |
| 60: | return $this->result; |
| 61: | } |
| 62: | |
| 63: | /** |
| 64: | * Returns the assertion result is positive. |
| 65: | * |
| 66: | * The assertion result is positive if it is equal to |
| 67: | * ProtocolResult::CHECKID_OK |
| 68: | * |
| 69: | * @return bool true if the assertion is positive |
| 70: | */ |
| 71: | public function isPositiveAssertion() { |
| 72: | return ($this->result == self::CHECKID_OK); |
| 73: | } |
| 74: | } |
| 75: | |
| 76: | ?> |