mirror of
https://github.com/hapifhir/org.hl7.fhir.core.git
synced 2025-02-13 16:24:44 +00:00
fix up SHC parsing problem
This commit is contained in:
parent
6a735d4319
commit
96b5bce878
@ -118,12 +118,14 @@ public abstract class ParserBase {
|
|||||||
|
|
||||||
//FIXME: i18n should be done here
|
//FIXME: i18n should be done here
|
||||||
public void logError(int line, int col, String path, IssueType type, String message, IssueSeverity level) throws FHIRFormatError {
|
public void logError(int line, int col, String path, IssueType type, String message, IssueSeverity level) throws FHIRFormatError {
|
||||||
|
if (errors != null) {
|
||||||
if (policy == ValidationPolicy.EVERYTHING) {
|
if (policy == ValidationPolicy.EVERYTHING) {
|
||||||
ValidationMessage msg = new ValidationMessage(Source.InstanceValidator, type, line, col, path, message, level);
|
ValidationMessage msg = new ValidationMessage(Source.InstanceValidator, type, line, col, path, message, level);
|
||||||
errors.add(msg);
|
errors.add(msg);
|
||||||
} else if (level == IssueSeverity.FATAL || (level == IssueSeverity.ERROR && policy == ValidationPolicy.QUICK))
|
} else if (level == IssueSeverity.FATAL || (level == IssueSeverity.ERROR && policy == ValidationPolicy.QUICK))
|
||||||
throw new FHIRFormatError(message+String.format(" at line %d col %d", line, col));
|
throw new FHIRFormatError(message+String.format(" at line %d col %d", line, col));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected StructureDefinition getDefinition(int line, int col, String ns, String name) throws FHIRFormatError {
|
protected StructureDefinition getDefinition(int line, int col, String ns, String name) throws FHIRFormatError {
|
||||||
|
@ -237,6 +237,7 @@ public class SHCParser extends ParserBase {
|
|||||||
|
|
||||||
private static final int BUFFER_SIZE = 1024;
|
private static final int BUFFER_SIZE = 1024;
|
||||||
public static final String CURRENT_PACKAGE = "hl7.fhir.uv.shc-vaccination#0.6.2";
|
public static final String CURRENT_PACKAGE = "hl7.fhir.uv.shc-vaccination#0.6.2";
|
||||||
|
private static final int MAX_ALLOWED_SHC_LENGTH = 1195;
|
||||||
|
|
||||||
// todo: deal with chunking
|
// todo: deal with chunking
|
||||||
public static String decodeQRCode(String src) {
|
public static String decodeQRCode(String src) {
|
||||||
@ -253,10 +254,14 @@ public class SHCParser extends ParserBase {
|
|||||||
return b.toString();
|
return b.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JWT decodeJWT(String jwt) throws IOException, DataFormatException {
|
public JWT decodeJWT(String jwt) throws IOException, DataFormatException {
|
||||||
if (jwt.startsWith("shc:/")) {
|
if (jwt.startsWith("shc:/")) {
|
||||||
jwt = decodeQRCode(jwt);
|
jwt = decodeQRCode(jwt);
|
||||||
}
|
}
|
||||||
|
if (jwt.length() > MAX_ALLOWED_SHC_LENGTH) {
|
||||||
|
logError(-1, -1, "jwt", IssueType.TOOLONG, "JWT Payload limit length is "+MAX_ALLOWED_SHC_LENGTH+" bytes for a single image - this has "+jwt.length()+" bytes", IssueSeverity.ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
String[] parts = splitToken(jwt);
|
String[] parts = splitToken(jwt);
|
||||||
byte[] headerJson;
|
byte[] headerJson;
|
||||||
byte[] payloadJson;
|
byte[] payloadJson;
|
||||||
|
@ -99,7 +99,7 @@ public class ResourceChecker {
|
|||||||
String s = new String(cnt, StandardCharsets.UTF_8);
|
String s = new String(cnt, StandardCharsets.UTF_8);
|
||||||
if (s.startsWith("shc:/"))
|
if (s.startsWith("shc:/"))
|
||||||
s = SHCParser.decodeQRCode(s);
|
s = SHCParser.decodeQRCode(s);
|
||||||
JWT jwt = SHCParser.decodeJWT(s);
|
JWT jwt = new SHCParser(context).decodeJWT(s);
|
||||||
return Manager.FhirFormat.SHC;
|
return Manager.FhirFormat.SHC;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (debug) {
|
if (debug) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user