summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorNoel <noelgrandin@gmail.com>2020-12-08 11:57:57 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-12-08 11:57:24 +0100
commitd7ddc292b94583942d4990e132bd08bcaee9edf2 (patch)
tree400199249006b47af0a719eafc537a37141bafc4 /xmlsecurity
parente1e4edd4d1aabefb4ef31db3d1478f2165079800 (diff)
use proper struct for trusted authors
instead of passing around a Sequence<String>, there is no need to use UNO types here. Change-Id: I1b9a1b6919f830d8ce29139b4362b979a669d505 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107396 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/inc/macrosecurity.hxx2
-rw-r--r--xmlsecurity/source/component/documentdigitalsignatures.cxx22
-rw-r--r--xmlsecurity/source/dialogs/macrosecurity.cxx24
3 files changed, 22 insertions, 26 deletions
diff --git a/xmlsecurity/inc/macrosecurity.hxx b/xmlsecurity/inc/macrosecurity.hxx
index 74d35aeddee3..4461188cfc82 100644
--- a/xmlsecurity/inc/macrosecurity.hxx
+++ b/xmlsecurity/inc/macrosecurity.hxx
@@ -92,7 +92,7 @@ public:
class MacroSecurityTrustedSourcesTP : public MacroSecurityTP
{
private:
- css::uno::Sequence< SvtSecurityOptions::Certificate > m_aTrustedAuthors;
+ std::vector< SvtSecurityOptions::Certificate > m_aTrustedAuthors;
bool mbAuthorsReadonly;
bool mbURLsReadonly;
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx
index f69bbb4fece5..ac9f25ce41c9 100644
--- a/xmlsecurity/source/component/documentdigitalsignatures.cxx
+++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx
@@ -653,12 +653,12 @@ sal_Bool DocumentDigitalSignatures::isAuthorTrusted(
{
OUString sSerialNum = xmlsecurity::bigIntegerToNumericString( Author->getSerialNumber() );
- Sequence< SvtSecurityOptions::Certificate > aTrustedAuthors = SvtSecurityOptions().GetTrustedAuthors();
+ std::vector< SvtSecurityOptions::Certificate > aTrustedAuthors = SvtSecurityOptions().GetTrustedAuthors();
return std::any_of(aTrustedAuthors.begin(), aTrustedAuthors.end(),
[&Author, &sSerialNum](const SvtSecurityOptions::Certificate& rAuthor) {
- return ( rAuthor[0] == Author->getIssuerName() )
- && ( rAuthor[1] == sSerialNum );
+ return ( rAuthor.SubjectName == Author->getIssuerName() )
+ && ( rAuthor.SerialNumber == sSerialNum );
});
}
@@ -762,20 +762,16 @@ void DocumentDigitalSignatures::addAuthorToTrustedSources(
{
SvtSecurityOptions aSecOpts;
- SvtSecurityOptions::Certificate aNewCert( 3 );
- aNewCert[ 0 ] = Author->getIssuerName();
- aNewCert[ 1 ] = xmlsecurity::bigIntegerToNumericString( Author->getSerialNumber() );
+ SvtSecurityOptions::Certificate aNewCert;
+ aNewCert.SubjectName = Author->getIssuerName();
+ aNewCert.SerialNumber = xmlsecurity::bigIntegerToNumericString( Author->getSerialNumber() );
OUStringBuffer aStrBuffer;
::comphelper::Base64::encode(aStrBuffer, Author->getEncoded());
- aNewCert[ 2 ] = aStrBuffer.makeStringAndClear();
-
-
- Sequence< SvtSecurityOptions::Certificate > aTrustedAuthors = aSecOpts.GetTrustedAuthors();
- sal_Int32 nCnt = aTrustedAuthors.getLength();
- aTrustedAuthors.realloc( nCnt + 1 );
- aTrustedAuthors[ nCnt ] = aNewCert;
+ aNewCert.RawData = aStrBuffer.makeStringAndClear();
+ std::vector< SvtSecurityOptions::Certificate > aTrustedAuthors = aSecOpts.GetTrustedAuthors();
+ aTrustedAuthors.push_back( aNewCert );
aSecOpts.SetTrustedAuthors( aTrustedAuthors );
}
diff --git a/xmlsecurity/source/dialogs/macrosecurity.cxx b/xmlsecurity/source/dialogs/macrosecurity.cxx
index 540a62eda813..ac4d7bc5188b 100644
--- a/xmlsecurity/source/dialogs/macrosecurity.cxx
+++ b/xmlsecurity/source/dialogs/macrosecurity.cxx
@@ -216,23 +216,23 @@ IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, ViewCertPBHdl, weld::Button&, voi
uno::Reference< css::security::XCertificate > xCert;
try
{
- xCert = m_pDlg->m_xSecurityEnvironment->getCertificate(m_aTrustedAuthors[nSelected][0],
- xmlsecurity::numericStringToBigInteger(m_aTrustedAuthors[nSelected][1]));
+ xCert = m_pDlg->m_xSecurityEnvironment->getCertificate(m_aTrustedAuthors[nSelected].SubjectName,
+ xmlsecurity::numericStringToBigInteger(m_aTrustedAuthors[nSelected].SerialNumber));
}
catch (...)
{
- TOOLS_WARN_EXCEPTION("xmlsecurity.dialogs", "matching certificate not found for: " << m_aTrustedAuthors[nSelected][0]);
+ TOOLS_WARN_EXCEPTION("xmlsecurity.dialogs", "matching certificate not found for: " << m_aTrustedAuthors[nSelected].SubjectName);
}
if (!xCert.is())
{
try
{
- xCert = m_pDlg->m_xSecurityEnvironment->createCertificateFromAscii(m_aTrustedAuthors[nSelected][2]);
+ xCert = m_pDlg->m_xSecurityEnvironment->createCertificateFromAscii(m_aTrustedAuthors[nSelected].RawData);
}
catch (...)
{
- TOOLS_WARN_EXCEPTION("xmlsecurity.dialogs", "certificate data couldn't be parsed: " << m_aTrustedAuthors[nSelected][2]);
+ TOOLS_WARN_EXCEPTION("xmlsecurity.dialogs", "certificate data couldn't be parsed: " << m_aTrustedAuthors[nSelected].RawData);
}
}
@@ -243,7 +243,7 @@ IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, ViewCertPBHdl, weld::Button&, voi
}
else
// should never happen, as we parsed the certificate data when we added it!
- ShowBrokenCertificateError(m_aTrustedAuthors[nSelected][2]);
+ ShowBrokenCertificateError(m_aTrustedAuthors[nSelected].RawData);
}
IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, RemoveCertPBHdl, weld::Button&, void)
@@ -252,7 +252,7 @@ IMPL_LINK_NOARG(MacroSecurityTrustedSourcesTP, RemoveCertPBHdl, weld::Button&, v
if (nEntry != -1)
{
sal_uInt16 nAuthor = m_xTrustCertLB->get_id(nEntry).toUInt32();
- ::comphelper::removeElementAt( m_aTrustedAuthors, nAuthor );
+ m_aTrustedAuthors.erase(m_aTrustedAuthors.begin() + nAuthor);
FillCertLB();
ImplCheckButtons();
@@ -328,19 +328,19 @@ void MacroSecurityTrustedSourcesTP::FillCertLB(const bool bShowWarnings)
{
m_xTrustCertLB->clear();
- sal_uInt32 nEntries = m_aTrustedAuthors.getLength();
+ sal_uInt32 nEntries = m_aTrustedAuthors.size();
if ( !(nEntries && m_pDlg->m_xSecurityEnvironment.is()) )
return;
for( sal_uInt32 nEntry = 0 ; nEntry < nEntries ; ++nEntry )
{
- css::uno::Sequence< OUString >& rEntry = m_aTrustedAuthors[ nEntry ];
+ SvtSecurityOptions::Certificate& rEntry = m_aTrustedAuthors[ nEntry ];
try
{
// create from RawData
- uno::Reference< css::security::XCertificate > xCert = m_pDlg->m_xSecurityEnvironment->createCertificateFromAscii(rEntry[2]);
+ uno::Reference< css::security::XCertificate > xCert = m_pDlg->m_xSecurityEnvironment->createCertificateFromAscii(rEntry.RawData);
m_xTrustCertLB->append(OUString::number(nEntry), xmlsec::GetContentPart(xCert->getSubjectName(), xCert->getCertificateKind()));
m_xTrustCertLB->set_text(nEntry, xmlsec::GetContentPart(xCert->getIssuerName(), xCert->getCertificateKind()), 1);
m_xTrustCertLB->set_text(nEntry, utl::GetDateTimeString(xCert->getNotValidAfter()), 2);
@@ -349,8 +349,8 @@ void MacroSecurityTrustedSourcesTP::FillCertLB(const bool bShowWarnings)
{
if (bShowWarnings)
{
- TOOLS_WARN_EXCEPTION("xmlsecurity.dialogs", "certificate data couldn't be parsed: " << rEntry[2]);
- OUString sData = rEntry[2];
+ TOOLS_WARN_EXCEPTION("xmlsecurity.dialogs", "certificate data couldn't be parsed: " << rEntry.RawData);
+ OUString sData = rEntry.RawData;
css::uno::Any tools_warn_exception(DbgGetCaughtException());
OUString sException = OStringToOUString(exceptionToString(tools_warn_exception), RTL_TEXTENCODING_UTF8);
if (!sException.isEmpty())