Skip to content

Commit 460f375

Browse files
author
Olesja Aarma
committed
Merge branch 'RM-5029_interaction_params' into 'master'
RM-5029: SID/MID interaction params usage description See merge request cdoc2/cdoc2-java-ref-impl!111
2 parents fb493b3 + 80deffa commit 460f375

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

cdoc2-lib/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,35 @@ List<String> extractedFiles = new CDocDecrypter()
475475
.decrypt();
476476
```
477477

478+
479+
### User interaction with Smart ID and Mobile ID clients
480+
Smart ID and Mobile ID clients interact with user by display messages and verification code.
481+
Available interactions are implemented in a class `InteractionParams`, which can be of
482+
following types `InteractionParams.InteractionType`:
483+
* DISPLAY_TEXT_AND_PIN
484+
* CONFIRMATION_MESSAGE
485+
* VERIFICATION_CODE_CHOICE
486+
* CONFIRMATION_MESSAGE_AND_VERIFICATION_CODE_CHOICE
487+
488+
Initialized `InteractionParams` will be transferred to Smart ID and Mobile ID clients while
489+
authenticating.
490+
491+
`InteractionParams` can be configured by initializing `KeyShareDecryptionKeyMaterial`
492+
with method `InteractionParamsConfigurable.init()` while decrypting:
493+
```java
494+
private static void addInteractionParameters(File cdocFile, DecryptionKeyMaterial dkm) {
495+
if (dkm instanceof InteractionParamsConfigurable paramsConfigurable) {
496+
497+
InteractionParams interactionParams = (cdocFile == null)
498+
? InteractionParams.displayTextAndPin()
499+
: InteractionParams.displayTextAndVCCForDocument(cdocFile.toPath().getFileName().toString());
500+
interactionParams.addAuthListener(e -> System.out.println("Verification code:" + e.getVerificationCode()));
501+
paramsConfigurable.init(interactionParams);
502+
}
503+
}
504+
```
505+
506+
478507
## Long-term crypto
479508

480509
Scenarios with id-card are meant for transport cryptography only as id-card certificates expiry and

cdoc2-lib/src/main/java/ee/cyber/cdoc2/crypto/jwt/InteractionParams.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.LinkedList;
88
import java.util.List;
99

10+
1011
/**
1112
* Smart-ID and Mobile-ID interaction parameters.
1213
* Optional parameters to drive user interaction and to get verification code.
@@ -28,7 +29,6 @@ public enum InteractionType {
2829
CONFIRMATION_MESSAGE_AND_VERIFICATION_CODE_CHOICE
2930
}
3031

31-
3232
/** Default text for Smart-ID. Max length 60 chars. Default text for MID is defined in mobile-id.properties */
3333
public static final String DEFAULT_DISPLAY_TEXT = "Authenticate to decrypt CDOC2 document";
3434

@@ -119,7 +119,6 @@ public void setEncoding(String encoding) {
119119
this.encoding = encoding;
120120
}
121121

122-
123122
/** Get text displayed. If text is longer than 200 chars, will be capped to 200 chars */
124123
public String getDisplayText200() {
125124
return getDisplayText(200);
@@ -160,4 +159,5 @@ public void notifyAuthListeners(AuthEvent event) {
160159
listener.authStarted(event);
161160
}
162161
}
162+
163163
}

0 commit comments

Comments
 (0)