Set assertion property name for JWS

This commit is contained in:
Xavi Aracil 2022-12-02 11:29:00 +01:00
parent 550dde03f6
commit 2492aa28f3
3 changed files with 16 additions and 19 deletions

View File

@ -302,4 +302,5 @@ public class Assertion extends Credential {
public static final String ID = Assertion.class.getCanonicalName(); public static final String ID = Assertion.class.getCanonicalName();
private static final String ISSUED_ON_PROPERTY_NAME = "issuedOn"; private static final String ISSUED_ON_PROPERTY_NAME = "issuedOn";
private static final String EXPIRES_AT_PROPERTY_NAME = "expires"; private static final String EXPIRES_AT_PROPERTY_NAME = "expires";
public static final String JWT_NODE_NAME = ""; // empty because the whole payload is the assertion
} }

View File

@ -32,7 +32,6 @@ import org.oneedtech.inspect.vc.probe.CredentialParseProbe;
import org.oneedtech.inspect.vc.probe.ExpirationProbe; import org.oneedtech.inspect.vc.probe.ExpirationProbe;
import org.oneedtech.inspect.vc.probe.IssuanceProbe; import org.oneedtech.inspect.vc.probe.IssuanceProbe;
import org.oneedtech.inspect.vc.probe.TypePropertyProbe; import org.oneedtech.inspect.vc.probe.TypePropertyProbe;
import org.oneedtech.inspect.vc.probe.validation.ValidationPropertyProbe;
import org.oneedtech.inspect.vc.probe.validation.ValidationPropertyProbeFactory; import org.oneedtech.inspect.vc.probe.validation.ValidationPropertyProbeFactory;
import org.oneedtech.inspect.vc.util.CachingDocumentLoader; import org.oneedtech.inspect.vc.util.CachingDocumentLoader;
@ -91,6 +90,7 @@ public class OB20Inspector extends Inspector {
.put(Key.PNG_CREDENTIAL_KEY, PngParser.Keys.OB20) .put(Key.PNG_CREDENTIAL_KEY, PngParser.Keys.OB20)
.put(Key.SVG_CREDENTIAL_QNAME, SvgParser.QNames.OB20) .put(Key.SVG_CREDENTIAL_QNAME, SvgParser.QNames.OB20)
.put(Key.JSON_DOCUMENT_LOADER, documentLoader) .put(Key.JSON_DOCUMENT_LOADER, documentLoader)
.put(Key.JWT_CREDENTIAL_NODE_NAME, Assertion.JWT_NODE_NAME)
.build(); .build();
List<ReportItems> accumulator = new ArrayList<>(); List<ReportItems> accumulator = new ArrayList<>();
@ -122,7 +122,11 @@ public class OB20Inspector extends Inspector {
accumulator.add(new JsonLDValidationProbe(jsonLdGeneratedObject).run(assertion, ctx)); accumulator.add(new JsonLDValidationProbe(jsonLdGeneratedObject).run(assertion, ctx));
if(broken(accumulator, true)) return abort(ctx, accumulator, probeCount); if(broken(accumulator, true)) return abort(ctx, accumulator, probeCount);
// Validates the Open Badge, from the compacted form
// Each Badge Object contains all required properties for its class
// This could be done validating with the schema, but seems that there are some error on that file
// So, we do a manual Probe for the nodes.
// Also, we validate the Open Badge, from the compacted form
JsonNode assertionNode = mapper.readTree(jsonLdGeneratedObject.getJson()); JsonNode assertionNode = mapper.readTree(jsonLdGeneratedObject.getJson());
List<Validation> validations = assertion.getValidations(); List<Validation> validations = assertion.getValidations();
for (Validation validation : validations) { for (Validation validation : validations) {
@ -138,21 +142,6 @@ public class OB20Inspector extends Inspector {
accumulator.add(probe.run(assertion, ctx)); accumulator.add(probe.run(assertion, ctx));
if(broken(accumulator)) return abort(ctx, accumulator, probeCount); if(broken(accumulator)) return abort(ctx, accumulator, probeCount);
} }
// Each Badge Object contains all required properties for its class
// This could be done validating with the schema, but seems that there are some error on that file
// So, we do a manual Probe for the nodes
// accumulator.add(new RequiredFieldsProbe(jsonLdGeneratedObject).run(assertion, ctx));
// if(broken(accumulator, true)) return abort(ctx, accumulator, probeCount);
//canonical schema and inline schemata
// SchemaKey schema = assertion.getSchemaKey().orElseThrow();
// for(Probe<JsonNode> probe : List.of(new JsonSchemaProbe(schema), new InlineJsonSchemaProbe(schema))) {
// probeCount++;
// accumulator.add(probe.run(assertion.getJson(), ctx));
// if(broken(accumulator)) return abort(ctx, accumulator, probeCount);
// }
} catch (Exception e) { } catch (Exception e) {
accumulator.add(onProbeException(Probe.ID.NO_UNCAUGHT_EXCEPTIONS, resource, e)); accumulator.add(onProbeException(Probe.ID.NO_UNCAUGHT_EXCEPTIONS, resource, e));
} }

View File

@ -89,7 +89,14 @@ public class OB20Tests {
}); });
} }
@Test
void testSimpleJWTValid() {
assertDoesNotThrow(()->{
Report report = validator.run(Samples.OB20.JWT.SIMPLE_JWT.asFileResource());
if(verbose) PrintHelper.print(report, true);
assertValid(report);
});
}
@Nested @Nested
static class WarningTests { static class WarningTests {