| @@ 143-170 (lines=28) @@ | ||
| 140 | $vettedSecondFactors->getTotalItems() > 0; |
|
| 141 | } |
|
| 142 | ||
| 143 | public function identityHasSecondFactorOfStateWithId($identityId, $state, $secondFactorId) |
|
| 144 | { |
|
| 145 | switch ($state) { |
|
| 146 | case 'unverified': |
|
| 147 | $secondFactors = $this->findUnverifiedByIdentity($identityId); |
|
| 148 | break; |
|
| 149 | case 'verified': |
|
| 150 | $secondFactors = $this->findVerifiedByIdentity($identityId); |
|
| 151 | break; |
|
| 152 | case 'vetted': |
|
| 153 | $secondFactors = $this->findVettedByIdentity($identityId); |
|
| 154 | break; |
|
| 155 | default: |
|
| 156 | throw new LogicException(sprintf('Invalid second factor state "%s" given.', $state)); |
|
| 157 | } |
|
| 158 | ||
| 159 | if (count($secondFactors->getElements()) === 0) { |
|
| 160 | return false; |
|
| 161 | } |
|
| 162 | ||
| 163 | foreach ($secondFactors->getElements() as $secondFactor) { |
|
| 164 | if ($secondFactor->id === $secondFactorId) { |
|
| 165 | return true; |
|
| 166 | } |
|
| 167 | } |
|
| 168 | ||
| 169 | return false; |
|
| 170 | } |
|
| 171 | ||
| 172 | /** |
|
| 173 | * Tests if the identity owns a second factor token for a given state, with a satisfiable LoA |
|
| @@ 180-207 (lines=28) @@ | ||
| 177 | * @param Loa $loa |
|
| 178 | * @return bool |
|
| 179 | */ |
|
| 180 | public function identityHasSecondFactorOfStateWithMinimalLoa($identityId, $state, Loa $loa) |
|
| 181 | { |
|
| 182 | switch ($state) { |
|
| 183 | case 'unverified': |
|
| 184 | $secondFactors = $this->findUnverifiedByIdentity($identityId); |
|
| 185 | break; |
|
| 186 | case 'verified': |
|
| 187 | $secondFactors = $this->findVerifiedByIdentity($identityId); |
|
| 188 | break; |
|
| 189 | case 'vetted': |
|
| 190 | $secondFactors = $this->findVettedByIdentity($identityId); |
|
| 191 | break; |
|
| 192 | default: |
|
| 193 | throw new LogicException(sprintf('Invalid second factor state "%s" given.', $state)); |
|
| 194 | } |
|
| 195 | ||
| 196 | if (count($secondFactors->getElements()) === 0) { |
|
| 197 | return false; |
|
| 198 | } |
|
| 199 | ||
| 200 | foreach ($secondFactors->getElements() as $secondFactor) { |
|
| 201 | if ($this->secondFactorTypeService->canSatisfy(new SecondFactorType($secondFactor->type), $loa)) { |
|
| 202 | return true; |
|
| 203 | } |
|
| 204 | } |
|
| 205 | ||
| 206 | return false; |
|
| 207 | } |
|
| 208 | ||
| 209 | /** |
|
| 210 | * Returns the given registrant's unverified second factors. |
|