From 34962fd631e1c75b70c55cd964cd12039b436b85 Mon Sep 17 00:00:00 2001 From: Xavi Aracil Date: Tue, 7 Feb 2023 19:12:10 +0100 Subject: [PATCH] Refresh of credential may fail. If so, continue with old credential --- .../java/org/oneedtech/inspect/vc/OB30Inspector.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/OB30Inspector.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/OB30Inspector.java index a775f0c..e616709 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/OB30Inspector.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/OB30Inspector.java @@ -6,6 +6,7 @@ import static org.oneedtech.inspect.core.report.ReportUtil.onProbeException; import static org.oneedtech.inspect.util.code.Defensives.*; import static org.oneedtech.inspect.util.json.ObjectMapperCache.Config.DEFAULT; import static org.oneedtech.inspect.vc.Credential.CREDENTIAL_KEY; +import static org.oneedtech.inspect.vc.VerifiableCredential.REFRESH_SERVICE_MIME_TYPES; import static org.oneedtech.inspect.vc.VerifiableCredential.ProofType.EXTERNAL; import static org.oneedtech.inspect.vc.payload.PayloadParser.fromJwt; import static org.oneedtech.inspect.vc.util.JsonNodeUtil.asNodeList; @@ -200,9 +201,11 @@ public class OB30Inspector extends VCInspector implements SubInspector { if(resource.getContext().get(REFRESHED) != TRUE) { Optional newID = checkRefreshService(ob, ctx); if(newID.isPresent()) { - return this.run( - new UriResource(new URI(newID.get())) - .setContext(new ResourceContext(REFRESHED, TRUE))); + // If the refresh is not successful, continue the verification process using the original OpenBadgeCredential. + UriResource uriResource = new UriResource(new URI(newID.get()), null, REFRESH_SERVICE_MIME_TYPES); + if (uriResource.exists()) { + return this.run(uriResource.setContext(new ResourceContext(REFRESHED, TRUE))); + } } }