throw new Exception("Package version [" + packageVersion + "] does not exist, cannot check hash");
}
String realHash;
if (packageVersion.getMD5() != null) {
realHash = new MessageDigestGenerator(MessageDigestGenerator.MD5).calcDigestString(packageFile);
if (!packageVersion.getMD5().equals(realHash)) {
throw new Exception("Package version [" + packageVersion + "] failed MD5 check. expected=["
+ packageVersion.getMD5() + "], actual=[" + realHash + "]");
}
} else if (packageVersion.getSHA256() != null) {
realHash = new MessageDigestGenerator(MessageDigestGenerator.SHA_256).calcDigestString(packageFile);
if (!packageVersion.getSHA256().equals(realHash)) {
throw new Exception("Package version [" + packageVersion + "] failed SHA256 check. expected=["
+ packageVersion.getSHA256() + "], actual=[" + realHash + "]");
}
} else {