Skip to content

Commit

Permalink
SiVa warning improvements (#208)
Browse files Browse the repository at this point in the history
* MOPPAND-822
  • Loading branch information
martenrebane authored Nov 25, 2021
1 parent d9d0300 commit f3c3302
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ abstract class DocumentViewIntent implements Intent, Action {
abstract boolean confirmation();

static DocumentViewIntent confirmation(File containerFile, DataFile document) {
if (SignedContainer.isContainer(containerFile)) {
String containerFileExtension = getFileExtension(containerFile.getName()).toLowerCase(Locale.US);
String documentFileExtension = getFileExtension(document.name()).toLowerCase(Locale.US);
if (!containerFileExtension.equals("pdf") && !documentFileExtension.equals("pdf") && SignedContainer.isContainer(containerFile)) {
boolean isConfirmationNeeded;
try {
SignedContainer signedContainer = SignedContainer.open(containerFile);
Expand All @@ -106,6 +108,8 @@ static DocumentViewIntent confirmation(File containerFile, DataFile document) {
Timber.log(Log.ERROR, e, "Unable to get data file from container");
return create(containerFile, document, false);
}
} else if (containerFileExtension.equals("pdf") && documentFileExtension.equals("pdf")) {
return create(containerFile, document, false);
} else {
boolean isConfirmationNeeded = SivaUtil.isSivaConfirmationNeeded(containerFile, document);
return create(containerFile, document, isConfirmationNeeded);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ee.ria.DigiDoc.android.signature.update;

import static android.app.Activity.RESULT_OK;
import static com.google.common.io.Files.getFileExtension;
import static ee.ria.DigiDoc.android.Constants.SAVE_FILE;
import static ee.ria.DigiDoc.android.utils.IntentUtils.createSaveIntent;
import static ee.ria.DigiDoc.android.utils.IntentUtils.createSendIntent;
Expand All @@ -19,6 +20,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Locale;
import java.util.concurrent.TimeUnit;

import javax.inject.Inject;
Expand Down Expand Up @@ -206,9 +208,10 @@ final class Processor implements ObservableTransformer<Action, Result> {
.observeOn(AndroidSchedulers.mainThread())
.map(documentFile -> {
Transaction transaction;
String documentFileExtension = getFileExtension(documentFile.getName()).toLowerCase(Locale.US);
boolean isSignedPdfDataFile =
SivaUtil.isSivaConfirmationNeeded(ImmutableList.of(FileStream.create(documentFile)));
if (isSignedPdfDataFile && SignedContainer.isContainer(documentFile)) {
(SivaUtil.isSivaConfirmationNeeded(ImmutableList.of(FileStream.create(documentFile))) && documentFileExtension.equals("pdf"));
if (!isSignedPdfDataFile && SignedContainer.isContainer(documentFile)) {
transaction = Transaction.push(SignatureUpdateScreen
.create(true, true, documentFile, false, false));
} else if (CryptoContainer.isContainerFileName(documentFile.getName())) {
Expand Down

0 comments on commit f3c3302

Please sign in to comment.