From 80e7f9bbde2448a896431e34ba5b792674b37716 Mon Sep 17 00:00:00 2001 From: Markus Gylling Date: Thu, 30 Jun 2022 15:55:17 +0200 Subject: [PATCH] implement refreshService --- .../org/oneedtech/inspect/vc/OB30Inspector.java | 16 +++++++++++++--- .../inspect/vc/probe/CredentialTypeProbe.java | 1 - 2 files changed, 13 insertions(+), 4 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 c1849f4..88f007e 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 @@ -22,6 +22,7 @@ import org.oneedtech.inspect.core.probe.json.JsonPredicates.JsonPredicateProbePa import org.oneedtech.inspect.core.probe.json.JsonSchemaProbe; import org.oneedtech.inspect.core.report.Report; import org.oneedtech.inspect.core.report.ReportItems; +import org.oneedtech.inspect.core.report.ReportUtil; import org.oneedtech.inspect.schema.JsonSchemaCache; import org.oneedtech.inspect.schema.SchemaKey; import org.oneedtech.inspect.util.json.ObjectMapperCache; @@ -121,8 +122,8 @@ public class OB30Inspector extends VCInspector { //check refresh service if we are not already refreshed probeCount++; - if(resource.getContext().get(REFRESHED) != TRUE) { - Optional newID = checkRefreshService(crd, ctx); //TODO fail = invalid + if(resource.getContext().get(REFRESHED) != TRUE) { + Optional newID = checkRefreshService(crd, ctx); if(newID.isPresent()) { return this.run( new UriResource(new URI(newID.get())) @@ -179,7 +180,16 @@ public class OB30Inspector extends VCInspector { * the credential is invalid. */ private Optional checkRefreshService(Credential crd, RunContext ctx) { - //TODO + JsonNode refreshServiceNode = crd.getJson().get("refreshService"); + if(refreshServiceNode != null) { + JsonNode serviceTypeNode = refreshServiceNode.get("type"); + if(serviceTypeNode != null && serviceTypeNode.asText().equals("1EdTechCredentialRefresh")) { + JsonNode serviceURINode = refreshServiceNode.get("id"); + if(serviceURINode != null) { + return Optional.of(serviceURINode.asText()); + } + } + } return Optional.empty(); } diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/CredentialTypeProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/CredentialTypeProbe.java index 535c9c0..1995c0d 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/CredentialTypeProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/CredentialTypeProbe.java @@ -2,7 +2,6 @@ package org.oneedtech.inspect.vc.probe; import static java.nio.charset.StandardCharsets.UTF_8; -import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.Base64; import java.util.Base64.Decoder;