Skip to content
Merged
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
45 changes: 37 additions & 8 deletions src/Conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Conf::Conf() = default;
Conf::~Conf() = default;

/**
* Return global instance object
* Return global config instance object
*/
Conf* Conf::instance() { return INSTANCE; }

Expand Down Expand Up @@ -248,7 +248,7 @@ ConfV2::ConfV2() = default;
ConfV2::~ConfV2() = default;

/**
* Return global instance object
* @copydoc digidoc::Conf::instance()
*/
ConfV2* ConfV2::instance() { return dynamic_cast<ConfV2*>(Conf::instance()); }

Expand Down Expand Up @@ -277,7 +277,7 @@ ConfV3::ConfV3() = default;
ConfV3::~ConfV3() = default;

/**
* Return global instance object
* @copydoc digidoc::Conf::instance()
*/
ConfV3* ConfV3::instance() { return dynamic_cast<ConfV3*>(Conf::instance()); }

Expand Down Expand Up @@ -308,7 +308,7 @@ ConfV4::ConfV4() = default;
ConfV4::~ConfV4() = default;

/**
* Return global instance object
* @copydoc digidoc::Conf::instance()
*/
ConfV4* ConfV4::instance() { return dynamic_cast<ConfV4*>(Conf::instance()); }

Expand All @@ -317,8 +317,37 @@ ConfV4* ConfV4::instance() { return dynamic_cast<ConfV4*>(Conf::instance()); }
*/
vector<X509Cert> ConfV4::verifyServiceCerts() const
{
X509Cert cert = verifyServiceCert();
if(!cert)
return {};
return { cert };
if(X509Cert cert = verifyServiceCert())
return { cert };
return {};
}

/**
* @class digidoc::ConfV5
* @brief Verison 5 of configuration class to add additonial parameters.
*
* Conf contains virtual members and is not leaf class we need create
* subclasses to keep binary compatibility
* https://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C++#Adding_new_virtual_functions_to_leaf_classes
* @see digidoc::ConfV4
* @see @ref parameters
*/
/**
* Version 4 config with new parameters
*/
ConfV5::ConfV5() = default;

ConfV5::~ConfV5() = default;

/**
* @copydoc digidoc::Conf::instance()
*/
ConfV5* ConfV5::instance() { return dynamic_cast<ConfV5*>(Conf::instance()); }

/**
* Gets verify service Certs
*/
vector<X509Cert> ConfV5::TSCerts() const
{
return {};
}
15 changes: 14 additions & 1 deletion src/Conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ class DIGIDOCPP_EXPORT ConfV4: public ConfV3
DISABLE_COPY(ConfV4);
};

using ConfCurrent = ConfV4;
class DIGIDOCPP_EXPORT ConfV5: public ConfV4
{
public:
ConfV5();
~ConfV5() override;
static ConfV5* instance();

virtual std::vector<X509Cert> TSCerts() const;

private:
DISABLE_COPY(ConfV5);
};

using ConfCurrent = ConfV5;
#define CONF(method) (ConfCurrent::instance() ? ConfCurrent::instance()->method() : ConfCurrent().method())
}
4 changes: 2 additions & 2 deletions src/Exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@
#define DISABLE_COPY(Class) \
Class(const Class &) = delete; \
Class &operator=(const Class &) = delete; \
Class(Class &&) = delete; \
Class &operator=(Class &&) = delete
Class(Class &&) DIGIDOCPP_NOEXCEPT = delete; \
Class &operator=(Class &&) DIGIDOCPP_NOEXCEPT = delete
Loading