implement refreshService

This commit is contained in:
Markus Gylling 2022-06-30 15:55:17 +02:00
parent c655b3ca1c
commit 80e7f9bbde
2 changed files with 13 additions and 4 deletions

View File

@ -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.probe.json.JsonSchemaProbe;
import org.oneedtech.inspect.core.report.Report; import org.oneedtech.inspect.core.report.Report;
import org.oneedtech.inspect.core.report.ReportItems; 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.JsonSchemaCache;
import org.oneedtech.inspect.schema.SchemaKey; import org.oneedtech.inspect.schema.SchemaKey;
import org.oneedtech.inspect.util.json.ObjectMapperCache; import org.oneedtech.inspect.util.json.ObjectMapperCache;
@ -122,7 +123,7 @@ public class OB30Inspector extends VCInspector {
//check refresh service if we are not already refreshed //check refresh service if we are not already refreshed
probeCount++; probeCount++;
if(resource.getContext().get(REFRESHED) != TRUE) { if(resource.getContext().get(REFRESHED) != TRUE) {
Optional<String> newID = checkRefreshService(crd, ctx); //TODO fail = invalid Optional<String> newID = checkRefreshService(crd, ctx);
if(newID.isPresent()) { if(newID.isPresent()) {
return this.run( return this.run(
new UriResource(new URI(newID.get())) new UriResource(new URI(newID.get()))
@ -179,7 +180,16 @@ public class OB30Inspector extends VCInspector {
* the credential is invalid. * the credential is invalid.
*/ */
private Optional<String> checkRefreshService(Credential crd, RunContext ctx) { private Optional<String> 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(); return Optional.empty();
} }

View File

@ -2,7 +2,6 @@ package org.oneedtech.inspect.vc.probe;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.util.Base64; import java.util.Base64;
import java.util.Base64.Decoder; import java.util.Base64.Decoder;