libdigidocpp
digidoc-tool.cpp File Reference
#include "log.h"
#include "BDoc.h"
#include "Conf.h"
#include "Document.h"
#include "Signature.h"
#include "crypto/cert/X509Cert.h"
#include "crypto/signer/EstEIDConsolePinSigner.h"
#include "util/File.h"
Include dependency graph for digidoc-tool.cpp:

Go to the source code of this file.

Classes

class  DemoEstEIDConsolePinSigner

Macros

#define SUCCESS   0
#define FAILURE   1
#define PRINT_EXCEPTION

Functions

static std::string decodeParameter (const std::string &param)
void printUsage (const char *executable)
std::string parseException (const Exception &e)
int open (int argc, char *argv[])
int create (int argc, char *argv[])
int sign (int argc, char *argv[])
int main (int argc, char *argv[])

Variables

const char * CERT_STATUSES [3] = { "GOOD", "REVOKED", "UNKNOWN" }

Macro Definition Documentation

#define FAILURE   1

Definition at line 35 of file digidoc-tool.cpp.

Referenced by create(), main(), open(), and sign().

#define PRINT_EXCEPTION
Value:
catch(const BDocException& e) { printf("Caught BDocException: %s\n", parseException(e).c_str()); } \
catch(const IOException& e) { printf("Caught IOException: %s\n", parseException(e).c_str()); } \
catch(const SignException& e) { printf("Caught SignException: %s\n", parseException(e).c_str()); } \
catch(const SignatureException& e) { printf("Caught SignatureException: %s\n", parseException(e).c_str()); } \
catch(const Exception& e) { printf("Caught Exception: %s\n", parseException(e).c_str()); } \
catch(...) { printf("Caught unknown exception\n"); }

Definition at line 37 of file digidoc-tool.cpp.

Referenced by create(), open(), and sign().

#define SUCCESS   0

Definition at line 34 of file digidoc-tool.cpp.

Referenced by create(), main(), open(), and sign().

Function Documentation

int create ( int  argc,
char *  argv[] 
)

Create new BDOC container.

Parameters
argcnumber of command line arguments.
argvcommand line arguments.
Returns
FAILURE (1) - failure, SUCCESS (0) - success

Definition at line 298 of file digidoc-tool.cpp.

References digidoc::BDoc::addDocument(), digidoc::BDoc::BES, digidoc::SignerRole::claimedRoles, decodeParameter(), FAILURE, digidoc::Conf::getInstance(), digidoc::Conf::getPKCS11DriverPath(), i, PRINT_EXCEPTION, printUsage(), digidoc::BDoc::saveTo(), digidoc::Signer::setSignatureProductionPlace(), digidoc::Signer::setSignerRole(), digidoc::BDoc::sign(), SUCCESS, and digidoc::BDoc::TM.

Referenced by main(), and testCanon().

Here is the call graph for this function:

Here is the caller graph for this function:

static std::string decodeParameter ( const std::string &  param)
static

Definition at line 49 of file digidoc-tool.cpp.

References digidoc::util::File::decodeName(), and int().

Referenced by create(), open(), and sign().

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Executes digidoc demonstration application.

Parameters
argcnumber of command line arguments.
argvcommand line arguments.
Returns
FAILURE (1) - failure, SUCCESS (0) - success

Definition at line 578 of file digidoc-tool.cpp.

References create(), FAILURE, digidoc::initialize(), open(), printUsage(), sign(), SUCCESS, digidoc::terminate(), VER_STR, and digidoc::version().

Here is the call graph for this function:

int open ( int  argc,
char *  argv[] 
)

Open BDOC container Example command: demo open –validateOnline container-file.bdoc Args:

  • –extract - extracts documents (to path when provided)
  • –list - lists documents and signatures.
  • –validateOnline - Whether online validate all signatures
Parameters
argcnumber of command line arguments.
argvcommand line arguments.
Returns
FAILURE (1) - failure, SUCCESS (0) - success

Definition at line 152 of file digidoc-tool.cpp.

References CERT_STATUSES, digidoc::SignatureProductionPlace::city, digidoc::SignerRole::claimedRoles, digidoc::SignatureProductionPlace::countryName, decodeParameter(), digidoc::BDoc::documentCount(), e, FAILURE, digidoc::BDoc::getDocument(), digidoc::Document::getFileName(), digidoc::Signature::getMediaType(), digidoc::Document::getMediaType(), digidoc::Signature::getProductionPlace(), digidoc::BDoc::getSignature(), digidoc::Signature::getSignerRole(), digidoc::Signature::getSigningCertificate(), digidoc::Signature::getSigningTime(), digidoc::Document::getSize(), digidoc::X509Cert::getSubjectName(), i, digidoc::SignatureProductionPlace::isEmpty(), digidoc::SignerRole::isEmpty(), parseException(), digidoc::SignatureProductionPlace::postalCode, PRINT_EXCEPTION, printUsage(), digidoc::Document::saveAs(), digidoc::BDoc::signatureCount(), digidoc::SignatureProductionPlace::stateOrProvince, SUCCESS, digidoc::Signature::validateOffline(), and digidoc::Signature::validateOnline().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

std::string parseException ( const Exception e)

Definition at line 130 of file digidoc-tool.cpp.

References digidoc::Exception::getCauses(), digidoc::Exception::getMsg(), and i.

Referenced by open().

Here is the call graph for this function:

Here is the caller graph for this function:

void printUsage ( const char *  executable)

Prints demo application usage.

Definition at line 88 of file digidoc-tool.cpp.

References digidoc::Conf::getInstance().

Referenced by create(), main(), open(), and sign().

Here is the call graph for this function:

Here is the caller graph for this function:

int sign ( int  argc,
char *  argv[] 
)

Sign BDOC container.

Parameters
argcnumber of command line arguments.
argvcommand line arguments.
Returns
FAILURE (1) - failure, SUCCESS (0) - success

Definition at line 416 of file digidoc-tool.cpp.

References digidoc::BDoc::BES, digidoc::SignerRole::claimedRoles, decodeParameter(), FAILURE, digidoc::Conf::getInstance(), digidoc::Conf::getPKCS11DriverPath(), i, PRINT_EXCEPTION, printUsage(), digidoc::BDoc::saveTo(), digidoc::Signer::setSignatureProductionPlace(), digidoc::Signer::setSignerRole(), digidoc::BDoc::sign(), SUCCESS, and digidoc::BDoc::TM.

Referenced by main(), digidoc::RSASigner::sign(), and digidoc::BDoc::sign().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const char* CERT_STATUSES[3] = { "GOOD", "REVOKED", "UNKNOWN" }

Definition at line 47 of file digidoc-tool.cpp.

Referenced by open().