Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hacky attempt at SiVa & CAdES #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions src/ASiC_S.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 &)
{
Expand Down
19 changes: 17 additions & 2 deletions src/Container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "crypto/X509CertStore.h"
#include "util/File.h"
#include "util/log.h"
#include <iostream>


DIGIDOCPP_WARNING_PUSH
DIGIDOCPP_WARNING_DISABLE_CLANG("-Wnull-conversion")
Expand Down Expand Up @@ -349,12 +351,25 @@ Container* Container::open(const string &path)
*/
unique_ptr<Container> 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> container = open(path))
// cout << "Container.cpp inside for loop" << endl;
if(unique_ptr<Container> 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);
}

/**
Expand Down
10 changes: 9 additions & 1 deletion src/SiVaContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@

#include <algorithm>
#include <fstream>
#include <iostream>


using namespace digidoc;
using namespace digidoc::util;
Expand Down Expand Up @@ -314,13 +316,19 @@ vector<DataFile *> SiVaContainer::dataFiles() const

unique_ptr<Container> 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<Container>(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<Container>(new SiVaContainer(path, ext, false));
throw;
Expand Down
1 change: 1 addition & 0 deletions src/digidoc-tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ static int open(int argc, char* argv[])

unique_ptr<Container> 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;
Expand Down