normalize variable names, add break
This commit is contained in:
parent
9ab087f026
commit
59642ac5ab
@ -39,10 +39,10 @@ public final class PngParser extends PayloadParser {
|
|||||||
imageReader.setInput(ImageIO.createImageInputStream(is), true);
|
imageReader.setInput(ImageIO.createImageInputStream(is), true);
|
||||||
IIOMetadata metadata = imageReader.getImageMetadata(0);
|
IIOMetadata metadata = imageReader.getImageMetadata(0);
|
||||||
|
|
||||||
String credentialString = null;
|
String vcString = null;
|
||||||
String jwtString = null;
|
String jwtString = null;
|
||||||
String formatSearch = null;
|
String formatSearch = null;
|
||||||
JsonNode credential = null;
|
JsonNode vcNode = null;
|
||||||
|
|
||||||
String[] names = metadata.getMetadataFormatNames();
|
String[] names = metadata.getMetadataFormatNames();
|
||||||
int length = names.length;
|
int length = names.length;
|
||||||
@ -50,25 +50,26 @@ public final class PngParser extends PayloadParser {
|
|||||||
//Check all names rather than limiting to PNG format to remain malleable through any library changes. (Could limit to "javax_imageio_png_1.0")
|
//Check all names rather than limiting to PNG format to remain malleable through any library changes. (Could limit to "javax_imageio_png_1.0")
|
||||||
formatSearch = getOpenBadgeCredentialNodeText(metadata.getAsTree(names[i]));
|
formatSearch = getOpenBadgeCredentialNodeText(metadata.getAsTree(names[i]));
|
||||||
if(formatSearch != null) {
|
if(formatSearch != null) {
|
||||||
credentialString = formatSearch;
|
vcString = formatSearch;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(credentialString == null) {
|
if(vcString == null) {
|
||||||
throw new IllegalArgumentException("No credential inside PNG");
|
throw new IllegalArgumentException("No credential inside PNG");
|
||||||
}
|
}
|
||||||
|
|
||||||
credentialString = credentialString.trim();
|
vcString = vcString.trim();
|
||||||
if(credentialString.charAt(0) != '{'){
|
if(vcString.charAt(0) != '{'){
|
||||||
//This is a jwt. Fetch either the 'vc' out of the payload and save the string for signature verification.
|
//This is a jwt. Fetch either the 'vc' out of the payload and save the string for signature verification.
|
||||||
jwtString = credentialString;
|
jwtString = vcString;
|
||||||
credential = fromJwt(credentialString, ctx);
|
vcNode = fromJwt(vcString, ctx);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
credential = fromString(credentialString, ctx);
|
vcNode = fromString(vcString, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Credential(resource, credential, jwtString);
|
return new Credential(resource, vcNode, jwtString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user