-
Notifications
You must be signed in to change notification settings - Fork 2
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
Adapted policy to the claims format of the IdentityHubCredentialsVerifier. #227
Adapted policy to the claims format of the IdentityHubCredentialsVerifier. #227
Conversation
This reverts commit 04569cd.
2f3bdc8
to
348f871
Compare
...ions/policies/src/main/java/org/eclipse/dataspaceconnector/mvd/RegionConstraintFunction.java
Show resolved
Hide resolved
...tials-verifier/src/main/java/org/eclipse/dataspaceconnector/mvd/MockCredentialsVerifier.java
Outdated
Show resolved
Hide resolved
...tials-verifier/src/main/java/org/eclipse/dataspaceconnector/mvd/MockCredentialsVerifier.java
Outdated
Show resolved
Hide resolved
...s-verifier/src/test/java/org/eclipse/dataspaceconnector/mvd/MockCredentialsVerifierTest.java
Show resolved
Hide resolved
try { | ||
var region = verifiableCredential.getCredentialSubject().get(REGION_KEY); | ||
return Optional.ofNullable((String) region); | ||
} catch (Exception e) { |
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.
nit: is there a particular reason why are catching all of the exception here and then returning empty optional, instead not letting exception be thrown or bubble up?
same as in above method getVerifiableCredential
because this method may also throw IllegalArgumentException and in case of other exceptions current implementation will give the impression that evaluate
failed with false response but it is actually something else.
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 changed the exception to ClassCastException to make it better.
It is in case a region can't be casted to string. To avoid breaking the entire flow checking the policy.
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.
or maybe I was thinking too much your trick with optional may also work if you catch all exception with logging error about it.
And just a java doc on the method that we continue to process to avoid any Verifiable credential which do not have region as per the correct format.
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.
Approved with suggestions.
commit 7c5069d Author: Ophélie Le Mentec <17216799+ouphi@users.noreply.github.com> Date: Tue Aug 2 14:37:15 2022 +0200 Cleanup to make the catching of exceptions related to the Verifiable credential casting more clear. (#231) * Cleanup. * Use only one method to get the region. commit 618f40f Merge: a3ca8c6 508dc29 Author: Ophelie Le Mentec <17216799+ouphi@users.noreply.github.com> Date: Tue Aug 2 14:17:38 2022 +0200 Merged main. commit a3ca8c6 Author: Ophélie Le Mentec <17216799+ouphi@users.noreply.github.com> Date: Tue Aug 2 11:38:06 2022 +0200 feat: adapt policy to the claims format of the IdentityHubCredentialsVerifier. (#227) * Update action.yml * Update deploy.yaml * Adapted policy to VC. * . * . * Update action.yml * Update IdentityHubIntegrationTest.java * Update IdentityHubIntegrationTest.java * Update IdentityHubIntegrationTest.java * Fixed checkstyle. * Changed identityhub commit. * Adapt ide hub client contract in tests. * Renamed constraint function. * Renamed constraint function. * Updated credentials verifier. * checkstyle. * Fixed tests. * Fixed checkstyle. * Updated javadoc. * Used Duty instead of Permission. * Improved issuer comment. * Improved tests. * Revert "Used Duty instead of Permission." This reverts commit 04569cd. * Revert "Revert "Used Duty instead of Permission."" This reverts commit 348f871. * Revert "Revert "Revert "Used Duty instead of Permission.""" This reverts commit 654d038. * cleanup. * Simplified toMappedVC. * Added tests for RegionConstraintFunction. * Used constants. * Fix. * Added a test. * Fixed checkstyle. * checkstyle. * Improved test coverage. * Added region key. * Used constant for iss. * Fixed checktyls. * use private. * applied comment. * Used ofNullable. * Used identityHubGroup and identityHubVersion. * Applied comment. * Removed unused method. * Applied comment. * . * checkstyle. * Fixed import. * Used last idHub commit. * Added NEQ operator. * Update MockCredentialsVerifier.java * Update SeedPoliciesExtension.java * Update MockCredentialsVerifier.java * Update SeedPoliciesExtension.java * Revert using static vckey var. * Revert "Used last idHub commit." This reverts commit 54c6439. * Update MockCredentialsVerifierTest.java * Update deploy.yaml * Used provider. * Made provider method public. * Merged PR updating EDC version. * Revert "Merged PR updating EDC version." This reverts commit 75e628b. * Used constant verifiable credentials key. * Changed identityHub commit. * Fix. * Use failure message. * Added IN operator. * use ClassCastException. * Added test. * Applied comment. * Do not use Optional as a returned type. Co-authored-by: Alexandre Gattiker <algattik@microsoft.com>
What this PR changes/adds
Adapted policy to the claims format returned by the IdentityHubCredentialsVerifier.
Why it does that
MVD will be using the IdentityHubCredentialsVerifier. Adapted the policy to the claim format that the IdentityHubCredentialsVerifier returns.
Further notes
Changed the MockCredentialVerifier to return the same format as the IdentityHubCredentialsVerifier.
Linked Issue(s)
agera-edc/IdentityHub#32
Checklist
no-changelog
)