| @@ 31-112 (lines=82) @@ | ||
| 28 | use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable; |
|
| 29 | use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData; |
|
| 30 | ||
| 31 | class IdentityCreatedEvent extends IdentityEvent implements Forgettable |
|
| 32 | { |
|
| 33 | /** |
|
| 34 | * @var NameId |
|
| 35 | */ |
|
| 36 | public $nameId; |
|
| 37 | ||
| 38 | /** |
|
| 39 | * @var \Surfnet\Stepup\Identity\Value\CommonName |
|
| 40 | */ |
|
| 41 | public $commonName; |
|
| 42 | ||
| 43 | /** |
|
| 44 | * @var \Surfnet\Stepup\Identity\Value\Email |
|
| 45 | */ |
|
| 46 | public $email; |
|
| 47 | ||
| 48 | /** |
|
| 49 | * @var \Surfnet\Stepup\Identity\Value\Locale |
|
| 50 | */ |
|
| 51 | public $preferredLocale; |
|
| 52 | ||
| 53 | public function __construct( |
|
| 54 | IdentityId $id, |
|
| 55 | Institution $institution, |
|
| 56 | NameId $nameId, |
|
| 57 | CommonName $commonName, |
|
| 58 | Email $email, |
|
| 59 | Locale $preferredLocale |
|
| 60 | ) { |
|
| 61 | parent::__construct($id, $institution); |
|
| 62 | ||
| 63 | $this->nameId = $nameId; |
|
| 64 | $this->commonName = $commonName; |
|
| 65 | $this->email = $email; |
|
| 66 | $this->preferredLocale = $preferredLocale; |
|
| 67 | } |
|
| 68 | ||
| 69 | public function getAuditLogMetadata() |
|
| 70 | { |
|
| 71 | $metadata = new Metadata(); |
|
| 72 | $metadata->identityId = $this->identityId; |
|
| 73 | $metadata->identityInstitution = $this->identityInstitution; |
|
| 74 | ||
| 75 | return $metadata; |
|
| 76 | } |
|
| 77 | ||
| 78 | public static function deserialize(array $data) |
|
| 79 | { |
|
| 80 | return new self( |
|
| 81 | new IdentityId($data['id']), |
|
| 82 | new Institution($data['institution']), |
|
| 83 | new NameId($data['name_id']), |
|
| 84 | CommonName::unknown(), |
|
| 85 | Email::unknown(), |
|
| 86 | new Locale($data['preferred_locale']) |
|
| 87 | ); |
|
| 88 | } |
|
| 89 | ||
| 90 | public function serialize() |
|
| 91 | { |
|
| 92 | return [ |
|
| 93 | 'id' => (string) $this->identityId, |
|
| 94 | 'institution' => (string) $this->identityInstitution, |
|
| 95 | 'name_id' => (string) $this->nameId, |
|
| 96 | 'preferred_locale' => (string) $this->preferredLocale, |
|
| 97 | ]; |
|
| 98 | } |
|
| 99 | ||
| 100 | public function getSensitiveData() |
|
| 101 | { |
|
| 102 | return (new SensitiveData) |
|
| 103 | ->withCommonName($this->commonName) |
|
| 104 | ->withEmail($this->email); |
|
| 105 | } |
|
| 106 | ||
| 107 | public function setSensitiveData(SensitiveData $sensitiveData) |
|
| 108 | { |
|
| 109 | $this->email = $sensitiveData->getEmail(); |
|
| 110 | $this->commonName = $sensitiveData->getCommonName(); |
|
| 111 | } |
|
| 112 | } |
|
| 113 | ||
| @@ 30-111 (lines=82) @@ | ||
| 27 | use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable; |
|
| 28 | use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData; |
|
| 29 | ||
| 30 | class RegistrationAuthorityRetractedForInstitutionEvent extends IdentityEvent implements Forgettable |
|
| 31 | { |
|
| 32 | /** |
|
| 33 | * @var NameId |
|
| 34 | */ |
|
| 35 | public $nameId; |
|
| 36 | ||
| 37 | /** |
|
| 38 | * @var CommonName |
|
| 39 | */ |
|
| 40 | public $commonName; |
|
| 41 | ||
| 42 | /** |
|
| 43 | * @var Email |
|
| 44 | */ |
|
| 45 | public $email; |
|
| 46 | ||
| 47 | /** |
|
| 48 | * @var Institution |
|
| 49 | */ |
|
| 50 | public $raInstitution; |
|
| 51 | ||
| 52 | public function __construct( |
|
| 53 | IdentityId $identityId, |
|
| 54 | Institution $institution, |
|
| 55 | NameId $nameId, |
|
| 56 | CommonName $commonName, |
|
| 57 | Email $email, |
|
| 58 | Institution $raInstitution |
|
| 59 | ) { |
|
| 60 | parent::__construct($identityId, $institution); |
|
| 61 | ||
| 62 | $this->nameId = $nameId; |
|
| 63 | $this->commonName = $commonName; |
|
| 64 | $this->email = $email; |
|
| 65 | $this->raInstitution = $raInstitution; |
|
| 66 | } |
|
| 67 | ||
| 68 | public function getAuditLogMetadata() |
|
| 69 | { |
|
| 70 | $metadata = new Metadata(); |
|
| 71 | $metadata->identityId = $this->identityId; |
|
| 72 | $metadata->identityInstitution = $this->identityInstitution; |
|
| 73 | ||
| 74 | return $metadata; |
|
| 75 | } |
|
| 76 | ||
| 77 | public static function deserialize(array $data) |
|
| 78 | { |
|
| 79 | return new self( |
|
| 80 | new IdentityId($data['identity_id']), |
|
| 81 | new Institution($data['identity_institution']), |
|
| 82 | new NameId($data['name_id']), |
|
| 83 | CommonName::unknown(), |
|
| 84 | Email::unknown(), |
|
| 85 | new Institution($data['ra_institution']) |
|
| 86 | ); |
|
| 87 | } |
|
| 88 | ||
| 89 | public function serialize() |
|
| 90 | { |
|
| 91 | return [ |
|
| 92 | 'identity_id' => (string) $this->identityId, |
|
| 93 | 'identity_institution' => (string) $this->identityInstitution, |
|
| 94 | 'name_id' => (string) $this->nameId, |
|
| 95 | 'ra_institution' => (string) $this->raInstitution, |
|
| 96 | ]; |
|
| 97 | } |
|
| 98 | ||
| 99 | public function getSensitiveData() |
|
| 100 | { |
|
| 101 | return (new SensitiveData) |
|
| 102 | ->withCommonName($this->commonName) |
|
| 103 | ->withEmail($this->email); |
|
| 104 | } |
|
| 105 | ||
| 106 | public function setSensitiveData(SensitiveData $sensitiveData) |
|
| 107 | { |
|
| 108 | $this->email = $sensitiveData->getEmail(); |
|
| 109 | $this->commonName = $sensitiveData->getCommonName(); |
|
| 110 | } |
|
| 111 | } |
|
| 112 | ||