LOGGER.log(WARNING,"Attempt to verify a downloaded file ("+file.getName()+") using SHA-512 failed since it could not be computed. Falling back to weaker algorithms. Update your JRE.");
break;
caseNOT_PROVIDED:
LOGGER.log(INFO,"Attempt to verify a downloaded file ("+file.getName()+") using SHA-512 failed since your configured update site does not provide this checksum. Falling back to weaker algorithms.");
thrownewIOException("Failed to compute SHA-1 of downloaded file, refusing installation");
}
if(!expectedSHA1.equals(actualSha1)){
thrownewIOException("Downloaded file "+downloadedFile.getAbsolutePath()+" does not match expected SHA-1, expected '"+expectedSHA1+"', actual '"+actualSha1+"'");
// keep 'downloadedFile' around for investigating what's going on
returnFormValidation.error("No correct_signature or correct_signature512 entry found in '"+name+"'.");
}
caseOK:
// fall through
}
if(warning!=null)returnwarning;
returnFormValidation.ok();
}catch(GeneralSecurityExceptione){
returnFormValidation.error(e,"Signature verification failed in "+name);
returnFormValidation.error(e,"Signature verification failed in "+name);
}
}
/**
* Computes the specified {@code digest} and {@code signature} for the provided {@code json} object and checks whether they match {@code digestEntry} and {@signatureEntry} in the provided {@code signatureJson} object.
*
* @param json the full update-center.json content
* @param signatureJson signature block from update-center.json
* @param digest digest to compute
* @param digestEntry key of the digest entry in {@code signatureJson} to check
* @param signature signature to compute
* @param signatureEntry key of the signature entry in {@code signatureJson} to check
* @param digestName name of the digest used for log/error messages
* @return {@link FormValidation.Kind#WARNING} if digest or signature are not provided, {@link FormValidation.Kind#OK} if check is successful, {@link FormValidation.Kind#ERROR} otherwise.
* @throws IOException if this somehow fails to write the canonical JSON representation to an in-memory stream.