| 1: | <?php |
| 2: | /* |
| 3: | * SimpleID |
| 4: | * |
| 5: | * Copyright (C) Kelvin Mo 2021-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\Connect; |
| 24: | |
| 25: | use SimpleID\Models\Client; |
| 26: | use SimpleID\Models\User; |
| 27: | use SimpleID\Util\Events\BaseDataCollectionEvent; |
| 28: | |
| 29: | /** |
| 30: | * Event to collect a set of claims to be included in an ID token or UserInfo response |
| 31: | * |
| 32: | */ |
| 33: | class ConnectBuildClaimsEvent extends BaseDataCollectionEvent { |
| 34: | /** @var User */ |
| 35: | protected $user; |
| 36: | |
| 37: | /** @var Client */ |
| 38: | protected $client; |
| 39: | |
| 40: | /** @var string */ |
| 41: | protected $context; |
| 42: | |
| 43: | /** @var array<string> */ |
| 44: | protected $scope; |
| 45: | |
| 46: | /** @var array<string, mixed>|null */ |
| 47: | protected $claims_requested; |
| 48: | |
| 49: | /** |
| 50: | * @param User $user |
| 51: | * @param Client $client |
| 52: | * @param string $context |
| 53: | * @param array<string> $scope |
| 54: | * @param array<string, mixed>|null $claims_requested |
| 55: | */ |
| 56: | public function __construct(User $user, Client $client, $context, $scope, $claims_requested = NULL) { |
| 57: | parent::__construct(); |
| 58: | |
| 59: | $this->user = $user; |
| 60: | $this->client = $client; |
| 61: | $this->context = $context; |
| 62: | $this->scope = $scope; |
| 63: | $this->claims_requested = $claims_requested; |
| 64: | } |
| 65: | |
| 66: | /** |
| 67: | * Returns the user about which the ID token is created |
| 68: | * |
| 69: | * @return User the user about which the ID |
| 70: | * token is created |
| 71: | */ |
| 72: | public function getUser() { |
| 73: | return $this->user; |
| 74: | } |
| 75: | |
| 76: | /** |
| 77: | * Returns the client to which the ID token will be |
| 78: | * sent. |
| 79: | * |
| 80: | * @return Client the client to which the |
| 81: | * ID token will be sent |
| 82: | */ |
| 83: | public function getClient() { |
| 84: | return $this->client; |
| 85: | } |
| 86: | |
| 87: | /** |
| 88: | * Returns the context. |
| 89: | * |
| 90: | * This is either `id_token` or `userinfo` |
| 91: | * |
| 92: | * @return string the context |
| 93: | */ |
| 94: | public function getContext() { |
| 95: | return $this->context; |
| 96: | } |
| 97: | |
| 98: | /** |
| 99: | * Returns the scope for the response. |
| 100: | * |
| 101: | * @return array<string> the scope |
| 102: | */ |
| 103: | public function getScope() { |
| 104: | return $this->scope; |
| 105: | } |
| 106: | |
| 107: | /** |
| 108: | * Returns the specific claims requested, if any |
| 109: | * |
| 110: | * @return array<string, mixed>|null an array of claims or null |
| 111: | */ |
| 112: | public function getRequestedClaims() { |
| 113: | return $this->claims_requested; |
| 114: | } |
| 115: | } |
| 116: | |
| 117: | ?> |