Skip to content

Commit

Permalink
Add option to save SiVa URL to xml config
Browse files Browse the repository at this point in the history
IB-6839

Signed-off-by: Raul Metsma <raul@metsma.ee>
  • Loading branch information
metsma committed Oct 6, 2022
1 parent 0c52180 commit 7f10746
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 4 deletions.
14 changes: 14 additions & 0 deletions libdigidocpp.dox
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,20 @@ If left unspecified then the logging output is written to standard output stream
\note For testing purposes, the SK's test time-stamping service can be used. The service is available at http://demo.sk.ee/tsa/ additional information can be found at https://www.id.ee/en/rubriik/timestamping-service/.


\subsubsection VerifyService-settings Signature Verify Service settings
<table>
<tr>
<th>Parameter name</th>
<th>Comments</th>
</tr>
<tr>
<td>verify.serivceUri</td>
<td>Specifies the URL of the signature-verify service that is used during signature validation. By default, the RIA's signature-verify service is used by the library (https://siva.eesti.ee/V3/validate)
</td>
</tr>
</table>


\subsubsection pkcs11-settings PKCS#11 settings
<table>
<tr>
Expand Down
13 changes: 11 additions & 2 deletions src/XmlConf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,10 +605,10 @@ SET1CONST(string, setPKCS12Pass, PKCS12Pass)

/**
* @fn void digidoc::XmlConf::setTSUrl(const std::string &url)
* Sets a PKCS#12 certificate password. Also adds or replaces PKCS#12 certificate password in the user configuration file.
* Sets a TSA service URL. Also adds or replaces TSA service URL in the user configuration file.
*
* @param url Target URL to connect TSA service.
* @throws Exception exception is thrown if saving a TS URL into a user configuration file fails.
* @throws Exception exception is thrown if saving a TS service URL into a user configuration file fails.
*/
/**
* @fn void digidoc::XmlConfV2::setTSUrl(const std::string &url)
Expand All @@ -624,6 +624,15 @@ SET1CONST(string, setPKCS12Pass, PKCS12Pass)
*/
SET1CONST(string, setTSUrl, TSUrl)

/**
* @fn void digidoc::XmlConf::setVerifyServiceUri(const std::string &url)
* Sets a Verify service URL. Also adds or replaces Verify service URL in the user configuration file.
*
* @param url Target URL to connect Verify service.
* @throws Exception exception is thrown if saving a Verify service URL into a user configuration file fails.
*/
SET1CONST(string, setVerifyServiceUri, verifyServiceUri)

/**
* @fn void digidoc::XmlConf::setPKCS12Disable(bool disable)
* Sets a PKCS#12 certificate usage. Also adds or replaces PKCS#12 certificate usage in the user configuration file.
Expand Down
4 changes: 4 additions & 0 deletions src/XmlConf.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class DIGIDOCPP_EXPORT XmlConf: public Conf
virtual void setTSLTimeOut( int timeOut );

virtual void setTSUrl(const std::string &url);
virtual void setVerifyServiceUri(const std::string &url);

private:
DISABLE_COPY(XmlConf);
Expand Down Expand Up @@ -130,6 +131,7 @@ class DIGIDOCPP_EXPORT XmlConfV2: public ConfV2
virtual void setTSLTimeOut( int timeOut );

virtual void setTSUrl(const std::string &url);
virtual void setVerifyServiceUri(const std::string &url);

private:
DISABLE_COPY(XmlConfV2);
Expand Down Expand Up @@ -185,6 +187,7 @@ class DIGIDOCPP_EXPORT XmlConfV3: public ConfV3
virtual void setTSLTimeOut( int timeOut );

virtual void setTSUrl(const std::string &url);
virtual void setVerifyServiceUri(const std::string &url);

private:
DISABLE_COPY(XmlConfV3);
Expand Down Expand Up @@ -241,6 +244,7 @@ class DIGIDOCPP_EXPORT XmlConfV4: public ConfV4
virtual void setTSLTimeOut( int timeOut );

virtual void setTSUrl(const std::string &url);
virtual void setVerifyServiceUri(const std::string &url);

private:
DISABLE_COPY(XmlConfV4);
Expand Down
1 change: 0 additions & 1 deletion src/libdigidocpp.i.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class SWIGEXPORT DigiDocConf: public digidoc::XmlConfCurrent
if(!cert.empty())
serviceCerts.emplace_back(cert, X509Cert::Der);
}
void setVerifyServiceUri(std::string url) { serviceUrl = std::move(url); }

private:
int _logLevel = 4;
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if( Boost_INCLUDE_DIR )
add_definitions(
-DDIGIDOCPPCONF="${CMAKE_SOURCE_DIR}/etc/schema"
-DPKCS11_MODULE="${PKCS11_MODULE}"
-DSIVA_URL="${SIVA_URL}"
)
add_executable(unittests libdigidocpp_boost.cpp)
add_executable(TSLTests TSLTests.cpp)
Expand Down
6 changes: 5 additions & 1 deletion test/libdigidocpp_boost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE(ConfSuite)
BOOST_AUTO_TEST_CASE(XmlConfCase) {
XmlConf c("digidocpp.conf", util::File::path(DIGIDOCPPCONF, "/conf.xsd"));
XmlConfCurrent c("digidocpp.conf", util::File::path(DIGIDOCPPCONF, "/conf.xsd"));
BOOST_CHECK_EQUAL(c.logLevel(), 2);
BOOST_CHECK_EQUAL(c.logFile(), "digidocpp.log");
BOOST_CHECK_EQUAL(c.digestUri(), URI_SHA256);
Expand All @@ -493,6 +493,10 @@ BOOST_AUTO_TEST_CASE(XmlConfCase) {
BOOST_CHECK_EQUAL(c.PKCS12Pass(), "pass");
BOOST_CHECK_EQUAL(c.PKCS12Disable(), true);
BOOST_CHECK_EQUAL(c.ocsp("ESTEID-SK 2007"), "http://ocsp.sk.ee");
BOOST_CHECK_EQUAL(c.verifyServiceUri(), SIVA_URL);
const string testurl = "https://test.url";
c.setVerifyServiceUri(testurl);
BOOST_CHECK_EQUAL(c.verifyServiceUri(), testurl);
}
BOOST_AUTO_TEST_SUITE_END()

Expand Down

0 comments on commit 7f10746

Please sign in to comment.