From 7beb69f87be5acd98c5ca5297fe40463f6216c21 Mon Sep 17 00:00:00 2001 From: Xavi Aracil Date: Wed, 23 Nov 2022 09:08:42 +0100 Subject: [PATCH] AbstractBaseCredential renamed to Credential --- .../java/org/oneedtech/inspect/vc/Assertion.java | 4 ++-- ...AbstractBaseCredential.java => Credential.java} | 6 +++--- .../oneedtech/inspect/vc/EndorsementInspector.java | 2 +- .../org/oneedtech/inspect/vc/OB30Inspector.java | 2 +- .../oneedtech/inspect/vc/VerifiableCredential.java | 4 ++-- .../oneedtech/inspect/vc/payload/JsonParser.java | 4 ++-- .../oneedtech/inspect/vc/payload/JwtParser.java | 4 ++-- .../inspect/vc/payload/PayloadParser.java | 8 ++++---- .../oneedtech/inspect/vc/payload/PngParser.java | 4 ++-- .../oneedtech/inspect/vc/payload/SvgParser.java | 4 ++-- .../inspect/vc/probe/CredentialParseProbe.java | 4 ++-- .../inspect/vc/credential/PayloadParserTests.java | 14 +++++++------- 12 files changed, 30 insertions(+), 30 deletions(-) rename inspector-vc/src/main/java/org/oneedtech/inspect/vc/{AbstractBaseCredential.java => Credential.java} (90%) diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Assertion.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Assertion.java index 8cec78b..e571efd 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Assertion.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Assertion.java @@ -18,7 +18,7 @@ import com.google.common.collect.ImmutableMap; * and the extracted JSON data plus any other stuff Probes need. * @author xaracil */ -public class Assertion extends AbstractBaseCredential { +public class Assertion extends Credential { final Assertion.Type assertionType; @@ -46,7 +46,7 @@ public class Assertion extends AbstractBaseCredential { .put(Type.Assertion, Catalog.OB_21_ASSERTION_JSON) .build(); - public static class Builder extends AbstractBaseCredential.Builder { + public static class Builder extends Credential.Builder { @Override public Assertion build() { diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/AbstractBaseCredential.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Credential.java similarity index 90% rename from inspector-vc/src/main/java/org/oneedtech/inspect/vc/AbstractBaseCredential.java rename to inspector-vc/src/main/java/org/oneedtech/inspect/vc/Credential.java index 1262919..82ba4e2 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/AbstractBaseCredential.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Credential.java @@ -22,13 +22,13 @@ import com.google.common.base.MoreObjects; * This contains e.g. the origin resource and the extracted JSON data. * @author xaracil */ -public abstract class AbstractBaseCredential extends GeneratedObject { +public abstract class Credential extends GeneratedObject { final Resource resource; final JsonNode jsonData; final String jwt; final Map schemas; - protected AbstractBaseCredential(String id, Resource resource, JsonNode data, String jwt, Map schemas) { + protected Credential(String id, Resource resource, JsonNode data, String jwt, Map schemas) { super(id, GeneratedObject.Type.INTERNAL); this.resource = checkNotNull(resource); this.jsonData = checkNotNull(data); @@ -72,7 +72,7 @@ public abstract class AbstractBaseCredential extends GeneratedObject { public static final List RECOGNIZED_PAYLOAD_TYPES = List.of(SVG, PNG, JSON, JWT); public static final String CREDENTIAL_KEY = "CREDENTIAL_KEY"; - public abstract static class Builder { + public abstract static class Builder { private Resource resource; private JsonNode jsonData; private String jwt; diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/EndorsementInspector.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/EndorsementInspector.java index b7d29fa..6879e79 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/EndorsementInspector.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/EndorsementInspector.java @@ -5,7 +5,7 @@ import static org.oneedtech.inspect.core.probe.RunContext.Key.*; import static org.oneedtech.inspect.core.report.ReportUtil.onProbeException; import static org.oneedtech.inspect.util.code.Defensives.checkNotNull; import static org.oneedtech.inspect.util.json.ObjectMapperCache.Config.DEFAULT; -import static org.oneedtech.inspect.vc.AbstractBaseCredential.CREDENTIAL_KEY; +import static org.oneedtech.inspect.vc.Credential.CREDENTIAL_KEY; import static org.oneedtech.inspect.vc.VerifiableCredential.ProofType.EXTERNAL; import java.net.URI; 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 e60b8e2..51b48c6 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 @@ -5,7 +5,7 @@ import static org.oneedtech.inspect.core.Inspector.Behavior.RESET_CACHES_ON_RUN; 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.AbstractBaseCredential.CREDENTIAL_KEY; +import static org.oneedtech.inspect.vc.Credential.CREDENTIAL_KEY; 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; diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/VerifiableCredential.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/VerifiableCredential.java index 7daf258..b388379 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/VerifiableCredential.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/VerifiableCredential.java @@ -23,7 +23,7 @@ import com.google.common.collect.ImmutableMap; * and the extracted JSON data plus any other stuff Probes need. * @author mgylling */ -public class VerifiableCredential extends AbstractBaseCredential { +public class VerifiableCredential extends Credential { final VerifiableCredential.Type credentialType; protected VerifiableCredential(Resource resource, JsonNode data, String jwt, Map schemas) { @@ -91,7 +91,7 @@ public class VerifiableCredential extends AbstractBaseCredential { .toString(); } - public static class Builder extends AbstractBaseCredential.Builder { + public static class Builder extends Credential.Builder { @Override public VerifiableCredential build() { // transform key of schemas map to string because the type of the key in the base map is generic diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/JsonParser.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/JsonParser.java index c500743..8c16ed3 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/JsonParser.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/JsonParser.java @@ -7,7 +7,7 @@ import org.oneedtech.inspect.core.probe.RunContext; import org.oneedtech.inspect.core.probe.RunContext.Key; import org.oneedtech.inspect.util.resource.Resource; import org.oneedtech.inspect.util.resource.ResourceType; -import org.oneedtech.inspect.vc.AbstractBaseCredential; +import org.oneedtech.inspect.vc.Credential; import com.fasterxml.jackson.databind.JsonNode; /** @@ -22,7 +22,7 @@ public final class JsonParser extends PayloadParser { } @Override - public AbstractBaseCredential parse(Resource resource, RunContext ctx) throws Exception { + public Credential parse(Resource resource, RunContext ctx) throws Exception { checkTrue(resource.getType() == ResourceType.JSON); String json = resource.asByteSource().asCharSource(UTF_8).read(); JsonNode node = fromString(json, ctx); diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/JwtParser.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/JwtParser.java index eece82b..1769d07 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/JwtParser.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/JwtParser.java @@ -6,7 +6,7 @@ import static org.oneedtech.inspect.util.code.Defensives.checkTrue; import org.oneedtech.inspect.core.probe.RunContext; import org.oneedtech.inspect.util.resource.Resource; import org.oneedtech.inspect.util.resource.ResourceType; -import org.oneedtech.inspect.vc.AbstractBaseCredential; +import org.oneedtech.inspect.vc.Credential; import com.fasterxml.jackson.databind.JsonNode; @@ -22,7 +22,7 @@ public final class JwtParser extends PayloadParser { } @Override - public AbstractBaseCredential parse(Resource resource, RunContext ctx) throws Exception { + public Credential parse(Resource resource, RunContext ctx) throws Exception { checkTrue(resource.getType() == ResourceType.JWT); String jwt = resource.asByteSource().asCharSource(UTF_8).read(); JsonNode node = fromJwt(jwt, ctx); diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/PayloadParser.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/PayloadParser.java index dc9307f..78bc293 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/PayloadParser.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/PayloadParser.java @@ -7,7 +7,7 @@ import java.util.Base64.Decoder; import org.oneedtech.inspect.core.probe.RunContext; import org.oneedtech.inspect.util.resource.Resource; import org.oneedtech.inspect.util.resource.ResourceType; -import org.oneedtech.inspect.vc.AbstractBaseCredential; +import org.oneedtech.inspect.vc.Credential; import org.oneedtech.inspect.vc.VerifiableCredential; import com.fasterxml.jackson.databind.JsonNode; @@ -22,11 +22,11 @@ public abstract class PayloadParser { public abstract boolean supports(ResourceType type); - public abstract AbstractBaseCredential parse(Resource source, RunContext ctx) throws Exception; + public abstract Credential parse(Resource source, RunContext ctx) throws Exception; @SuppressWarnings("rawtypes") - public static AbstractBaseCredential.Builder getBuilder(RunContext context) { - return ((AbstractBaseCredential.Builder) context.get(RunContext.Key.GENERATED_OBJECT_BUILDER)); + public static Credential.Builder getBuilder(RunContext context) { + return ((Credential.Builder) context.get(RunContext.Key.GENERATED_OBJECT_BUILDER)); } protected static JsonNode fromString(String json, RunContext context) throws Exception { diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/PngParser.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/PngParser.java index 31ab22a..492bab2 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/PngParser.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/PngParser.java @@ -11,7 +11,7 @@ import javax.imageio.metadata.IIOMetadata; import org.oneedtech.inspect.core.probe.RunContext; import org.oneedtech.inspect.util.resource.Resource; import org.oneedtech.inspect.util.resource.ResourceType; -import org.oneedtech.inspect.vc.AbstractBaseCredential; +import org.oneedtech.inspect.vc.Credential; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; @@ -29,7 +29,7 @@ public final class PngParser extends PayloadParser { } @Override - public AbstractBaseCredential parse(Resource resource, RunContext ctx) throws Exception { + public Credential parse(Resource resource, RunContext ctx) throws Exception { checkTrue(resource.getType() == ResourceType.PNG); diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/SvgParser.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/SvgParser.java index 34f81fa..8d9a659 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/SvgParser.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/payload/SvgParser.java @@ -14,7 +14,7 @@ import org.oneedtech.inspect.core.probe.RunContext; import org.oneedtech.inspect.util.resource.Resource; import org.oneedtech.inspect.util.resource.ResourceType; import org.oneedtech.inspect.util.xml.XMLInputFactoryCache; -import org.oneedtech.inspect.vc.AbstractBaseCredential; +import org.oneedtech.inspect.vc.Credential; import com.fasterxml.jackson.databind.JsonNode; @@ -30,7 +30,7 @@ public final class SvgParser extends PayloadParser { } @Override - public AbstractBaseCredential parse(Resource resource, RunContext ctx) throws Exception { + public Credential parse(Resource resource, RunContext ctx) throws Exception { final QNames qNames = (QNames) ctx.get(RunContext.Key.SVG_CREDENTIAL_QNAME); checkTrue(resource.getType() == ResourceType.SVG); diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/CredentialParseProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/CredentialParseProbe.java index 93cc98d..1444c50 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/CredentialParseProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/CredentialParseProbe.java @@ -8,7 +8,7 @@ import org.oneedtech.inspect.core.report.ReportItems; import org.oneedtech.inspect.util.resource.Resource; import org.oneedtech.inspect.util.resource.ResourceType; import org.oneedtech.inspect.util.resource.detect.TypeDetector; -import org.oneedtech.inspect.vc.AbstractBaseCredential; +import org.oneedtech.inspect.vc.Credential; import org.oneedtech.inspect.vc.VerifiableCredential; import org.oneedtech.inspect.vc.payload.PayloadParserFactory; @@ -43,7 +43,7 @@ public class CredentialParseProbe extends Probe { return fatal("Payload type not supported: " + type.get().getName(), context); } - AbstractBaseCredential crd = PayloadParserFactory.of(resource).parse(resource, context); + Credential crd = PayloadParserFactory.of(resource).parse(resource, context); context.addGeneratedObject(crd); return success(this, context); diff --git a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/credential/PayloadParserTests.java b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/credential/PayloadParserTests.java index 1bf3f88..506b451 100644 --- a/inspector-vc/src/test/java/org/oneedtech/inspect/vc/credential/PayloadParserTests.java +++ b/inspector-vc/src/test/java/org/oneedtech/inspect/vc/credential/PayloadParserTests.java @@ -11,7 +11,7 @@ import org.oneedtech.inspect.core.probe.json.JsonPathEvaluator; import org.oneedtech.inspect.util.json.ObjectMapperCache; import org.oneedtech.inspect.util.resource.Resource; import org.oneedtech.inspect.util.resource.ResourceType; -import org.oneedtech.inspect.vc.AbstractBaseCredential; +import org.oneedtech.inspect.vc.Credential; import org.oneedtech.inspect.vc.OB30Inspector; import org.oneedtech.inspect.vc.Samples; import org.oneedtech.inspect.vc.payload.PayloadParser; @@ -27,7 +27,7 @@ public class PayloadParserTests { Resource res = Samples.OB30.SVG.SIMPLE_JSON_SVG.asFileResource(ResourceType.SVG); PayloadParser ext = PayloadParserFactory.of(res); assertNotNull(ext); - AbstractBaseCredential crd = ext.parse(res, mockOB30Context(res)); + Credential crd = ext.parse(res, mockOB30Context(res)); //System.out.println(crd.getJson().toPrettyString()); assertNotNull(crd); assertNotNull(crd.getJson()); @@ -41,7 +41,7 @@ public class PayloadParserTests { Resource res = Samples.OB30.SVG.SIMPLE_JWT_SVG.asFileResource(ResourceType.SVG); PayloadParser ext = PayloadParserFactory.of(res); assertNotNull(ext); - AbstractBaseCredential crd = ext.parse(res, mockOB30Context(res)); + Credential crd = ext.parse(res, mockOB30Context(res)); //System.out.println(crd.getJson().toPrettyString()); assertNotNull(crd); assertNotNull(crd.getJson()); @@ -55,7 +55,7 @@ public class PayloadParserTests { Resource res = Samples.OB30.PNG.SIMPLE_JSON_PNG.asFileResource(ResourceType.PNG); PayloadParser ext = PayloadParserFactory.of(res); assertNotNull(ext); - AbstractBaseCredential crd = ext.parse(res, mockOB30Context(res)); + Credential crd = ext.parse(res, mockOB30Context(res)); //System.out.println(crd.getJson().toPrettyString()); assertNotNull(crd); assertNotNull(crd.getJson()); @@ -69,7 +69,7 @@ public class PayloadParserTests { Resource res = Samples.OB30.PNG.SIMPLE_JWT_PNG.asFileResource(ResourceType.PNG); PayloadParser ext = PayloadParserFactory.of(res); assertNotNull(ext); - AbstractBaseCredential crd = ext.parse(res, mockOB30Context(res)); + Credential crd = ext.parse(res, mockOB30Context(res)); //System.out.println(crd.getJson().toPrettyString()); assertNotNull(crd); assertNotNull(crd.getJson()); @@ -83,7 +83,7 @@ public class PayloadParserTests { Resource res = Samples.OB30.JWT.SIMPLE_JWT.asFileResource(ResourceType.JWT); PayloadParser ext = PayloadParserFactory.of(res); assertNotNull(ext); - AbstractBaseCredential crd = ext.parse(res, mockOB30Context(res)); + Credential crd = ext.parse(res, mockOB30Context(res)); //System.out.println(crd.getJson().toPrettyString()); assertNotNull(crd); assertNotNull(crd.getJson()); @@ -97,7 +97,7 @@ public class PayloadParserTests { Resource res = Samples.OB30.JSON.SIMPLE_JSON.asFileResource(ResourceType.JSON); PayloadParser ext = PayloadParserFactory.of(res); assertNotNull(ext); - AbstractBaseCredential crd = ext.parse(res, mockOB30Context(res)); + Credential crd = ext.parse(res, mockOB30Context(res)); //System.out.println(crd.getJson().toPrettyString()); assertNotNull(crd); assertNotNull(crd.getJson());