Credential renamed to VerifiableCredential

This commit is contained in:
Xavi Aracil 2022-11-23 09:07:49 +01:00
parent 0e077c7256
commit 3ab9c52300
14 changed files with 184 additions and 185 deletions

View File

@ -5,8 +5,8 @@ import static org.oneedtech.inspect.core.probe.RunContext.Key.*;
import static org.oneedtech.inspect.core.report.ReportUtil.onProbeException; import static org.oneedtech.inspect.core.report.ReportUtil.onProbeException;
import static org.oneedtech.inspect.util.code.Defensives.checkNotNull; import static org.oneedtech.inspect.util.code.Defensives.checkNotNull;
import static org.oneedtech.inspect.util.json.ObjectMapperCache.Config.DEFAULT; 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.AbstractBaseCredential.CREDENTIAL_KEY;
import static org.oneedtech.inspect.vc.Credential.ProofType.EXTERNAL; import static org.oneedtech.inspect.vc.VerifiableCredential.ProofType.EXTERNAL;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
@ -25,7 +25,7 @@ import org.oneedtech.inspect.util.json.ObjectMapperCache;
import org.oneedtech.inspect.util.resource.Resource; import org.oneedtech.inspect.util.resource.Resource;
import org.oneedtech.inspect.util.resource.UriResource; import org.oneedtech.inspect.util.resource.UriResource;
import org.oneedtech.inspect.util.resource.context.ResourceContext; import org.oneedtech.inspect.util.resource.context.ResourceContext;
import org.oneedtech.inspect.vc.Credential.Type; import org.oneedtech.inspect.vc.VerifiableCredential.Type;
import org.oneedtech.inspect.vc.probe.ContextPropertyProbe; import org.oneedtech.inspect.vc.probe.ContextPropertyProbe;
import org.oneedtech.inspect.vc.probe.EmbeddedProofProbe; import org.oneedtech.inspect.vc.probe.EmbeddedProofProbe;
import org.oneedtech.inspect.vc.probe.ExpirationProbe; import org.oneedtech.inspect.vc.probe.ExpirationProbe;
@ -60,7 +60,7 @@ public class EndorsementInspector extends VCInspector implements SubInspector {
* *
*/ */
Credential endorsement = (Credential) checkNotNull(parentObjects.get(CREDENTIAL_KEY)); VerifiableCredential endorsement = (VerifiableCredential) checkNotNull(parentObjects.get(CREDENTIAL_KEY));
ObjectMapper mapper = ObjectMapperCache.get(DEFAULT); ObjectMapper mapper = ObjectMapperCache.get(DEFAULT);
JsonPathEvaluator jsonPath = new JsonPathEvaluator(mapper); JsonPathEvaluator jsonPath = new JsonPathEvaluator(mapper);
@ -76,7 +76,7 @@ public class EndorsementInspector extends VCInspector implements SubInspector {
try { try {
//context and type properties //context and type properties
Credential.Type type = Type.EndorsementCredential; VerifiableCredential.Type type = Type.EndorsementCredential;
for(Probe<JsonNode> probe : List.of(new ContextPropertyProbe(type), new TypePropertyProbe(type))) { for(Probe<JsonNode> probe : List.of(new ContextPropertyProbe(type), new TypePropertyProbe(type))) {
probeCount++; probeCount++;
accumulator.add(probe.run(endorsement.getJson(), ctx)); accumulator.add(probe.run(endorsement.getJson(), ctx));
@ -111,7 +111,7 @@ public class EndorsementInspector extends VCInspector implements SubInspector {
} }
//revocation, expiration and issuance //revocation, expiration and issuance
for(Probe<Credential> probe : List.of(new RevocationListProbe(), for(Probe<VerifiableCredential> probe : List.of(new RevocationListProbe(),
new ExpirationProbe(), new IssuanceProbe())) { new ExpirationProbe(), new IssuanceProbe())) {
probeCount++; probeCount++;
accumulator.add(probe.run(endorsement, ctx)); accumulator.add(probe.run(endorsement, ctx));

View File

@ -6,7 +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.code.Defensives.*;
import static org.oneedtech.inspect.util.json.ObjectMapperCache.Config.DEFAULT; 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.AbstractBaseCredential.CREDENTIAL_KEY;
import static org.oneedtech.inspect.vc.Credential.ProofType.EXTERNAL; import static org.oneedtech.inspect.vc.VerifiableCredential.ProofType.EXTERNAL;
import static org.oneedtech.inspect.vc.payload.PayloadParser.fromJwt; import static org.oneedtech.inspect.vc.payload.PayloadParser.fromJwt;
import static org.oneedtech.inspect.vc.util.JsonNodeUtil.asNodeList; import static org.oneedtech.inspect.vc.util.JsonNodeUtil.asNodeList;
@ -34,7 +34,7 @@ import org.oneedtech.inspect.util.resource.ResourceType;
import org.oneedtech.inspect.util.resource.UriResource; import org.oneedtech.inspect.util.resource.UriResource;
import org.oneedtech.inspect.util.resource.context.ResourceContext; import org.oneedtech.inspect.util.resource.context.ResourceContext;
import org.oneedtech.inspect.util.spec.Specification; import org.oneedtech.inspect.util.spec.Specification;
import org.oneedtech.inspect.vc.Credential.Type; import org.oneedtech.inspect.vc.VerifiableCredential.Type;
import org.oneedtech.inspect.vc.payload.PngParser; import org.oneedtech.inspect.vc.payload.PngParser;
import org.oneedtech.inspect.vc.payload.SvgParser; import org.oneedtech.inspect.vc.payload.SvgParser;
import org.oneedtech.inspect.vc.probe.ContextPropertyProbe; import org.oneedtech.inspect.vc.probe.ContextPropertyProbe;
@ -58,7 +58,7 @@ import com.google.common.collect.ImmutableList;
* @author mgylling * @author mgylling
*/ */
public class OB30Inspector extends VCInspector implements SubInspector { public class OB30Inspector extends VCInspector implements SubInspector {
protected final List<Probe<Credential>> userProbes; protected final List<Probe<VerifiableCredential>> userProbes;
protected OB30Inspector(OB30Inspector.Builder builder) { protected OB30Inspector(OB30Inspector.Builder builder) {
super(builder); super(builder);
@ -93,7 +93,7 @@ public class OB30Inspector extends VCInspector implements SubInspector {
.put(resource) .put(resource)
.put(Key.JACKSON_OBJECTMAPPER, mapper) .put(Key.JACKSON_OBJECTMAPPER, mapper)
.put(Key.JSONPATH_EVALUATOR, jsonPath) .put(Key.JSONPATH_EVALUATOR, jsonPath)
.put(Key.GENERATED_OBJECT_BUILDER, new Credential.Builder()) .put(Key.GENERATED_OBJECT_BUILDER, new VerifiableCredential.Builder())
.put(Key.PNG_CREDENTIAL_KEY, PngParser.Keys.OB30) .put(Key.PNG_CREDENTIAL_KEY, PngParser.Keys.OB30)
.put(Key.SVG_CREDENTIAL_QNAME, SvgParser.QNames.OB30) .put(Key.SVG_CREDENTIAL_QNAME, SvgParser.QNames.OB30)
.build(); .build();
@ -108,15 +108,15 @@ public class OB30Inspector extends VCInspector implements SubInspector {
if(broken(accumulator, true)) return abort(ctx, accumulator, probeCount); if(broken(accumulator, true)) return abort(ctx, accumulator, probeCount);
//we expect the above to place a generated object in the context //we expect the above to place a generated object in the context
Credential ob = ctx.getGeneratedObject(Credential.ID); VerifiableCredential ob = ctx.getGeneratedObject(VerifiableCredential.ID);
//call the subinspector method of this //call the subinspector method of this
Report subReport = this.run(resource, Map.of(Credential.CREDENTIAL_KEY, ob)); Report subReport = this.run(resource, Map.of(VerifiableCredential.CREDENTIAL_KEY, ob));
probeCount += subReport.getSummary().getTotalRun(); probeCount += subReport.getSummary().getTotalRun();
accumulator.add(subReport); accumulator.add(subReport);
//finally, run any user-added probes //finally, run any user-added probes
for(Probe<Credential> probe : userProbes) { for(Probe<VerifiableCredential> probe : userProbes) {
probeCount++; probeCount++;
accumulator.add(probe.run(ob, ctx)); accumulator.add(probe.run(ob, ctx));
} }
@ -131,11 +131,11 @@ public class OB30Inspector extends VCInspector implements SubInspector {
@Override @Override
public Report run(Resource resource, Map<String, GeneratedObject> parentObjects) { public Report run(Resource resource, Map<String, GeneratedObject> parentObjects) {
Credential ob = checkNotNull((Credential)parentObjects.get(CREDENTIAL_KEY)); VerifiableCredential ob = checkNotNull((VerifiableCredential)parentObjects.get(CREDENTIAL_KEY));
ObjectMapper mapper = ObjectMapperCache.get(DEFAULT); ObjectMapper mapper = ObjectMapperCache.get(DEFAULT);
JsonPathEvaluator jsonPath = new JsonPathEvaluator(mapper); JsonPathEvaluator jsonPath = new JsonPathEvaluator(mapper);
Credential.Builder credentialBuilder = new Credential.Builder(); VerifiableCredential.Builder credentialBuilder = new VerifiableCredential.Builder();
RunContext ctx = new RunContext.Builder() RunContext ctx = new RunContext.Builder()
.put(this) .put(this)
.put(resource) .put(resource)
@ -152,7 +152,7 @@ public class OB30Inspector extends VCInspector implements SubInspector {
try { try {
//context and type properties //context and type properties
Credential.Type type = Type.OpenBadgeCredential; VerifiableCredential.Type type = Type.OpenBadgeCredential;
for(Probe<JsonNode> probe : List.of(new ContextPropertyProbe(type), new TypePropertyProbe(type))) { for(Probe<JsonNode> probe : List.of(new ContextPropertyProbe(type), new TypePropertyProbe(type))) {
probeCount++; probeCount++;
accumulator.add(probe.run(ob.getJson(), ctx)); accumulator.add(probe.run(ob.getJson(), ctx));
@ -194,7 +194,7 @@ public class OB30Inspector extends VCInspector implements SubInspector {
} }
//revocation, expiration and issuance //revocation, expiration and issuance
for(Probe<Credential> probe : List.of(new RevocationListProbe(), for(Probe<VerifiableCredential> probe : List.of(new RevocationListProbe(),
new ExpirationProbe(), new IssuanceProbe())) { new ExpirationProbe(), new IssuanceProbe())) {
probeCount++; probeCount++;
accumulator.add(probe.run(ob, ctx)); accumulator.add(probe.run(ob, ctx));
@ -207,7 +207,7 @@ public class OB30Inspector extends VCInspector implements SubInspector {
List<JsonNode> endorsements = asNodeList(ob.getJson(), "$..endorsement", jsonPath); List<JsonNode> endorsements = asNodeList(ob.getJson(), "$..endorsement", jsonPath);
for(JsonNode node : endorsements) { for(JsonNode node : endorsements) {
probeCount++; probeCount++;
Credential endorsement = credentialBuilder.resource(resource).jsonData(node).build(); VerifiableCredential endorsement = credentialBuilder.resource(resource).jsonData(node).build();
accumulator.add(endorsementInspector.run(resource, Map.of(CREDENTIAL_KEY, endorsement))); accumulator.add(endorsementInspector.run(resource, Map.of(CREDENTIAL_KEY, endorsement)));
} }
@ -217,7 +217,7 @@ public class OB30Inspector extends VCInspector implements SubInspector {
probeCount++; probeCount++;
String jwt = node.asText(); String jwt = node.asText();
JsonNode vcNode = fromJwt(jwt, ctx); JsonNode vcNode = fromJwt(jwt, ctx);
Credential endorsement = credentialBuilder.resource(resource).jsonData(node).jwt(jwt).build(); VerifiableCredential endorsement = credentialBuilder.resource(resource).jsonData(node).jwt(jwt).build();
accumulator.add(endorsementInspector.run(resource, Map.of(CREDENTIAL_KEY, endorsement))); accumulator.add(endorsementInspector.run(resource, Map.of(CREDENTIAL_KEY, endorsement)));
} }

View File

@ -47,7 +47,7 @@ public abstract class VCInspector extends Inspector {
* provided, then start the verification process over using the response as input. If the request fails, * provided, then start the verification process over using the response as input. If the request fails,
* the credential is invalid. * the credential is invalid.
*/ */
protected Optional<String> checkRefreshService(Credential crd, RunContext ctx) { protected Optional<String> checkRefreshService(VerifiableCredential crd, RunContext ctx) {
JsonNode refreshServiceNode = crd.getJson().get("refreshService"); JsonNode refreshServiceNode = crd.getJson().get("refreshService");
if(refreshServiceNode != null) { if(refreshServiceNode != null) {
JsonNode serviceTypeNode = refreshServiceNode.get("type"); JsonNode serviceTypeNode = refreshServiceNode.get("type");
@ -64,14 +64,14 @@ public abstract class VCInspector extends Inspector {
protected static final String REFRESHED = "is.refreshed.credential"; protected static final String REFRESHED = "is.refreshed.credential";
public abstract static class Builder<B extends VCInspector.Builder<B>> extends Inspector.Builder<B> { public abstract static class Builder<B extends VCInspector.Builder<B>> extends Inspector.Builder<B> {
final List<Probe<Credential>> probes; final List<Probe<VerifiableCredential>> probes;
public Builder() { public Builder() {
super(); super();
this.probes = new ArrayList<>(); this.probes = new ArrayList<>();
} }
public VCInspector.Builder<B> add(Probe<Credential> probe) { public VCInspector.Builder<B> add(Probe<VerifiableCredential> probe) {
probes.add(probe); probes.add(probe);
return this; return this;
} }

View File

@ -1,9 +1,9 @@
package org.oneedtech.inspect.vc; package org.oneedtech.inspect.vc;
import static org.oneedtech.inspect.vc.Credential.Type.AchievementCredential; import static org.oneedtech.inspect.vc.VerifiableCredential.Type.AchievementCredential;
import static org.oneedtech.inspect.vc.Credential.Type.ClrCredential; import static org.oneedtech.inspect.vc.VerifiableCredential.Type.ClrCredential;
import static org.oneedtech.inspect.vc.Credential.Type.EndorsementCredential; import static org.oneedtech.inspect.vc.VerifiableCredential.Type.EndorsementCredential;
import static org.oneedtech.inspect.vc.Credential.Type.VerifiablePresentation; import static org.oneedtech.inspect.vc.VerifiableCredential.Type.VerifiablePresentation;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
@ -23,14 +23,14 @@ import com.google.common.collect.ImmutableMap;
* and the extracted JSON data plus any other stuff Probes need. * and the extracted JSON data plus any other stuff Probes need.
* @author mgylling * @author mgylling
*/ */
public class Credential extends AbstractBaseCredential { public class VerifiableCredential extends AbstractBaseCredential {
final Credential.Type credentialType; final VerifiableCredential.Type credentialType;
protected Credential(Resource resource, JsonNode data, String jwt, Map<String, SchemaKey> schemas) { protected VerifiableCredential(Resource resource, JsonNode data, String jwt, Map<String, SchemaKey> schemas) {
super(ID, resource, data, jwt, schemas); super(ID, resource, data, jwt, schemas);
ArrayNode typeNode = (ArrayNode)jsonData.get("type"); ArrayNode typeNode = (ArrayNode)jsonData.get("type");
this.credentialType = Credential.Type.valueOf(typeNode); this.credentialType = VerifiableCredential.Type.valueOf(typeNode);
} }
public String getCredentialType() { public String getCredentialType() {
@ -41,7 +41,7 @@ public class Credential extends AbstractBaseCredential {
return jwt == null ? ProofType.EMBEDDED : ProofType.EXTERNAL; return jwt == null ? ProofType.EMBEDDED : ProofType.EXTERNAL;
} }
private static final Map<Credential.Type, SchemaKey> schemas = new ImmutableMap.Builder<Credential.Type, SchemaKey>() private static final Map<VerifiableCredential.Type, SchemaKey> schemas = new ImmutableMap.Builder<VerifiableCredential.Type, SchemaKey>()
.put(AchievementCredential, Catalog.OB_30_ACHIEVEMENTCREDENTIAL_JSON) .put(AchievementCredential, Catalog.OB_30_ACHIEVEMENTCREDENTIAL_JSON)
.put(ClrCredential, Catalog.CLR_20_CLRCREDENTIAL_JSON) .put(ClrCredential, Catalog.CLR_20_CLRCREDENTIAL_JSON)
.put(VerifiablePresentation, Catalog.CLR_20_CLRCREDENTIAL_JSON) .put(VerifiablePresentation, Catalog.CLR_20_CLRCREDENTIAL_JSON)
@ -58,7 +58,7 @@ public class Credential extends AbstractBaseCredential {
VerifiableCredential, //this is an underspecifier in our context VerifiableCredential, //this is an underspecifier in our context
Unknown; Unknown;
public static Credential.Type valueOf (ArrayNode typeArray) { public static VerifiableCredential.Type valueOf (ArrayNode typeArray) {
if(typeArray != null) { if(typeArray != null) {
Iterator<JsonNode> iter = typeArray.iterator(); Iterator<JsonNode> iter = typeArray.iterator();
while(iter.hasNext()) { while(iter.hasNext()) {
@ -91,18 +91,18 @@ public class Credential extends AbstractBaseCredential {
.toString(); .toString();
} }
public static class Builder extends AbstractBaseCredential.Builder<Credential> { public static class Builder extends AbstractBaseCredential.Builder<VerifiableCredential> {
@Override @Override
public Credential build() { public VerifiableCredential build() {
// transform key of schemas map to string because the type of the key in the base map is generic // transform key of schemas map to string because the type of the key in the base map is generic
// and our specific key is an Enum // and our specific key is an Enum
return new Credential(getResource(), getJsonData(), getJwt(), return new VerifiableCredential(getResource(), getJsonData(), getJwt(),
schemas.entrySet().stream().collect(Collectors.toMap( schemas.entrySet().stream().collect(Collectors.toMap(
entry -> entry.getKey().toString(), entry -> entry.getKey().toString(),
entry -> entry.getValue()))); entry -> entry.getValue())));
} }
} }
public static final String ID = Credential.class.getCanonicalName(); public static final String ID = VerifiableCredential.class.getCanonicalName();
} }

View File

@ -8,7 +8,7 @@ import org.oneedtech.inspect.core.probe.RunContext;
import org.oneedtech.inspect.util.resource.Resource; import org.oneedtech.inspect.util.resource.Resource;
import org.oneedtech.inspect.util.resource.ResourceType; import org.oneedtech.inspect.util.resource.ResourceType;
import org.oneedtech.inspect.vc.AbstractBaseCredential; import org.oneedtech.inspect.vc.AbstractBaseCredential;
import org.oneedtech.inspect.vc.Credential; import org.oneedtech.inspect.vc.VerifiableCredential;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;

View File

@ -1,6 +1,6 @@
package org.oneedtech.inspect.vc.probe; package org.oneedtech.inspect.vc.probe;
import static org.oneedtech.inspect.vc.Credential.Type.*; import static org.oneedtech.inspect.vc.VerifiableCredential.Type.*;
import static org.oneedtech.inspect.util.code.Defensives.checkNotNull; import static org.oneedtech.inspect.util.code.Defensives.checkNotNull;
@ -11,7 +11,7 @@ import java.util.Set;
import org.oneedtech.inspect.core.probe.Probe; import org.oneedtech.inspect.core.probe.Probe;
import org.oneedtech.inspect.core.probe.RunContext; import org.oneedtech.inspect.core.probe.RunContext;
import org.oneedtech.inspect.core.report.ReportItems; import org.oneedtech.inspect.core.report.ReportItems;
import org.oneedtech.inspect.vc.Credential; import org.oneedtech.inspect.vc.VerifiableCredential;
import org.oneedtech.inspect.vc.util.JsonNodeUtil; import org.oneedtech.inspect.vc.util.JsonNodeUtil;
@ -25,9 +25,9 @@ import com.google.common.collect.ImmutableMap;
* @author mgylling * @author mgylling
*/ */
public class ContextPropertyProbe extends Probe<JsonNode> { public class ContextPropertyProbe extends Probe<JsonNode> {
private final Credential.Type type; private final VerifiableCredential.Type type;
public ContextPropertyProbe(Credential.Type type) { public ContextPropertyProbe(VerifiableCredential.Type type) {
super(ID); super(ID);
this.type = checkNotNull(type); this.type = checkNotNull(type);
} }
@ -58,7 +58,7 @@ public class ContextPropertyProbe extends Probe<JsonNode> {
return success(ctx); return success(ctx);
} }
private final static Map<Set<Credential.Type>, List<String>> values = new ImmutableMap.Builder<Set<Credential.Type>, List<String>>() private final static Map<Set<VerifiableCredential.Type>, List<String>> values = new ImmutableMap.Builder<Set<VerifiableCredential.Type>, List<String>>()
.put(Set.of(OpenBadgeCredential, AchievementCredential, EndorsementCredential), .put(Set.of(OpenBadgeCredential, AchievementCredential, EndorsementCredential),
List.of("https://www.w3.org/2018/credentials/v1", List.of("https://www.w3.org/2018/credentials/v1",
//"https://purl.imsglobal.org/spec/ob/v3p0/context.json")) //dev legacy //"https://purl.imsglobal.org/spec/ob/v3p0/context.json")) //dev legacy

View File

@ -9,7 +9,7 @@ import org.oneedtech.inspect.util.resource.Resource;
import org.oneedtech.inspect.util.resource.ResourceType; import org.oneedtech.inspect.util.resource.ResourceType;
import org.oneedtech.inspect.util.resource.detect.TypeDetector; import org.oneedtech.inspect.util.resource.detect.TypeDetector;
import org.oneedtech.inspect.vc.AbstractBaseCredential; 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; import org.oneedtech.inspect.vc.payload.PayloadParserFactory;
/** /**
@ -39,7 +39,7 @@ public class CredentialParseProbe extends Probe<Resource> {
} }
} }
if(!Credential.RECOGNIZED_PAYLOAD_TYPES.contains(type.get())) { if(!VerifiableCredential.RECOGNIZED_PAYLOAD_TYPES.contains(type.get())) {
return fatal("Payload type not supported: " + type.get().getName(), context); return fatal("Payload type not supported: " + type.get().getName(), context);
} }

View File

@ -7,7 +7,7 @@ import java.util.Optional;
import org.oneedtech.inspect.core.probe.Probe; import org.oneedtech.inspect.core.probe.Probe;
import org.oneedtech.inspect.core.probe.RunContext; import org.oneedtech.inspect.core.probe.RunContext;
import org.oneedtech.inspect.core.report.ReportItems; import org.oneedtech.inspect.core.report.ReportItems;
import org.oneedtech.inspect.vc.Credential; import org.oneedtech.inspect.vc.VerifiableCredential;
import com.apicatalog.jsonld.StringUtils; import com.apicatalog.jsonld.StringUtils;
import com.apicatalog.jsonld.document.Document; import com.apicatalog.jsonld.document.Document;
@ -15,7 +15,6 @@ import com.apicatalog.jsonld.loader.DocumentLoaderOptions;
import com.apicatalog.multibase.Multibase; import com.apicatalog.multibase.Multibase;
import com.apicatalog.multicodec.Multicodec; import com.apicatalog.multicodec.Multicodec;
import com.apicatalog.multicodec.Multicodec.Codec; import com.apicatalog.multicodec.Multicodec.Codec;
import com.danubetech.verifiablecredentials.VerifiableCredential;
import foundation.identity.jsonld.ConfigurableDocumentLoader; import foundation.identity.jsonld.ConfigurableDocumentLoader;
import info.weboftrust.ldsignatures.LdProof; import info.weboftrust.ldsignatures.LdProof;
@ -28,7 +27,7 @@ import jakarta.json.JsonStructure;
* *
* @author mgylling * @author mgylling
*/ */
public class EmbeddedProofProbe extends Probe<Credential> { public class EmbeddedProofProbe extends Probe<VerifiableCredential> {
public EmbeddedProofProbe() { public EmbeddedProofProbe() {
super(ID); super(ID);
@ -39,11 +38,11 @@ public class EmbeddedProofProbe extends Probe<Credential> {
* (https://github.com/danubetech/verifiable-credentials-java) * (https://github.com/danubetech/verifiable-credentials-java)
*/ */
@Override @Override
public ReportItems run(Credential crd, RunContext ctx) throws Exception { public ReportItems run(VerifiableCredential crd, RunContext ctx) throws Exception {
// TODO: What there are multiple proofs? // TODO: What there are multiple proofs?
VerifiableCredential vc = VerifiableCredential.fromJson(new StringReader(crd.getJson().toString())); com.danubetech.verifiablecredentials.VerifiableCredential vc = com.danubetech.verifiablecredentials.VerifiableCredential.fromJson(new StringReader(crd.getJson().toString()));
ConfigurableDocumentLoader documentLoader = new ConfigurableDocumentLoader(); ConfigurableDocumentLoader documentLoader = new ConfigurableDocumentLoader();
documentLoader.setEnableHttp(true); documentLoader.setEnableHttp(true);
documentLoader.setEnableHttps(true); documentLoader.setEnableHttps(true);

View File

@ -5,7 +5,7 @@ import java.time.ZonedDateTime;
import org.oneedtech.inspect.core.probe.Probe; import org.oneedtech.inspect.core.probe.Probe;
import org.oneedtech.inspect.core.probe.RunContext; import org.oneedtech.inspect.core.probe.RunContext;
import org.oneedtech.inspect.core.report.ReportItems; import org.oneedtech.inspect.core.report.ReportItems;
import org.oneedtech.inspect.vc.Credential; import org.oneedtech.inspect.vc.VerifiableCredential;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
@ -13,14 +13,14 @@ import com.fasterxml.jackson.databind.JsonNode;
* A Probe that verifies a credential's expiration status * A Probe that verifies a credential's expiration status
* @author mgylling * @author mgylling
*/ */
public class ExpirationProbe extends Probe<Credential> { public class ExpirationProbe extends Probe<VerifiableCredential> {
public ExpirationProbe() { public ExpirationProbe() {
super(ID); super(ID);
} }
@Override @Override
public ReportItems run(Credential crd, RunContext ctx) throws Exception { public ReportItems run(VerifiableCredential crd, RunContext ctx) throws Exception {
/* /*
* If the AchievementCredential or EndorsementCredential has an expirationDate property * If the AchievementCredential or EndorsementCredential has an expirationDate property
* and the expiration date is prior to the current date, the credential has expired. * and the expiration date is prior to the current date, the credential has expired.

View File

@ -21,7 +21,7 @@ import org.apache.http.util.EntityUtils;
import org.oneedtech.inspect.core.probe.Probe; import org.oneedtech.inspect.core.probe.Probe;
import org.oneedtech.inspect.core.probe.RunContext; import org.oneedtech.inspect.core.probe.RunContext;
import org.oneedtech.inspect.core.report.ReportItems; import org.oneedtech.inspect.core.report.ReportItems;
import org.oneedtech.inspect.vc.Credential; import org.oneedtech.inspect.vc.VerifiableCredential;
import com.auth0.jwt.JWT; import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier; import com.auth0.jwt.JWTVerifier;
@ -39,14 +39,14 @@ import com.google.common.base.Splitter;
* A Probe that verifies credential external proof (jwt) * A Probe that verifies credential external proof (jwt)
* @author mlyon * @author mlyon
*/ */
public class ExternalProofProbe extends Probe<Credential> { public class ExternalProofProbe extends Probe<VerifiableCredential> {
public ExternalProofProbe() { public ExternalProofProbe() {
super(ID); super(ID);
} }
@Override @Override
public ReportItems run(Credential crd, RunContext ctx) throws Exception { public ReportItems run(VerifiableCredential crd, RunContext ctx) throws Exception {
try { try {
verifySignature(crd, ctx); verifySignature(crd, ctx);
} catch (Exception e) { } catch (Exception e) {
@ -55,7 +55,7 @@ public class ExternalProofProbe extends Probe<Credential> {
return success(ctx); return success(ctx);
} }
private void verifySignature(Credential crd, RunContext ctx) throws Exception { private void verifySignature(VerifiableCredential crd, RunContext ctx) throws Exception {
checkTrue(crd.getJwt().isPresent(), "no jwt supplied"); checkTrue(crd.getJwt().isPresent(), "no jwt supplied");
checkTrue(crd.getJwt().get().length() > 0, "no jwt supplied"); checkTrue(crd.getJwt().get().length() > 0, "no jwt supplied");

View File

@ -11,7 +11,7 @@ import org.oneedtech.inspect.core.probe.RunContext;
import org.oneedtech.inspect.core.probe.json.JsonSchemaProbe; import org.oneedtech.inspect.core.probe.json.JsonSchemaProbe;
import org.oneedtech.inspect.core.report.ReportItems; import org.oneedtech.inspect.core.report.ReportItems;
import org.oneedtech.inspect.schema.SchemaKey; import org.oneedtech.inspect.schema.SchemaKey;
import org.oneedtech.inspect.vc.Credential; import org.oneedtech.inspect.vc.VerifiableCredential;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;

View File

@ -5,7 +5,7 @@ import java.time.ZonedDateTime;
import org.oneedtech.inspect.core.probe.Probe; import org.oneedtech.inspect.core.probe.Probe;
import org.oneedtech.inspect.core.probe.RunContext; import org.oneedtech.inspect.core.probe.RunContext;
import org.oneedtech.inspect.core.report.ReportItems; import org.oneedtech.inspect.core.report.ReportItems;
import org.oneedtech.inspect.vc.Credential; import org.oneedtech.inspect.vc.VerifiableCredential;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
@ -13,14 +13,14 @@ import com.fasterxml.jackson.databind.JsonNode;
* A Probe that verifies a credential's issuance status * A Probe that verifies a credential's issuance status
* @author mgylling * @author mgylling
*/ */
public class IssuanceProbe extends Probe<Credential> { public class IssuanceProbe extends Probe<VerifiableCredential> {
public IssuanceProbe() { public IssuanceProbe() {
super(ID); super(ID);
} }
@Override @Override
public ReportItems run(Credential crd, RunContext ctx) throws Exception { public ReportItems run(VerifiableCredential crd, RunContext ctx) throws Exception {
/* /*
* If the AchievementCredential or EndorsementCredential issuanceDate * If the AchievementCredential or EndorsementCredential issuanceDate
* property after the current date, the credential is not yet valid. * property after the current date, the credential is not yet valid.

View File

@ -10,7 +10,7 @@ import java.util.List;
import org.oneedtech.inspect.core.probe.Probe; import org.oneedtech.inspect.core.probe.Probe;
import org.oneedtech.inspect.core.probe.RunContext; import org.oneedtech.inspect.core.probe.RunContext;
import org.oneedtech.inspect.core.report.ReportItems; import org.oneedtech.inspect.core.report.ReportItems;
import org.oneedtech.inspect.vc.Credential; import org.oneedtech.inspect.vc.VerifiableCredential;
import org.oneedtech.inspect.vc.util.JsonNodeUtil; import org.oneedtech.inspect.vc.util.JsonNodeUtil;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
@ -20,14 +20,14 @@ import com.fasterxml.jackson.databind.ObjectMapper;
* A Probe that verifies a credential's revocation status. * A Probe that verifies a credential's revocation status.
* @author mgylling * @author mgylling
*/ */
public class RevocationListProbe extends Probe<Credential> { public class RevocationListProbe extends Probe<VerifiableCredential> {
public RevocationListProbe() { public RevocationListProbe() {
super(ID); super(ID);
} }
@Override @Override
public ReportItems run(Credential crd, RunContext ctx) throws Exception { public ReportItems run(VerifiableCredential crd, RunContext ctx) throws Exception {
/* /*
* If the AchievementCredential or EndorsementCredential has a credentialStatus property * If the AchievementCredential or EndorsementCredential has a credentialStatus property

View File

@ -7,8 +7,8 @@ import java.util.List;
import org.oneedtech.inspect.core.probe.Probe; import org.oneedtech.inspect.core.probe.Probe;
import org.oneedtech.inspect.core.probe.RunContext; import org.oneedtech.inspect.core.probe.RunContext;
import org.oneedtech.inspect.core.report.ReportItems; import org.oneedtech.inspect.core.report.ReportItems;
import org.oneedtech.inspect.vc.Credential; import org.oneedtech.inspect.vc.VerifiableCredential;
import org.oneedtech.inspect.vc.Credential.Type; import org.oneedtech.inspect.vc.VerifiableCredential.Type;
import org.oneedtech.inspect.vc.util.JsonNodeUtil; import org.oneedtech.inspect.vc.util.JsonNodeUtil;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
@ -20,9 +20,9 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
* @author mgylling * @author mgylling
*/ */
public class TypePropertyProbe extends Probe<JsonNode> { public class TypePropertyProbe extends Probe<JsonNode> {
private final Credential.Type expected; private final VerifiableCredential.Type expected;
public TypePropertyProbe(Credential.Type expected) { public TypePropertyProbe(VerifiableCredential.Type expected) {
super(ID); super(ID);
this.expected = checkNotNull(expected); this.expected = checkNotNull(expected);
} }
@ -40,15 +40,15 @@ public class TypePropertyProbe extends Probe<JsonNode> {
return fatal("The type property does not contain the entry 'VerifiableCredential'", ctx); return fatal("The type property does not contain the entry 'VerifiableCredential'", ctx);
} }
if (expected == Credential.Type.OpenBadgeCredential) { if (expected == VerifiableCredential.Type.OpenBadgeCredential) {
if (!values.contains("OpenBadgeCredential") && !values.contains("AchievementCredential")) { if (!values.contains("OpenBadgeCredential") && !values.contains("AchievementCredential")) {
return fatal("The type property does not contain one of 'OpenBadgeCredential' or 'AchievementCredential'", ctx); return fatal("The type property does not contain one of 'OpenBadgeCredential' or 'AchievementCredential'", ctx);
} }
} else if (expected == Credential.Type.ClrCredential) { } else if (expected == VerifiableCredential.Type.ClrCredential) {
if (!values.contains("ClrCredential")) { if (!values.contains("ClrCredential")) {
return fatal("The type property does not contain the entry 'ClrCredential'", ctx); return fatal("The type property does not contain the entry 'ClrCredential'", ctx);
} }
} else if (expected == Credential.Type.EndorsementCredential) { } else if (expected == VerifiableCredential.Type.EndorsementCredential) {
if (!values.contains("EndorsementCredential")) { if (!values.contains("EndorsementCredential")) {
return fatal("The type property does not contain the entry 'EndorsementCredential'", ctx); return fatal("The type property does not contain the entry 'EndorsementCredential'", ctx);
} }