[MS-1352] MFID: Accessing a correct scanned credential field to build an Identification response#1594
Conversation
…entification response
There was a problem hiding this comment.
Pull request overview
This pull request fixes a bug in the Multi-Factor ID (MFID) feature where the identification response was using the original scanned credential value instead of the edited value when a user modified a scanned credential.
Changes:
- Fixed
CreateIdentifyResponseUseCaseto use thecredentialfield (edited, tokenized value) instead ofscannedValue(original scanned value) - Added
TokenizationProcessordependency to decrypt the credential before including it in the response - Updated all test signatures to include the new
projectandtokenizationProcessorparameters
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/usecases/response/CreateIdentifyResponseUseCase.kt | Core bug fix: changed from using scannedValue to decrypting the credential field; added TokenizationProcessor dependency |
| feature/orchestrator/src/main/java/com/simprints/feature/orchestrator/usecases/response/AppResponseBuilderUseCase.kt | Thread the project parameter through to CreateIdentifyResponseUseCase |
| feature/orchestrator/src/test/java/com/simprints/feature/orchestrator/usecases/response/CreateIdentifyResponseUseCaseTest.kt | Updated all test method signatures to include new project parameter |
| feature/orchestrator/src/test/java/com/simprints/feature/orchestrator/usecases/response/AppResponseBuilderUseCaseTest.kt | Updated mock expectations to include the new project parameter |
...va/com/simprints/feature/orchestrator/usecases/response/CreateIdentifyResponseUseCaseTest.kt
Show resolved
Hide resolved
| .lastOrNull() | ||
| ?.scannedCredential | ||
| .toAppExternalCredential() | ||
| ?.toAppExternalCredential(tokenizationProcessor, project) |
There was a problem hiding this comment.
I am very confused - the PR description is about returning the edited value but the changes are only about tokenising the previously provided value.
There was a problem hiding this comment.
Previously it was accessing the initially captured value, which is unencrypted: ScannedCredential::scannedValue
Not it is accessing the final credential value, which is encrypted: ScannedCredential::credential
private fun ScannedCredential.toAppExternalCredential(
tokenizationProcessor: TokenizationProcessor,
project: Project?,
): AppExternalCredential? {
val decryptedValue = tokenizationProcessor.decrypt(
encrypted = credential, // <--- Here
)
// [...]
return AppExternalCredential(
id = credentialScanId,
value = decryptedValue,
type = credentialType,
)
There was a problem hiding this comment.
I was confused by the same. Why aren't we encrypting scannedValue, too? It will be the actual credential in > 99% of cases and having it saved as plain string kind of makes credential encryption pointless.
There was a problem hiding this comment.
The purpose of the scanned value is for evaluation of how off was scanned value from the final value (stored as credential), see here and here
I see why it might be confusing, I have plans to refactor the returning types a bit for easier separation of concerns. Currently, the ScannedCredential is assigned too much responsibilities that arose as a consequence of the changed requirements
There was a problem hiding this comment.
I can see why we'd want both the scanned and the final values. However, encrypting just the final one doesn't make much sense. Is there any reason for this discrepancy?
There was a problem hiding this comment.
IIRC, we have one event that requires both so that we can see how often attendants need to edit ORC results.
There was a problem hiding this comment.
My question is not why we keep both but why we encrypt only one of them? They are supposed to be the same values in > 99% of cases.
|



JIRA ticket
Will be released in: 2025.4.1
Root cause analysis (for bugfixes only)
First known affected version: 2025.4.1 (during a smoke test)
12345678to0000000012345678instead of the expected edited value (00000000)Notable changes
ScannedCredentialresponseTesting guidance
12345678to0000000000000000(not12345678)Additional work checklist