Skip to content

Commit

Permalink
Merge pull request #729 from akvo/issue/725
Browse files Browse the repository at this point in the history
[#725] Fixes optimization logic
  • Loading branch information
rumca committed Aug 19, 2014
2 parents 834d3b6 + 9bf04be commit c607a56
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions GAE/src/org/waterforpeople/mapping/app/web/TaskServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,16 @@ public static ArrayList<String> extractDataFromZip(ZipInputStream zis)
// check the signature if we have it
String allowUnsigned = PropertyUtil.getProperty(ALLOW_UNSIGNED);

if ("false".equalsIgnoreCase(allowUnsigned) && surveyDataOnly != null && dataSig != null) {
if ("false".equalsIgnoreCase(allowUnsigned)) {

if (dataSig == null) {
throw new SignedDataException("Datafile does not have a signature");
}

if (surveyDataOnly == null) {
throw new SignedDataException("data.txt not found in data zip");
}

try {
MessageDigest sha1Digest = MessageDigest.getInstance("SHA1");
byte[] digest = sha1Digest.digest(surveyDataOnly
Expand All @@ -392,11 +401,6 @@ public static ArrayList<String> extractDataFromZip(ZipInputStream zis)
} catch (GeneralSecurityException e) {
throw new SignedDataException("Could not calculate signature", e);
}

} else if (surveyDataOnly != null) {
// if there is no signature, check the configuration to see if we
// are allowed to proceed
throw new SignedDataException("Datafile does not have a signature");
}

return lines;
Expand Down

0 comments on commit c607a56

Please sign in to comment.