-
Notifications
You must be signed in to change notification settings - Fork 99
Start Differentiating Credential Types #573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start Differentiating Credential Types #573
Conversation
6c42fef
to
3c0367e
Compare
b5c2902
to
659f606
Compare
f1612bb
to
3846584
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a great start! Comments inline!
identity/src/main/java/com/android/identity/credential/Credential.kt
Outdated
Show resolved
Hide resolved
identity/src/main/java/com/android/identity/credential/SecureAreaBoundCredential.kt
Outdated
Show resolved
Hide resolved
identity/src/main/java/com/android/identity/credential/MdocCredential.kt
Outdated
Show resolved
Hide resolved
identity/src/main/java/com/android/identity/credential/SecureAreaBoundCredential.kt
Outdated
Show resolved
Hide resolved
identity/src/main/java/com/android/identity/document/Document.kt
Outdated
Show resolved
Hide resolved
* @throws IllegalArgumentException if `asReplacementFor` is not null and the given | ||
* credential already has a pending credential intending to replace it. | ||
*/ | ||
fun createCredential( | ||
fun createMdocCredential( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, yeah, I think we should probably move credential creation into concrete Credential
-derived classes and instead of Document.createCredential()
it should just be Document.addCredential()
and I think addCredential()
's only job would be to save the credential to disk ...
In this setup the application code would be something like this (for a contrived example where we're adding to mDL credentials - one for LoA Substantial, one for LoA High - one SD/JWT credentiat, and one mDL direct access credential.
val mdocCredential = MdocCredential.create(
domain = "mDL_LoA_Substantial",
validFrom = validFrom,
validUntil = validUntil,
secureArea = androidKeystoreSecureArea,
createKeySettings = createKeySettings,
asReplacementFor = null,
)
document.addCredential(mdocCredential)
val mdocCredentialLoAHigh = MdocCredential.create(
domain = "mDL_LoA_High",
validFrom = validFrom,
validUntil = validUntil,
secureArea = androidKeystoreSecureArea,
createKeySettings = createKeySettingsForLoAHigh,
asReplacementFor = null,
)
document.addCredential(mdocCredentialLoAHigh)
val sdjwtCredential = SdJwtCredential.create(
domain = "sdjwt_LoA_Substantial",
validFrom = validFrom,
validUntil = validUntil,
secureArea = androidKeystoreSecureArea,
createKeySettings = createKeySettings,
asReplacementFor = null,
)
document.addCredential(sdjwtCredential)
val mdocDirectAccessCredential = MdocDirectAccessCredential.create(
domain = "mdoc_directAccess",
validFrom = validFrom,
validUntil = validUntil,
asReplacementFor = null,
/* some direct-access specific stuff */
)
document.addCredential(mdocDirectAccessCredential)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since credentials are so tied to the document they're associated with, I added the document to the create
method so the usage would look like this instead:
val mdocCredentialLoAHigh = MdocCredential.create(
domain = "mDL_LoA_High",
secureArea = androidKeystoreSecureArea,
createKeySettings = createKeySettingsForLoAHigh,
asReplacementFor = null,
document = document
)
with the document.addCredential
implicitly in the Credential.create
- lmk what you think
identity/src/main/java/com/android/identity/credential/Credential.kt
Outdated
Show resolved
Hide resolved
ce1206b
to
6d60777
Compare
b0b86f4
to
de99297
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really great! Didn't have time to finish my review but here are some comments for what I did look at... might have some more comments on the next iteration!
identity/src/main/java/com/android/identity/document/Document.kt
Outdated
Show resolved
Hide resolved
identity-mdoc/src/test/java/com/android/identity/mdoc/response/DeviceResponseGeneratorTest.kt
Outdated
Show resolved
Hide resolved
.../src/main/java/com/android/identity_credential/wallet/credman/CredmanPresentationActivity.kt
Outdated
Show resolved
Hide resolved
identity/src/main/java/com/android/identity/document/DocumentUtil.kt
Outdated
Show resolved
Hide resolved
identity/src/test/java/com/android/identity/document/DocumentUtilTest.kt
Outdated
Show resolved
Hide resolved
de99297
to
c0e71a6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is almost ready. Mostly nits.
AUTH_KEY_DOMAIN, | ||
transferHelper.androidKeystoreSecureArea, | ||
CreateKeySettings("".toByteArray()), | ||
null | ||
null, | ||
document |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this actually works since create()
is protected. Use the constructor and then Document.addCredential() instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point - I didn't check the samples to make sure it all works, but will before the next push
identity/src/main/java/com/android/identity/document/DocumentUtil.kt
Outdated
Show resolved
Hide resolved
identity/src/main/java/com/android/identity/document/DocumentUtil.kt
Outdated
Show resolved
Hide resolved
identity/src/main/java/com/android/identity/document/DocumentUtil.kt
Outdated
Show resolved
Hide resolved
appholder/src/main/java/com/android/identity/wallet/HolderApp.kt
Outdated
Show resolved
Hide resolved
identity/src/main/java/com/android/identity/document/Document.kt
Outdated
Show resolved
Hide resolved
identity/src/test/java/com/android/identity/document/DocumentStoreTest.kt
Outdated
Show resolved
Hide resolved
identity/src/test/java/com/android/identity/document/DocumentStoreTest.kt
Outdated
Show resolved
Hide resolved
identity/src/test/java/com/android/identity/document/DocumentStoreTest.kt
Outdated
Show resolved
Hide resolved
samples/preconsent-mdl/src/main/java/com/android/identity/preconsent_mdl/MainActivity.kt
Outdated
Show resolved
Hide resolved
7d5facb
to
a074a00
Compare
Added structure for additional credential types by moving existing code to a credential package and creating classes for Credential, SecureAreaBoundCredential, and MdocCredential. All tests pass + tested manually by provisioning and presenting in wallet and appholder. Signed-off-by: Suzanna Jiwani <suzannaj@google.com>
a074a00
to
53b6a49
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Added structure for additional credential types by moving existing code to a credential package and creating abstract classes for Credential and SecureAreaBoundCredential, with MdocCredential as the first implementation.
All tests pass + tested manually by provisioning and presenting in wallet and appholder.