From bc3162199d252eedaf5178731b378749cc1297d1 Mon Sep 17 00:00:00 2001 From: Joanna Adeele Siig Date: Fri, 26 May 2023 08:57:28 +0300 Subject: [PATCH] attempt at siva --- .gitignore | 11 +++++++++++ src/ASiC_S.cpp | 7 +++++++ src/Container.cpp | 19 +++++++++++++++++-- src/SiVaContainer.cpp | 10 +++++++++- src/digidoc-tool.cpp | 1 + 5 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..22fc56366 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +.vscode/ +macOS/ +openssl-3.0.8.tar.gz +openssl-3.0.8/ +xalan_c-1.12.tar.gz +xalan_c-1.12/ +xerces-c-3.2.4.tar.xz +xerces-c-3.2.4/ +xml-security-c-2.0.4.tar.gz +xml-security-c-2.0.4/ +.DS_Store diff --git a/src/ASiC_S.cpp b/src/ASiC_S.cpp index 0c4767816..dbd6dde52 100644 --- a/src/ASiC_S.cpp +++ b/src/ASiC_S.cpp @@ -198,8 +198,15 @@ bool ASiC_S::isContainerSimpleFormat(const string &path) if(readMimetype(iss) == MIMETYPE_ASIC_S) return true; } + if(isTimestampedASiC_S(list)) return true; + + // Just trying things out + // if(none_of(list.cbegin(), list.cend(), [](const string &file) { return file.find("p7s") != string::npos; })) { + // DEBUG("Check if ASiC/zip containter"); + // return false; + // } } catch(const Exception &) { diff --git a/src/Container.cpp b/src/Container.cpp index d8bca3069..70376ef8c 100644 --- a/src/Container.cpp +++ b/src/Container.cpp @@ -29,6 +29,8 @@ #include "crypto/X509CertStore.h" #include "util/File.h" #include "util/log.h" +#include + DIGIDOCPP_WARNING_PUSH DIGIDOCPP_WARNING_DISABLE_CLANG("-Wnull-conversion") @@ -349,12 +351,25 @@ Container* Container::open(const string &path) */ unique_ptr Container::openPtr(const string &path) { + // Hackilyy bypass method + return SiVaContainer::openInternal(path); + + // cout << "Container.cpp before for loop" << endl; for(auto open: m_openList) { - if(unique_ptr container = open(path)) + // cout << "Container.cpp inside for loop" << endl; + if(unique_ptr container = open(path)) { + // cout << "inside if statement" << endl; return container; + } + // cout << "Container.cpp after if statement" << endl; } - return ASiC_E::openInternal(path); + + // cout << "Container.cpp after for loop" << endl; + + + //return SiVaContainer::openInternal(path); + //return ASiC_E::openInternal(path); } /** diff --git a/src/SiVaContainer.cpp b/src/SiVaContainer.cpp index a28ff2201..a9fd2f028 100644 --- a/src/SiVaContainer.cpp +++ b/src/SiVaContainer.cpp @@ -46,6 +46,8 @@ #include #include +#include + using namespace digidoc; using namespace digidoc::util; @@ -314,13 +316,19 @@ vector SiVaContainer::dataFiles() const unique_ptr SiVaContainer::openInternal(const string &path) { - static const array supported {"pdf", "ddoc"}; + // Log that we have made it here along with param + cout << "SiVaContainer::openInternal(" << path << ") entered method" << endl; + + static const array supported {"pdf", "ddoc", "asics"}; string ext = File::fileExtension(path); + if(find(supported.cbegin(), supported.cend(), ext) == supported.cend()) return {}; try { + cout << "SiVaContainer::openInternal(" << path << ") try block in method" << endl; return unique_ptr(new SiVaContainer(path, ext, true)); } catch(const Exception &e) { + cout << "SiVaContainer::openInternal(" << path << ") catch block in method" << endl; if(e.msg().find("Bad digest for DataFile") == 0) return unique_ptr(new SiVaContainer(path, ext, false)); throw; diff --git a/src/digidoc-tool.cpp b/src/digidoc-tool.cpp index 68453c0f2..b23cb52be 100644 --- a/src/digidoc-tool.cpp +++ b/src/digidoc-tool.cpp @@ -580,6 +580,7 @@ static int open(int argc, char* argv[]) unique_ptr doc; try { + // cout << "digidoc-tool.cpp open method try before Container::openPtr(path)" << endl; doc = Container::openPtr(path); } catch(const Exception &e) { cout << "Failed to parse container" << endl;