Skip to content

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

Merged

Conversation

suzannajiwani
Copy link
Contributor

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.

@suzannajiwani suzannajiwani marked this pull request as draft April 9, 2024 19:49
@suzannajiwani suzannajiwani force-pushed the mdoc-credential branch 2 times, most recently from b5c2902 to 659f606 Compare April 9, 2024 20:25
@suzannajiwani suzannajiwani marked this pull request as ready for review April 9, 2024 20:29
@suzannajiwani suzannajiwani requested a review from davidz25 April 9, 2024 20:29
@suzannajiwani suzannajiwani force-pushed the mdoc-credential branch 2 times, most recently from f1612bb to 3846584 Compare April 9, 2024 20:35
Copy link
Contributor

@davidz25 davidz25 left a 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!

* @throws IllegalArgumentException if `asReplacementFor` is not null and the given
* credential already has a pending credential intending to replace it.
*/
fun createCredential(
fun createMdocCredential(
Copy link
Contributor

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)

Copy link
Contributor Author

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

@suzannajiwani suzannajiwani force-pushed the mdoc-credential branch 3 times, most recently from ce1206b to 6d60777 Compare April 12, 2024 18:54
@suzannajiwani suzannajiwani requested a review from dritan-x April 12, 2024 18:56
@suzannajiwani suzannajiwani force-pushed the mdoc-credential branch 3 times, most recently from b0b86f4 to de99297 Compare April 16, 2024 00:54
Copy link
Contributor

@davidz25 davidz25 left a 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!

Copy link
Contributor

@davidz25 davidz25 left a 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
Copy link
Contributor

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.

Copy link
Contributor Author

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

@suzannajiwani suzannajiwani force-pushed the mdoc-credential branch 2 times, most recently from 7d5facb to a074a00 Compare April 18, 2024 03:23
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>
Copy link
Contributor

@davidz25 davidz25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@davidz25 davidz25 merged commit f775c19 into openwallet-foundation-labs:main Apr 18, 2024
2 checks passed
@suzannajiwani suzannajiwani deleted the mdoc-credential branch November 20, 2024 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants