mirror of
https://github.com/hapifhir/org.hl7.fhir.core.git
synced 2025-02-09 06:14:45 +00:00
SHCParser file cleanup (#640)
* Use File.createTempFile to manage SHCParser payload writing * Undo auto-reorg imports * Remove JsonTrackingParser.write
This commit is contained in:
parent
52cbe69651
commit
83b1702cc5
@ -97,7 +97,7 @@ public class SHCParser extends ParserBase {
|
||||
return res;
|
||||
}
|
||||
map = jwt.map;
|
||||
JsonTrackingParser.write(jwt.payload, "c:\\temp\\payload.json");
|
||||
|
||||
checkNamedProperties(jwt.getPayload(), prefix+"payload", "iss", "nbf", "vc");
|
||||
checkProperty(jwt.getPayload(), prefix+"payload", "iss", true, "String");
|
||||
logError(1, 1, prefix+"JWT", IssueType.INFORMATIONAL, "The FHIR Validator does not check the JWT signature "+
|
||||
@ -105,43 +105,43 @@ public class SHCParser extends ParserBase {
|
||||
checkProperty(jwt.getPayload(), prefix+"payload", "nbf", true, "Number");
|
||||
JsonObject vc = jwt.getPayload().getAsJsonObject("vc");
|
||||
if (vc == null) {
|
||||
logError(1, 1, "JWT", IssueType.STRUCTURE, "Unable to find property 'vc' in the payload", IssueSeverity.ERROR);
|
||||
logError(1, 1, "JWT", IssueType.STRUCTURE, "Unable to find property 'vc' in the payload", IssueSeverity.ERROR);
|
||||
return res;
|
||||
}
|
||||
String path = prefix+"payload.vc";
|
||||
checkNamedProperties(vc, path, "type", "credentialSubject");
|
||||
if (!checkProperty(vc, path, "type", true, "Array")) {
|
||||
return res;
|
||||
if (!checkProperty(vc, path, "type", true, "Array")) {
|
||||
return res;
|
||||
}
|
||||
JsonArray type = vc.getAsJsonArray("type");
|
||||
int i = 0;
|
||||
for (JsonElement e : type) {
|
||||
if (!(e instanceof JsonPrimitive)) {
|
||||
logError(line(e), col(e), path+".type["+i+"]", IssueType.STRUCTURE, "Wrong Property Type in JSON Payload. Expected : String but found "+JSONUtil.type(e), IssueSeverity.ERROR);
|
||||
logError(line(e), col(e), path+".type["+i+"]", IssueType.STRUCTURE, "Wrong Property Type in JSON Payload. Expected : String but found "+JSONUtil.type(e), IssueSeverity.ERROR);
|
||||
} else {
|
||||
types.add(e.getAsString());
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (!types.contains("https://smarthealth.cards#health-card")) {
|
||||
logError(line(vc), col(vc), path, IssueType.STRUCTURE, "Card does not claim to be of type https://smarthealth.cards#health-card, cannot validate", IssueSeverity.ERROR);
|
||||
logError(line(vc), col(vc), path, IssueType.STRUCTURE, "Card does not claim to be of type https://smarthealth.cards#health-card, cannot validate", IssueSeverity.ERROR);
|
||||
return res;
|
||||
}
|
||||
if (!checkProperty(vc, path, "credentialSubject", true, "Object")) {
|
||||
return res;
|
||||
if (!checkProperty(vc, path, "credentialSubject", true, "Object")) {
|
||||
return res;
|
||||
}
|
||||
JsonObject cs = vc.getAsJsonObject("credentialSubject");
|
||||
path = path+".credentialSubject";
|
||||
if (!checkProperty(cs, path, "fhirVersion", true, "String")) {
|
||||
return res;
|
||||
if (!checkProperty(cs, path, "fhirVersion", true, "String")) {
|
||||
return res;
|
||||
}
|
||||
JsonElement fv = cs.get("fhirVersion");
|
||||
if (!VersionUtilities.versionsCompatible(context.getVersion(), fv.getAsString())) {
|
||||
logError(line(fv), col(fv), path+".fhirVersion", IssueType.STRUCTURE, "Card claims to be of version "+fv.getAsString()+", cannot be validated against version "+context.getVersion(), IssueSeverity.ERROR);
|
||||
return res;
|
||||
}
|
||||
if (!checkProperty(cs, path, "fhirBundle", true, "Object")) {
|
||||
return res;
|
||||
logError(line(fv), col(fv), path+".fhirVersion", IssueType.STRUCTURE, "Card claims to be of version "+fv.getAsString()+", cannot be validated against version "+context.getVersion(), IssueSeverity.ERROR);
|
||||
return res;
|
||||
}
|
||||
if (!checkProperty(cs, path, "fhirBundle", true, "Object")) {
|
||||
return res;
|
||||
}
|
||||
// ok. all checks passed, we can now validate the bundle
|
||||
Element e = jsonParser.parse(cs.getAsJsonObject("fhirBundle"), map);
|
||||
|
Loading…
x
Reference in New Issue
Block a user