@@ 34-157 (lines=124) @@ | ||
31 | use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable; |
|
32 | use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData; |
|
33 | ||
34 | class PhonePossessionProvenEvent extends IdentityEvent implements Forgettable |
|
35 | { |
|
36 | /** |
|
37 | * @var \Surfnet\Stepup\Identity\Value\SecondFactorId |
|
38 | */ |
|
39 | public $secondFactorId; |
|
40 | ||
41 | /** |
|
42 | * @var \Surfnet\Stepup\Identity\Value\PhoneNumber |
|
43 | */ |
|
44 | public $phoneNumber; |
|
45 | ||
46 | /** |
|
47 | * @var \Surfnet\Stepup\Identity\Value\EmailVerificationWindow |
|
48 | */ |
|
49 | public $emailVerificationWindow; |
|
50 | ||
51 | /** |
|
52 | * @var string |
|
53 | */ |
|
54 | public $emailVerificationNonce; |
|
55 | ||
56 | /** |
|
57 | * @var \Surfnet\Stepup\Identity\Value\CommonName |
|
58 | */ |
|
59 | public $commonName; |
|
60 | ||
61 | /** |
|
62 | * @var \Surfnet\Stepup\Identity\Value\Email |
|
63 | */ |
|
64 | public $email; |
|
65 | ||
66 | /** |
|
67 | * @var \Surfnet\Stepup\Identity\Value\Locale Eg. "en_GB" |
|
68 | */ |
|
69 | public $preferredLocale; |
|
70 | ||
71 | /** |
|
72 | * @param IdentityId $identityId |
|
73 | * @param Institution $identityInstitution |
|
74 | * @param SecondFactorId $secondFactorId |
|
75 | * @param PhoneNumber $phoneNumber |
|
76 | * @param EmailVerificationWindow $emailVerificationWindow |
|
77 | * @param string $emailVerificationNonce |
|
78 | * @param CommonName $commonName |
|
79 | * @param Email $email |
|
80 | * @param Locale $preferredLocale |
|
81 | */ |
|
82 | public function __construct( |
|
83 | IdentityId $identityId, |
|
84 | Institution $identityInstitution, |
|
85 | SecondFactorId $secondFactorId, |
|
86 | PhoneNumber $phoneNumber, |
|
87 | EmailVerificationWindow $emailVerificationWindow, |
|
88 | $emailVerificationNonce, |
|
89 | CommonName $commonName, |
|
90 | Email $email, |
|
91 | Locale $preferredLocale |
|
92 | ) { |
|
93 | parent::__construct($identityId, $identityInstitution); |
|
94 | ||
95 | $this->secondFactorId = $secondFactorId; |
|
96 | $this->phoneNumber = $phoneNumber; |
|
97 | $this->emailVerificationWindow = $emailVerificationWindow; |
|
98 | $this->emailVerificationNonce = $emailVerificationNonce; |
|
99 | $this->commonName = $commonName; |
|
100 | $this->email = $email; |
|
101 | $this->preferredLocale = $preferredLocale; |
|
102 | } |
|
103 | ||
104 | public function getAuditLogMetadata() |
|
105 | { |
|
106 | $metadata = new Metadata(); |
|
107 | $metadata->identityId = $this->identityId; |
|
108 | $metadata->identityInstitution = $this->identityInstitution; |
|
109 | $metadata->secondFactorId = $this->secondFactorId; |
|
110 | $metadata->secondFactorType = new SecondFactorType('sms'); |
|
111 | $metadata->secondFactorIdentifier = $this->phoneNumber; |
|
112 | ||
113 | return $metadata; |
|
114 | } |
|
115 | ||
116 | public static function deserialize(array $data) |
|
117 | { |
|
118 | return new self( |
|
119 | new IdentityId($data['identity_id']), |
|
120 | new Institution($data['identity_institution']), |
|
121 | new SecondFactorId($data['second_factor_id']), |
|
122 | PhoneNumber::unknown(), |
|
123 | EmailVerificationWindow::deserialize($data['email_verification_window']), |
|
124 | $data['email_verification_nonce'], |
|
125 | CommonName::unknown(), |
|
126 | Email::unknown(), |
|
127 | new Locale($data['preferred_locale']) |
|
128 | ); |
|
129 | } |
|
130 | ||
131 | public function serialize() |
|
132 | { |
|
133 | return [ |
|
134 | 'identity_id' => (string) $this->identityId, |
|
135 | 'identity_institution' => (string) $this->identityInstitution, |
|
136 | 'second_factor_id' => (string) $this->secondFactorId, |
|
137 | 'email_verification_window' => $this->emailVerificationWindow->serialize(), |
|
138 | 'email_verification_nonce' => (string) $this->emailVerificationNonce, |
|
139 | 'preferred_locale' => (string) $this->preferredLocale, |
|
140 | ]; |
|
141 | } |
|
142 | ||
143 | public function getSensitiveData() |
|
144 | { |
|
145 | return (new SensitiveData) |
|
146 | ->withCommonName($this->commonName) |
|
147 | ->withEmail($this->email) |
|
148 | ->withSecondFactorIdentifier($this->phoneNumber, new SecondFactorType('sms')); |
|
149 | } |
|
150 | ||
151 | public function setSensitiveData(SensitiveData $sensitiveData) |
|
152 | { |
|
153 | $this->email = $sensitiveData->getEmail(); |
|
154 | $this->commonName = $sensitiveData->getCommonName(); |
|
155 | $this->phoneNumber = $sensitiveData->getSecondFactorIdentifier(); |
|
156 | } |
|
157 | } |
|
158 |
@@ 34-157 (lines=124) @@ | ||
31 | use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable; |
|
32 | use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData; |
|
33 | ||
34 | class U2fDevicePossessionProvenEvent extends IdentityEvent implements Forgettable |
|
35 | { |
|
36 | /** |
|
37 | * @var \Surfnet\Stepup\Identity\Value\SecondFactorId |
|
38 | */ |
|
39 | public $secondFactorId; |
|
40 | ||
41 | /** |
|
42 | * @var \Surfnet\Stepup\Identity\Value\U2fKeyHandle |
|
43 | */ |
|
44 | public $keyHandle; |
|
45 | ||
46 | /** |
|
47 | * @var \Surfnet\Stepup\Identity\Value\EmailVerificationWindow |
|
48 | */ |
|
49 | public $emailVerificationWindow; |
|
50 | ||
51 | /** |
|
52 | * @var string |
|
53 | */ |
|
54 | public $emailVerificationNonce; |
|
55 | ||
56 | /** |
|
57 | * @var \Surfnet\Stepup\Identity\Value\CommonName |
|
58 | */ |
|
59 | public $commonName; |
|
60 | ||
61 | /** |
|
62 | * @var \Surfnet\Stepup\Identity\Value\Email |
|
63 | */ |
|
64 | public $email; |
|
65 | ||
66 | /** |
|
67 | * @var \Surfnet\Stepup\Identity\Value\Locale Eg. "en_GB" |
|
68 | */ |
|
69 | public $preferredLocale; |
|
70 | ||
71 | /** |
|
72 | * @param IdentityId $identityId |
|
73 | * @param Institution $identityInstitution |
|
74 | * @param SecondFactorId $secondFactorId |
|
75 | * @param U2fKeyHandle $keyHandle |
|
76 | * @param EmailVerificationWindow $emailVerificationWindow |
|
77 | * @param string $emailVerificationNonce |
|
78 | * @param CommonName $commonName |
|
79 | * @param Email $email |
|
80 | * @param Locale $preferredLocale |
|
81 | */ |
|
82 | public function __construct( |
|
83 | IdentityId $identityId, |
|
84 | Institution $identityInstitution, |
|
85 | SecondFactorId $secondFactorId, |
|
86 | U2fKeyHandle $keyHandle, |
|
87 | EmailVerificationWindow $emailVerificationWindow, |
|
88 | $emailVerificationNonce, |
|
89 | CommonName $commonName, |
|
90 | Email $email, |
|
91 | Locale $preferredLocale |
|
92 | ) { |
|
93 | parent::__construct($identityId, $identityInstitution); |
|
94 | ||
95 | $this->secondFactorId = $secondFactorId; |
|
96 | $this->keyHandle = $keyHandle; |
|
97 | $this->emailVerificationWindow = $emailVerificationWindow; |
|
98 | $this->emailVerificationNonce = $emailVerificationNonce; |
|
99 | $this->commonName = $commonName; |
|
100 | $this->email = $email; |
|
101 | $this->preferredLocale = $preferredLocale; |
|
102 | } |
|
103 | ||
104 | public function getAuditLogMetadata() |
|
105 | { |
|
106 | $metadata = new Metadata(); |
|
107 | $metadata->identityId = $this->identityId; |
|
108 | $metadata->identityInstitution = $this->identityInstitution; |
|
109 | $metadata->secondFactorId = $this->secondFactorId; |
|
110 | $metadata->secondFactorType = new SecondFactorType('sms'); |
|
111 | $metadata->secondFactorIdentifier = $this->keyHandle; |
|
112 | ||
113 | return $metadata; |
|
114 | } |
|
115 | ||
116 | public static function deserialize(array $data) |
|
117 | { |
|
118 | return new self( |
|
119 | new IdentityId($data['identity_id']), |
|
120 | new Institution($data['identity_institution']), |
|
121 | new SecondFactorId($data['second_factor_id']), |
|
122 | U2fKeyHandle::unknown(), |
|
123 | EmailVerificationWindow::deserialize($data['email_verification_window']), |
|
124 | $data['email_verification_nonce'], |
|
125 | CommonName::unknown(), |
|
126 | Email::unknown(), |
|
127 | new Locale($data['preferred_locale']) |
|
128 | ); |
|
129 | } |
|
130 | ||
131 | public function serialize() |
|
132 | { |
|
133 | return [ |
|
134 | 'identity_id' => (string) $this->identityId, |
|
135 | 'identity_institution' => (string) $this->identityInstitution, |
|
136 | 'second_factor_id' => (string) $this->secondFactorId, |
|
137 | 'email_verification_window' => $this->emailVerificationWindow->serialize(), |
|
138 | 'email_verification_nonce' => (string) $this->emailVerificationNonce, |
|
139 | 'preferred_locale' => (string) $this->preferredLocale, |
|
140 | ]; |
|
141 | } |
|
142 | ||
143 | public function getSensitiveData() |
|
144 | { |
|
145 | return (new SensitiveData) |
|
146 | ->withCommonName($this->commonName) |
|
147 | ->withEmail($this->email) |
|
148 | ->withSecondFactorIdentifier($this->keyHandle, new SecondFactorType('u2f')); |
|
149 | } |
|
150 | ||
151 | public function setSensitiveData(SensitiveData $sensitiveData) |
|
152 | { |
|
153 | $this->email = $sensitiveData->getEmail(); |
|
154 | $this->commonName = $sensitiveData->getCommonName(); |
|
155 | $this->keyHandle = $sensitiveData->getSecondFactorIdentifier(); |
|
156 | } |
|
157 | } |
|
158 |
@@ 34-164 (lines=131) @@ | ||
31 | use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable; |
|
32 | use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData; |
|
33 | ||
34 | class YubikeyPossessionProvenEvent extends IdentityEvent implements Forgettable |
|
35 | { |
|
36 | /** |
|
37 | * @var \Surfnet\Stepup\Identity\Value\SecondFactorId |
|
38 | */ |
|
39 | public $secondFactorId; |
|
40 | ||
41 | /** |
|
42 | * The Yubikey's public ID. |
|
43 | * |
|
44 | * @var \Surfnet\Stepup\Identity\Value\YubikeyPublicId |
|
45 | */ |
|
46 | public $yubikeyPublicId; |
|
47 | ||
48 | /** |
|
49 | * @var \Surfnet\Stepup\DateTime\DateTime |
|
50 | */ |
|
51 | public $emailVerificationRequestedAt; |
|
52 | ||
53 | /** |
|
54 | * @var \Surfnet\Stepup\Identity\Value\EmailVerificationWindow |
|
55 | */ |
|
56 | public $emailVerificationWindow; |
|
57 | ||
58 | /** |
|
59 | * @var string |
|
60 | */ |
|
61 | public $emailVerificationNonce; |
|
62 | ||
63 | /** |
|
64 | * @var \Surfnet\Stepup\Identity\Value\CommonName |
|
65 | */ |
|
66 | public $commonName; |
|
67 | ||
68 | /** |
|
69 | * @var \Surfnet\Stepup\Identity\Value\Email |
|
70 | */ |
|
71 | public $email; |
|
72 | ||
73 | /** |
|
74 | * @var \Surfnet\Stepup\Identity\Value\Locale Eg. "en_GB" |
|
75 | */ |
|
76 | public $preferredLocale; |
|
77 | ||
78 | /** |
|
79 | * @param IdentityId $identityId |
|
80 | * @param Institution $institution |
|
81 | * @param SecondFactorId $secondFactorId |
|
82 | * @param YubikeyPublicId $yubikeyPublicId |
|
83 | * @param EmailVerificationWindow $emailVerificationWindow |
|
84 | * @param string $emailVerificationNonce |
|
85 | * @param CommonName $commonName |
|
86 | * @param Email $email |
|
87 | * @param Locale $preferredLocale |
|
88 | */ |
|
89 | public function __construct( |
|
90 | IdentityId $identityId, |
|
91 | Institution $institution, |
|
92 | SecondFactorId $secondFactorId, |
|
93 | YubikeyPublicId $yubikeyPublicId, |
|
94 | EmailVerificationWindow $emailVerificationWindow, |
|
95 | $emailVerificationNonce, |
|
96 | CommonName $commonName, |
|
97 | Email $email, |
|
98 | Locale $preferredLocale |
|
99 | ) { |
|
100 | parent::__construct($identityId, $institution); |
|
101 | ||
102 | $this->secondFactorId = $secondFactorId; |
|
103 | $this->yubikeyPublicId = $yubikeyPublicId; |
|
104 | $this->emailVerificationWindow = $emailVerificationWindow; |
|
105 | $this->emailVerificationNonce = $emailVerificationNonce; |
|
106 | $this->commonName = $commonName; |
|
107 | $this->email = $email; |
|
108 | $this->preferredLocale = $preferredLocale; |
|
109 | } |
|
110 | ||
111 | public function getAuditLogMetadata() |
|
112 | { |
|
113 | $metadata = new Metadata(); |
|
114 | $metadata->identityId = $this->identityId; |
|
115 | $metadata->identityInstitution = $this->identityInstitution; |
|
116 | $metadata->secondFactorId = $this->secondFactorId; |
|
117 | $metadata->secondFactorType = new SecondFactorType('yubikey'); |
|
118 | $metadata->secondFactorIdentifier = $this->yubikeyPublicId; |
|
119 | ||
120 | return $metadata; |
|
121 | } |
|
122 | ||
123 | public static function deserialize(array $data) |
|
124 | { |
|
125 | return new self( |
|
126 | new IdentityId($data['identity_id']), |
|
127 | new Institution($data['identity_institution']), |
|
128 | new SecondFactorId($data['second_factor_id']), |
|
129 | YubikeyPublicId::unknown(), |
|
130 | EmailVerificationWindow::deserialize($data['email_verification_window']), |
|
131 | $data['email_verification_nonce'], |
|
132 | CommonName::unknown(), |
|
133 | Email::unknown(), |
|
134 | new Locale($data['preferred_locale']) |
|
135 | ); |
|
136 | } |
|
137 | ||
138 | public function serialize() |
|
139 | { |
|
140 | return [ |
|
141 | 'identity_id' => (string) $this->identityId, |
|
142 | 'identity_institution' => (string) $this->identityInstitution, |
|
143 | 'second_factor_id' => (string) $this->secondFactorId, |
|
144 | 'email_verification_window' => $this->emailVerificationWindow->serialize(), |
|
145 | 'email_verification_nonce' => (string) $this->emailVerificationNonce, |
|
146 | 'preferred_locale' => (string) $this->preferredLocale, |
|
147 | ]; |
|
148 | } |
|
149 | ||
150 | public function getSensitiveData() |
|
151 | { |
|
152 | return (new SensitiveData) |
|
153 | ->withCommonName($this->commonName) |
|
154 | ->withEmail($this->email) |
|
155 | ->withSecondFactorIdentifier($this->yubikeyPublicId, new SecondFactorType('yubikey')); |
|
156 | } |
|
157 | ||
158 | public function setSensitiveData(SensitiveData $sensitiveData) |
|
159 | { |
|
160 | $this->email = $sensitiveData->getEmail(); |
|
161 | $this->commonName = $sensitiveData->getCommonName(); |
|
162 | $this->yubikeyPublicId = $sensitiveData->getSecondFactorIdentifier(); |
|
163 | } |
|
164 | } |
|
165 |