| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -200,6 +200,39 @@ public CompletionStage<AccessGrant> issue(final URI type, final URI agent, final | |
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Verify an access grant or request. | ||
| * | ||
| * @param accessGrant the access grant to verify | ||
| * @return the next stage of completion containing the resulting credential | ||
| */ | ||
| public CompletionStage<VerificationResponse> verify(final AccessGrant accessGrant) { | ||
| return v1Metadata().thenCompose(metadata -> { | ||
|
|
||
| final Map<String, Object> presentation = new HashMap<>(); | ||
| presentation.put(VERIFIABLE_CREDENTIAL, accessGrant); | ||
|
|
||
| final Request req = Request.newBuilder(metadata.verifyEndpoint) | ||
| .header(CONTENT_TYPE, APPLICATION_JSON) | ||
| .POST(Request.BodyPublishers.ofByteArray(serialize(presentation))).build(); | ||
|
|
||
| return client.send(req, Response.BodyHandlers.ofInputStream()) | ||
| .thenApply(res -> { | ||
| try (final InputStream input = res.body()) { | ||
| final int status = res.statusCode(); | ||
| if (isSuccess(status)) { | ||
| return processVerificationResult(input); | ||
| } | ||
| throw new AccessGrantException("Unable to perform Access Grant verify: HTTP error " + status, | ||
|
Comment thread
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIn the case of an error the response will also contain an error, errorDescription and an optional reason. These could be useful for a downstream client to know but they are getting dropped here and we are only giving them the status.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityAccording to the VC-API spec, the verify endpoint will return a 200 in cases where the credential is invalid, but there is no defined response for, say, 4xx or 5xx category errors. I think it would be great for the client to try to parse 4xx/5xx error bodies as if they contain those response, but that can be part of an overall improvement in how errors are processed.
Sorry, something went wrong.
timea-solid reacted with thumbs up emoji
All reactions
|
||
| status); | ||
| } catch (final IOException ex) { | ||
| throw new AccessGrantException( | ||
| "Unexpected I/O exception while verifying Access Grant", ex); | ||
| } | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Perform an Access Grant query. | ||
| * | ||
| Expand Down Expand Up | @@ -339,6 +372,10 @@ AccessGrant processVerifiableCredential(final InputStream input, final Set<Strin | |
| } | ||
| } | ||
|
|
||
| VerificationResponse processVerificationResult(final InputStream input) throws IOException { | ||
| return jsonService.fromJson(input, VerificationResponse.class); | ||
| } | ||
|
|
||
| List<AccessGrant> processQueryResponse(final InputStream input, final Set<String> validTypes) throws IOException { | ||
| final Map<String, Object> data = jsonService.fromJson(input, | ||
| new HashMap<String, Object>(){}.getClass().getGenericSuperclass()); | ||
| Expand Down Expand Up | @@ -546,4 +583,24 @@ static boolean isAccessRequest(final URI type) { | |
| return "SolidAccessRequest".equals(type.toString()) || ACCESS_REQUEST.equals(type); | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * A data objects for verification responses. | ||
| */ | ||
| public static class VerificationResponse { | ||
| /** | ||
| * The verification checks that were performed. | ||
| */ | ||
| public List<String> checks; | ||
|
|
||
| /** | ||
| * The verification warnings that were discovered. | ||
| */ | ||
| public List<String> warnings; | ||
|
|
||
| /** | ||
| * The verification errors that were discovered. | ||
| */ | ||
| public List<String> errors; | ||
| } | ||
| } | ||
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThe /verify endpoint can also take a VerifiablePresentation. Do you need this in this client?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.