Credential renamed to VerifiableCredential
This commit is contained in:
parent
0e077c7256
commit
3ab9c52300
@ -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.util.code.Defensives.checkNotNull;
|
||||
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.Credential.ProofType.EXTERNAL;
|
||||
import static org.oneedtech.inspect.vc.AbstractBaseCredential.CREDENTIAL_KEY;
|
||||
import static org.oneedtech.inspect.vc.VerifiableCredential.ProofType.EXTERNAL;
|
||||
|
||||
import java.net.URI;
|
||||
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.UriResource;
|
||||
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.EmbeddedProofProbe;
|
||||
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);
|
||||
JsonPathEvaluator jsonPath = new JsonPathEvaluator(mapper);
|
||||
@ -76,7 +76,7 @@ public class EndorsementInspector extends VCInspector implements SubInspector {
|
||||
try {
|
||||
|
||||
//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))) {
|
||||
probeCount++;
|
||||
accumulator.add(probe.run(endorsement.getJson(), ctx));
|
||||
@ -111,7 +111,7 @@ public class EndorsementInspector extends VCInspector implements SubInspector {
|
||||
}
|
||||
|
||||
//revocation, expiration and issuance
|
||||
for(Probe<Credential> probe : List.of(new RevocationListProbe(),
|
||||
for(Probe<VerifiableCredential> probe : List.of(new RevocationListProbe(),
|
||||
new ExpirationProbe(), new IssuanceProbe())) {
|
||||
probeCount++;
|
||||
accumulator.add(probe.run(endorsement, ctx));
|
||||
|
@ -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.json.ObjectMapperCache.Config.DEFAULT;
|
||||
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.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.context.ResourceContext;
|
||||
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.SvgParser;
|
||||
import org.oneedtech.inspect.vc.probe.ContextPropertyProbe;
|
||||
@ -58,7 +58,7 @@ import com.google.common.collect.ImmutableList;
|
||||
* @author mgylling
|
||||
*/
|
||||
public class OB30Inspector extends VCInspector implements SubInspector {
|
||||
protected final List<Probe<Credential>> userProbes;
|
||||
protected final List<Probe<VerifiableCredential>> userProbes;
|
||||
|
||||
protected OB30Inspector(OB30Inspector.Builder builder) {
|
||||
super(builder);
|
||||
@ -93,7 +93,7 @@ public class OB30Inspector extends VCInspector implements SubInspector {
|
||||
.put(resource)
|
||||
.put(Key.JACKSON_OBJECTMAPPER, mapper)
|
||||
.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.SVG_CREDENTIAL_QNAME, SvgParser.QNames.OB30)
|
||||
.build();
|
||||
@ -108,15 +108,15 @@ public class OB30Inspector extends VCInspector implements SubInspector {
|
||||
if(broken(accumulator, true)) return abort(ctx, accumulator, probeCount);
|
||||
|
||||
//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
|
||||
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();
|
||||
accumulator.add(subReport);
|
||||
|
||||
//finally, run any user-added probes
|
||||
for(Probe<Credential> probe : userProbes) {
|
||||
for(Probe<VerifiableCredential> probe : userProbes) {
|
||||
probeCount++;
|
||||
accumulator.add(probe.run(ob, ctx));
|
||||
}
|
||||
@ -131,11 +131,11 @@ public class OB30Inspector extends VCInspector implements SubInspector {
|
||||
@Override
|
||||
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);
|
||||
JsonPathEvaluator jsonPath = new JsonPathEvaluator(mapper);
|
||||
Credential.Builder credentialBuilder = new Credential.Builder();
|
||||
VerifiableCredential.Builder credentialBuilder = new VerifiableCredential.Builder();
|
||||
RunContext ctx = new RunContext.Builder()
|
||||
.put(this)
|
||||
.put(resource)
|
||||
@ -152,7 +152,7 @@ public class OB30Inspector extends VCInspector implements SubInspector {
|
||||
try {
|
||||
|
||||
//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))) {
|
||||
probeCount++;
|
||||
accumulator.add(probe.run(ob.getJson(), ctx));
|
||||
@ -194,7 +194,7 @@ public class OB30Inspector extends VCInspector implements SubInspector {
|
||||
}
|
||||
|
||||
//revocation, expiration and issuance
|
||||
for(Probe<Credential> probe : List.of(new RevocationListProbe(),
|
||||
for(Probe<VerifiableCredential> probe : List.of(new RevocationListProbe(),
|
||||
new ExpirationProbe(), new IssuanceProbe())) {
|
||||
probeCount++;
|
||||
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);
|
||||
for(JsonNode node : endorsements) {
|
||||
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)));
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ public class OB30Inspector extends VCInspector implements SubInspector {
|
||||
probeCount++;
|
||||
String jwt = node.asText();
|
||||
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)));
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
* 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");
|
||||
if(refreshServiceNode != null) {
|
||||
JsonNode serviceTypeNode = refreshServiceNode.get("type");
|
||||
@ -64,14 +64,14 @@ public abstract class VCInspector extends Inspector {
|
||||
protected static final String REFRESHED = "is.refreshed.credential";
|
||||
|
||||
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() {
|
||||
super();
|
||||
this.probes = new ArrayList<>();
|
||||
}
|
||||
|
||||
public VCInspector.Builder<B> add(Probe<Credential> probe) {
|
||||
public VCInspector.Builder<B> add(Probe<VerifiableCredential> probe) {
|
||||
probes.add(probe);
|
||||
return this;
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package org.oneedtech.inspect.vc;
|
||||
|
||||
import static org.oneedtech.inspect.vc.Credential.Type.AchievementCredential;
|
||||
import static org.oneedtech.inspect.vc.Credential.Type.ClrCredential;
|
||||
import static org.oneedtech.inspect.vc.Credential.Type.EndorsementCredential;
|
||||
import static org.oneedtech.inspect.vc.Credential.Type.VerifiablePresentation;
|
||||
import static org.oneedtech.inspect.vc.VerifiableCredential.Type.AchievementCredential;
|
||||
import static org.oneedtech.inspect.vc.VerifiableCredential.Type.ClrCredential;
|
||||
import static org.oneedtech.inspect.vc.VerifiableCredential.Type.EndorsementCredential;
|
||||
import static org.oneedtech.inspect.vc.VerifiableCredential.Type.VerifiablePresentation;
|
||||
|
||||
import java.util.Iterator;
|
||||
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.
|
||||
* @author mgylling
|
||||
*/
|
||||
public class Credential extends AbstractBaseCredential {
|
||||
final Credential.Type credentialType;
|
||||
public class VerifiableCredential extends AbstractBaseCredential {
|
||||
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);
|
||||
|
||||
ArrayNode typeNode = (ArrayNode)jsonData.get("type");
|
||||
this.credentialType = Credential.Type.valueOf(typeNode);
|
||||
this.credentialType = VerifiableCredential.Type.valueOf(typeNode);
|
||||
}
|
||||
|
||||
public String getCredentialType() {
|
||||
@ -41,7 +41,7 @@ public class Credential extends AbstractBaseCredential {
|
||||
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(ClrCredential, 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
|
||||
Unknown;
|
||||
|
||||
public static Credential.Type valueOf (ArrayNode typeArray) {
|
||||
public static VerifiableCredential.Type valueOf (ArrayNode typeArray) {
|
||||
if(typeArray != null) {
|
||||
Iterator<JsonNode> iter = typeArray.iterator();
|
||||
while(iter.hasNext()) {
|
||||
@ -91,18 +91,18 @@ public class Credential extends AbstractBaseCredential {
|
||||
.toString();
|
||||
}
|
||||
|
||||
public static class Builder extends AbstractBaseCredential.Builder<Credential> {
|
||||
public static class Builder extends AbstractBaseCredential.Builder<VerifiableCredential> {
|
||||
@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
|
||||
// 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(
|
||||
entry -> entry.getKey().toString(),
|
||||
entry -> entry.getValue())));
|
||||
}
|
||||
}
|
||||
|
||||
public static final String ID = Credential.class.getCanonicalName();
|
||||
public static final String ID = VerifiableCredential.class.getCanonicalName();
|
||||
|
||||
}
|
@ -8,7 +8,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.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.ObjectMapper;
|
||||
|
@ -1,6 +1,6 @@
|
||||
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;
|
||||
|
||||
@ -11,7 +11,7 @@ import java.util.Set;
|
||||
import org.oneedtech.inspect.core.probe.Probe;
|
||||
import org.oneedtech.inspect.core.probe.RunContext;
|
||||
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;
|
||||
|
||||
@ -25,9 +25,9 @@ import com.google.common.collect.ImmutableMap;
|
||||
* @author mgylling
|
||||
*/
|
||||
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);
|
||||
this.type = checkNotNull(type);
|
||||
}
|
||||
@ -58,7 +58,7 @@ public class ContextPropertyProbe extends Probe<JsonNode> {
|
||||
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),
|
||||
List.of("https://www.w3.org/2018/credentials/v1",
|
||||
//"https://purl.imsglobal.org/spec/ob/v3p0/context.json")) //dev legacy
|
||||
|
@ -9,7 +9,7 @@ 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;
|
||||
|
||||
/**
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ import java.util.Optional;
|
||||
import org.oneedtech.inspect.core.probe.Probe;
|
||||
import org.oneedtech.inspect.core.probe.RunContext;
|
||||
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.document.Document;
|
||||
@ -15,7 +15,6 @@ import com.apicatalog.jsonld.loader.DocumentLoaderOptions;
|
||||
import com.apicatalog.multibase.Multibase;
|
||||
import com.apicatalog.multicodec.Multicodec;
|
||||
import com.apicatalog.multicodec.Multicodec.Codec;
|
||||
import com.danubetech.verifiablecredentials.VerifiableCredential;
|
||||
|
||||
import foundation.identity.jsonld.ConfigurableDocumentLoader;
|
||||
import info.weboftrust.ldsignatures.LdProof;
|
||||
@ -28,7 +27,7 @@ import jakarta.json.JsonStructure;
|
||||
*
|
||||
* @author mgylling
|
||||
*/
|
||||
public class EmbeddedProofProbe extends Probe<Credential> {
|
||||
public class EmbeddedProofProbe extends Probe<VerifiableCredential> {
|
||||
|
||||
public EmbeddedProofProbe() {
|
||||
super(ID);
|
||||
@ -39,11 +38,11 @@ public class EmbeddedProofProbe extends Probe<Credential> {
|
||||
* (https://github.com/danubetech/verifiable-credentials-java)
|
||||
*/
|
||||
@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?
|
||||
|
||||
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();
|
||||
documentLoader.setEnableHttp(true);
|
||||
documentLoader.setEnableHttps(true);
|
||||
|
@ -5,7 +5,7 @@ import java.time.ZonedDateTime;
|
||||
import org.oneedtech.inspect.core.probe.Probe;
|
||||
import org.oneedtech.inspect.core.probe.RunContext;
|
||||
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;
|
||||
|
||||
@ -13,14 +13,14 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
* A Probe that verifies a credential's expiration status
|
||||
* @author mgylling
|
||||
*/
|
||||
public class ExpirationProbe extends Probe<Credential> {
|
||||
public class ExpirationProbe extends Probe<VerifiableCredential> {
|
||||
|
||||
public ExpirationProbe() {
|
||||
super(ID);
|
||||
}
|
||||
|
||||
@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
|
||||
* and the expiration date is prior to the current date, the credential has expired.
|
||||
|
@ -21,7 +21,7 @@ import org.apache.http.util.EntityUtils;
|
||||
import org.oneedtech.inspect.core.probe.Probe;
|
||||
import org.oneedtech.inspect.core.probe.RunContext;
|
||||
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.JWTVerifier;
|
||||
@ -39,14 +39,14 @@ import com.google.common.base.Splitter;
|
||||
* A Probe that verifies credential external proof (jwt)
|
||||
* @author mlyon
|
||||
*/
|
||||
public class ExternalProofProbe extends Probe<Credential> {
|
||||
public class ExternalProofProbe extends Probe<VerifiableCredential> {
|
||||
|
||||
public ExternalProofProbe() {
|
||||
super(ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReportItems run(Credential crd, RunContext ctx) throws Exception {
|
||||
public ReportItems run(VerifiableCredential crd, RunContext ctx) throws Exception {
|
||||
try {
|
||||
verifySignature(crd, ctx);
|
||||
} catch (Exception e) {
|
||||
@ -55,7 +55,7 @@ public class ExternalProofProbe extends Probe<Credential> {
|
||||
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().get().length() > 0, "no jwt supplied");
|
||||
|
||||
|
@ -11,7 +11,7 @@ import org.oneedtech.inspect.core.probe.RunContext;
|
||||
import org.oneedtech.inspect.core.probe.json.JsonSchemaProbe;
|
||||
import org.oneedtech.inspect.core.report.ReportItems;
|
||||
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.node.ArrayNode;
|
||||
|
@ -5,7 +5,7 @@ import java.time.ZonedDateTime;
|
||||
import org.oneedtech.inspect.core.probe.Probe;
|
||||
import org.oneedtech.inspect.core.probe.RunContext;
|
||||
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;
|
||||
|
||||
@ -13,14 +13,14 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
* A Probe that verifies a credential's issuance status
|
||||
* @author mgylling
|
||||
*/
|
||||
public class IssuanceProbe extends Probe<Credential> {
|
||||
public class IssuanceProbe extends Probe<VerifiableCredential> {
|
||||
|
||||
public IssuanceProbe() {
|
||||
super(ID);
|
||||
}
|
||||
|
||||
@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”
|
||||
* property after the current date, the credential is not yet valid.
|
||||
|
@ -10,7 +10,7 @@ import java.util.List;
|
||||
import org.oneedtech.inspect.core.probe.Probe;
|
||||
import org.oneedtech.inspect.core.probe.RunContext;
|
||||
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 com.fasterxml.jackson.databind.JsonNode;
|
||||
@ -20,14 +20,14 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
* A Probe that verifies a credential's revocation status.
|
||||
* @author mgylling
|
||||
*/
|
||||
public class RevocationListProbe extends Probe<Credential> {
|
||||
public class RevocationListProbe extends Probe<VerifiableCredential> {
|
||||
|
||||
public RevocationListProbe() {
|
||||
super(ID);
|
||||
}
|
||||
|
||||
@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
|
||||
|
@ -7,8 +7,8 @@ import java.util.List;
|
||||
import org.oneedtech.inspect.core.probe.Probe;
|
||||
import org.oneedtech.inspect.core.probe.RunContext;
|
||||
import org.oneedtech.inspect.core.report.ReportItems;
|
||||
import org.oneedtech.inspect.vc.Credential;
|
||||
import org.oneedtech.inspect.vc.Credential.Type;
|
||||
import org.oneedtech.inspect.vc.VerifiableCredential;
|
||||
import org.oneedtech.inspect.vc.VerifiableCredential.Type;
|
||||
import org.oneedtech.inspect.vc.util.JsonNodeUtil;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
@ -20,9 +20,9 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
* @author mgylling
|
||||
*/
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
if (expected == Credential.Type.OpenBadgeCredential) {
|
||||
if (expected == VerifiableCredential.Type.OpenBadgeCredential) {
|
||||
if (!values.contains("OpenBadgeCredential") && !values.contains("AchievementCredential")) {
|
||||
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")) {
|
||||
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")) {
|
||||
return fatal("The type property does not contain the entry 'EndorsementCredential'", ctx);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user