| @@ 39-177 (lines=139) @@ | ||
| 36 | /** |
|
| 37 | * @SuppressWarnings(PHPMD.CouplingBetweenObjects) |
|
| 38 | */ |
|
| 39 | class SecondFactorVettedEvent extends IdentityEvent implements Forgettable |
|
| 40 | { |
|
| 41 | /** |
|
| 42 | * @var \Surfnet\Stepup\Identity\Value\NameId |
|
| 43 | */ |
|
| 44 | public $nameId; |
|
| 45 | ||
| 46 | /** |
|
| 47 | * @var \Surfnet\Stepup\Identity\Value\SecondFactorId |
|
| 48 | */ |
|
| 49 | public $secondFactorId; |
|
| 50 | ||
| 51 | /** |
|
| 52 | * @var \Surfnet\StepupBundle\Value\SecondFactorType |
|
| 53 | */ |
|
| 54 | public $secondFactorType; |
|
| 55 | ||
| 56 | /** |
|
| 57 | * @var \Surfnet\Stepup\Identity\Value\SecondFactorIdentifier |
|
| 58 | */ |
|
| 59 | public $secondFactorIdentifier; |
|
| 60 | ||
| 61 | /** |
|
| 62 | * @var \Surfnet\Stepup\Identity\Value\DocumentNumber |
|
| 63 | */ |
|
| 64 | public $documentNumber; |
|
| 65 | ||
| 66 | /** |
|
| 67 | * @var \Surfnet\Stepup\Identity\Value\CommonName |
|
| 68 | */ |
|
| 69 | public $commonName; |
|
| 70 | ||
| 71 | /** |
|
| 72 | * @var \Surfnet\Stepup\Identity\Value\Email |
|
| 73 | */ |
|
| 74 | public $email; |
|
| 75 | ||
| 76 | /** |
|
| 77 | * @var \Surfnet\Stepup\Identity\Value\Locale Eg. "en_GB" |
|
| 78 | */ |
|
| 79 | public $preferredLocale; |
|
| 80 | ||
| 81 | /** |
|
| 82 | * @param IdentityId $identityId |
|
| 83 | * @param NameId $nameId |
|
| 84 | * @param Institution $institution |
|
| 85 | * @param SecondFactorId $secondFactorId |
|
| 86 | * @param SecondFactorType $secondFactorType |
|
| 87 | * @param SecondFactorIdentifier $secondFactorIdentifier |
|
| 88 | * @param DocumentNumber $documentNumber |
|
| 89 | * @param CommonName $commonName |
|
| 90 | * @param Email $email |
|
| 91 | * @param Locale $preferredLocale |
|
| 92 | * |
|
| 93 | * @SuppressWarnings(PHPMD.ExcessiveParameterList) |
|
| 94 | */ |
|
| 95 | public function __construct( |
|
| 96 | IdentityId $identityId, |
|
| 97 | NameId $nameId, |
|
| 98 | Institution $institution, |
|
| 99 | SecondFactorId $secondFactorId, |
|
| 100 | SecondFactorType $secondFactorType, |
|
| 101 | SecondFactorIdentifier $secondFactorIdentifier, |
|
| 102 | DocumentNumber $documentNumber, |
|
| 103 | CommonName $commonName, |
|
| 104 | Email $email, |
|
| 105 | Locale $preferredLocale |
|
| 106 | ) { |
|
| 107 | parent::__construct($identityId, $institution); |
|
| 108 | ||
| 109 | $this->nameId = $nameId; |
|
| 110 | $this->secondFactorId = $secondFactorId; |
|
| 111 | $this->secondFactorType = $secondFactorType; |
|
| 112 | $this->secondFactorIdentifier = $secondFactorIdentifier; |
|
| 113 | $this->documentNumber = $documentNumber; |
|
| 114 | $this->commonName = $commonName; |
|
| 115 | $this->email = $email; |
|
| 116 | $this->preferredLocale = $preferredLocale; |
|
| 117 | } |
|
| 118 | ||
| 119 | public function getAuditLogMetadata() |
|
| 120 | { |
|
| 121 | $metadata = new Metadata(); |
|
| 122 | $metadata->identityId = $this->identityId; |
|
| 123 | $metadata->identityInstitution = $this->identityInstitution; |
|
| 124 | $metadata->secondFactorId = $this->secondFactorId; |
|
| 125 | $metadata->secondFactorType = $this->secondFactorType; |
|
| 126 | $metadata->secondFactorIdentifier = $this->secondFactorIdentifier; |
|
| 127 | ||
| 128 | return $metadata; |
|
| 129 | } |
|
| 130 | ||
| 131 | public static function deserialize(array $data) |
|
| 132 | { |
|
| 133 | $secondFactorType = new SecondFactorType($data['second_factor_type']); |
|
| 134 | ||
| 135 | return new self( |
|
| 136 | new IdentityId($data['identity_id']), |
|
| 137 | new NameId($data['name_id']), |
|
| 138 | new Institution($data['identity_institution']), |
|
| 139 | new SecondFactorId($data['second_factor_id']), |
|
| 140 | $secondFactorType, |
|
| 141 | SecondFactorIdentifierFactory::unknownForType($secondFactorType), |
|
| 142 | DocumentNumber::unknown(), |
|
| 143 | CommonName::unknown(), |
|
| 144 | Email::unknown(), |
|
| 145 | new Locale($data['preferred_locale']) |
|
| 146 | ); |
|
| 147 | } |
|
| 148 | ||
| 149 | public function serialize(): array |
|
| 150 | { |
|
| 151 | return [ |
|
| 152 | 'identity_id' => (string) $this->identityId, |
|
| 153 | 'name_id' => (string) $this->nameId, |
|
| 154 | 'identity_institution' => (string) $this->identityInstitution, |
|
| 155 | 'second_factor_id' => (string) $this->secondFactorId, |
|
| 156 | 'second_factor_type' => (string) $this->secondFactorType, |
|
| 157 | 'preferred_locale' => (string) $this->preferredLocale, |
|
| 158 | ]; |
|
| 159 | } |
|
| 160 | ||
| 161 | public function getSensitiveData() |
|
| 162 | { |
|
| 163 | return (new SensitiveData) |
|
| 164 | ->withCommonName($this->commonName) |
|
| 165 | ->withEmail($this->email) |
|
| 166 | ->withSecondFactorIdentifier($this->secondFactorIdentifier, $this->secondFactorType) |
|
| 167 | ->withDocumentNumber($this->documentNumber); |
|
| 168 | } |
|
| 169 | ||
| 170 | public function setSensitiveData(SensitiveData $sensitiveData) |
|
| 171 | { |
|
| 172 | $this->email = $sensitiveData->getEmail(); |
|
| 173 | $this->commonName = $sensitiveData->getCommonName(); |
|
| 174 | $this->secondFactorIdentifier = $sensitiveData->getSecondFactorIdentifier(); |
|
| 175 | $this->documentNumber = $sensitiveData->getDocumentNumber(); |
|
| 176 | } |
|
| 177 | } |
|
| 178 | ||
| @@ 39-177 (lines=139) @@ | ||
| 36 | /** |
|
| 37 | * @SuppressWarnings(PHPMD.CouplingBetweenObjects) |
|
| 38 | */ |
|
| 39 | class SecondFactorVettedWithoutTokenProofOfPossession extends IdentityEvent implements Forgettable |
|
| 40 | { |
|
| 41 | /** |
|
| 42 | * @var \Surfnet\Stepup\Identity\Value\NameId |
|
| 43 | */ |
|
| 44 | public $nameId; |
|
| 45 | ||
| 46 | /** |
|
| 47 | * @var \Surfnet\Stepup\Identity\Value\SecondFactorId |
|
| 48 | */ |
|
| 49 | public $secondFactorId; |
|
| 50 | ||
| 51 | /** |
|
| 52 | * @var \Surfnet\StepupBundle\Value\SecondFactorType |
|
| 53 | */ |
|
| 54 | public $secondFactorType; |
|
| 55 | ||
| 56 | /** |
|
| 57 | * @var \Surfnet\Stepup\Identity\Value\SecondFactorIdentifier |
|
| 58 | */ |
|
| 59 | public $secondFactorIdentifier; |
|
| 60 | ||
| 61 | /** |
|
| 62 | * @var \Surfnet\Stepup\Identity\Value\DocumentNumber |
|
| 63 | */ |
|
| 64 | public $documentNumber; |
|
| 65 | ||
| 66 | /** |
|
| 67 | * @var \Surfnet\Stepup\Identity\Value\CommonName |
|
| 68 | */ |
|
| 69 | public $commonName; |
|
| 70 | ||
| 71 | /** |
|
| 72 | * @var \Surfnet\Stepup\Identity\Value\Email |
|
| 73 | */ |
|
| 74 | public $email; |
|
| 75 | ||
| 76 | /** |
|
| 77 | * @var \Surfnet\Stepup\Identity\Value\Locale Eg. "en_GB" |
|
| 78 | */ |
|
| 79 | public $preferredLocale; |
|
| 80 | ||
| 81 | /** |
|
| 82 | * @param IdentityId $identityId |
|
| 83 | * @param NameId $nameId |
|
| 84 | * @param Institution $institution |
|
| 85 | * @param SecondFactorId $secondFactorId |
|
| 86 | * @param SecondFactorType $secondFactorType |
|
| 87 | * @param SecondFactorIdentifier $secondFactorIdentifier |
|
| 88 | * @param DocumentNumber $documentNumber |
|
| 89 | * @param CommonName $commonName |
|
| 90 | * @param Email $email |
|
| 91 | * @param Locale $preferredLocale |
|
| 92 | * |
|
| 93 | * @SuppressWarnings(PHPMD.ExcessiveParameterList) |
|
| 94 | */ |
|
| 95 | public function __construct( |
|
| 96 | IdentityId $identityId, |
|
| 97 | NameId $nameId, |
|
| 98 | Institution $institution, |
|
| 99 | SecondFactorId $secondFactorId, |
|
| 100 | SecondFactorType $secondFactorType, |
|
| 101 | SecondFactorIdentifier $secondFactorIdentifier, |
|
| 102 | DocumentNumber $documentNumber, |
|
| 103 | CommonName $commonName, |
|
| 104 | Email $email, |
|
| 105 | Locale $preferredLocale |
|
| 106 | ) { |
|
| 107 | parent::__construct($identityId, $institution); |
|
| 108 | ||
| 109 | $this->nameId = $nameId; |
|
| 110 | $this->secondFactorId = $secondFactorId; |
|
| 111 | $this->secondFactorType = $secondFactorType; |
|
| 112 | $this->secondFactorIdentifier = $secondFactorIdentifier; |
|
| 113 | $this->documentNumber = $documentNumber; |
|
| 114 | $this->commonName = $commonName; |
|
| 115 | $this->email = $email; |
|
| 116 | $this->preferredLocale = $preferredLocale; |
|
| 117 | } |
|
| 118 | ||
| 119 | public function getAuditLogMetadata() |
|
| 120 | { |
|
| 121 | $metadata = new Metadata(); |
|
| 122 | $metadata->identityId = $this->identityId; |
|
| 123 | $metadata->identityInstitution = $this->identityInstitution; |
|
| 124 | $metadata->secondFactorId = $this->secondFactorId; |
|
| 125 | $metadata->secondFactorType = $this->secondFactorType; |
|
| 126 | $metadata->secondFactorIdentifier = $this->secondFactorIdentifier; |
|
| 127 | ||
| 128 | return $metadata; |
|
| 129 | } |
|
| 130 | ||
| 131 | public static function deserialize(array $data) |
|
| 132 | { |
|
| 133 | $secondFactorType = new SecondFactorType($data['second_factor_type']); |
|
| 134 | ||
| 135 | return new self( |
|
| 136 | new IdentityId($data['identity_id']), |
|
| 137 | new NameId($data['name_id']), |
|
| 138 | new Institution($data['identity_institution']), |
|
| 139 | new SecondFactorId($data['second_factor_id']), |
|
| 140 | $secondFactorType, |
|
| 141 | SecondFactorIdentifierFactory::unknownForType($secondFactorType), |
|
| 142 | DocumentNumber::unknown(), |
|
| 143 | CommonName::unknown(), |
|
| 144 | Email::unknown(), |
|
| 145 | new Locale($data['preferred_locale']) |
|
| 146 | ); |
|
| 147 | } |
|
| 148 | ||
| 149 | public function serialize(): array |
|
| 150 | { |
|
| 151 | return [ |
|
| 152 | 'identity_id' => (string) $this->identityId, |
|
| 153 | 'name_id' => (string) $this->nameId, |
|
| 154 | 'identity_institution' => (string) $this->identityInstitution, |
|
| 155 | 'second_factor_id' => (string) $this->secondFactorId, |
|
| 156 | 'second_factor_type' => (string) $this->secondFactorType, |
|
| 157 | 'preferred_locale' => (string) $this->preferredLocale, |
|
| 158 | ]; |
|
| 159 | } |
|
| 160 | ||
| 161 | public function getSensitiveData() |
|
| 162 | { |
|
| 163 | return (new SensitiveData) |
|
| 164 | ->withCommonName($this->commonName) |
|
| 165 | ->withEmail($this->email) |
|
| 166 | ->withSecondFactorIdentifier($this->secondFactorIdentifier, $this->secondFactorType) |
|
| 167 | ->withDocumentNumber($this->documentNumber); |
|
| 168 | } |
|
| 169 | ||
| 170 | public function setSensitiveData(SensitiveData $sensitiveData) |
|
| 171 | { |
|
| 172 | $this->email = $sensitiveData->getEmail(); |
|
| 173 | $this->commonName = $sensitiveData->getCommonName(); |
|
| 174 | $this->secondFactorIdentifier = $sensitiveData->getSecondFactorIdentifier(); |
|
| 175 | $this->documentNumber = $sensitiveData->getDocumentNumber(); |
|
| 176 | } |
|
| 177 | } |
|
| 178 | ||