[Libreoffice-commits] core.git: include/sfx2 sfx2/source xmlsecurity/qa
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Nov 14 07:20:13 UTC 2018
include/sfx2/objsh.hxx | 10 +++----
sfx2/source/doc/objmisc.cxx | 2 -
sfx2/source/doc/objserv.cxx | 4 +--
xmlsecurity/qa/unit/signing/data/signatureline.odt |binary
xmlsecurity/qa/unit/signing/signing.cxx | 28 ++++++++++++++++++---
5 files changed, 31 insertions(+), 13 deletions(-)
New commits:
commit d7f638f38fee26458e5e233c647248307f4e0f70
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Tue Nov 13 16:02:13 2018 +0100
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Wed Nov 14 08:19:45 2018 +0100
Add unit test for reading ODF signed signatureline
Change-Id: I4423a32fe84c6f13457e92aa0de913ee22995119
Reviewed-on: https://gerrit.libreoffice.org/63333
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index a7f65b619e60..ced0db56320d 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -362,6 +362,10 @@ public:
bool HasValidSignatures();
SignatureState GetDocumentSignatureState();
void SignDocumentContent(weld::Window* pDialogParent);
+ css::uno::Sequence<css::security::DocumentSignatureInformation> GetDocumentSignatureInformation(
+ bool bScriptingContent,
+ const css::uno::Reference<css::security::XDocumentDigitalSignatures>& xSigner
+ = css::uno::Reference<css::security::XDocumentDigitalSignatures>());
bool SignDocumentContentUsingCertificate(const css::uno::Reference<css::security::XCertificate>& xCertificate);
@@ -745,12 +749,6 @@ public:
// configuration items
SAL_DLLPRIVATE SignatureState ImplGetSignatureState( bool bScriptingContent = false );
- SAL_DLLPRIVATE css::uno::Sequence< css::security::DocumentSignatureInformation >
- ImplAnalyzeSignature(
- bool bScriptingContent,
- const css::uno::Reference< css::security::XDocumentDigitalSignatures >& xSigner
- = css::uno::Reference< css::security::XDocumentDigitalSignatures >() );
-
SAL_DLLPRIVATE bool QuerySaveSizeExceededModules_Impl( const css::uno::Reference< css::task::XInteractionHandler >& xHandler );
SAL_DLLPRIVATE bool QueryAllowExoticFormat_Impl( const css::uno::Reference< css::task::XInteractionHandler >& xHandler,
const OUString& rURL,
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 4bcfd9118e59..e245800f2fec 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -1758,7 +1758,7 @@ bool SfxObjectShell_Impl::hasTrustedScriptingSignature( bool bAllowUIToAddAuthor
|| nScriptingSignatureState == SignatureState::OK
|| nScriptingSignatureState == SignatureState::NOTVALIDATED )
{
- uno::Sequence< security::DocumentSignatureInformation > aInfo = rDocShell.ImplAnalyzeSignature( true, xSigner );
+ uno::Sequence< security::DocumentSignatureInformation > aInfo = rDocShell.GetDocumentSignatureInformation( true, xSigner );
if ( aInfo.getLength() )
{
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 487afb1825d6..6777e64d9cf5 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -1328,7 +1328,7 @@ static bool HasSignatureStream(const uno::Reference<embed::XStorage>& xStorage)
return xNameAccess->hasByName("_xmlsignatures");
}
-uno::Sequence< security::DocumentSignatureInformation > SfxObjectShell::ImplAnalyzeSignature( bool bScriptingContent, const uno::Reference< security::XDocumentDigitalSignatures >& xSigner )
+uno::Sequence< security::DocumentSignatureInformation > SfxObjectShell::GetDocumentSignatureInformation( bool bScriptingContent, const uno::Reference< security::XDocumentDigitalSignatures >& xSigner )
{
uno::Sequence< security::DocumentSignatureInformation > aResult;
uno::Reference< security::XDocumentDigitalSignatures > xLocSigner = xSigner;
@@ -1394,7 +1394,7 @@ SignatureState SfxObjectShell::ImplGetSignatureState( bool bScriptingContent )
{
*pState = SignatureState::NOSIGNATURES;
- uno::Sequence< security::DocumentSignatureInformation > aInfos = ImplAnalyzeSignature( bScriptingContent );
+ uno::Sequence< security::DocumentSignatureInformation > aInfos = GetDocumentSignatureInformation( bScriptingContent );
*pState = ImplCheckSignaturesInformation( aInfos );
}
diff --git a/xmlsecurity/qa/unit/signing/data/signatureline.odt b/xmlsecurity/qa/unit/signing/data/signatureline.odt
new file mode 100644
index 000000000000..d3a3e4671e5f
Binary files /dev/null and b/xmlsecurity/qa/unit/signing/data/signatureline.odt differ
diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx
index ef5bbbda05ff..15553c922934 100644
--- a/xmlsecurity/qa/unit/signing/signing.cxx
+++ b/xmlsecurity/qa/unit/signing/signing.cxx
@@ -105,8 +105,9 @@ public:
void testXAdES();
/// Works with an existing good XAdES signature.
void testXAdESGood();
- /// Test importing of signature line images
- void testSignatureLineImages();
+ /// Test importing of signature line
+ void testSignatureLineOOXML();
+ void testSignatureLineODF();
#if HAVE_FEATURE_GPGVERIFY
/// Test a typical ODF where all streams are GPG-signed.
void testODFGoodGPG();
@@ -145,7 +146,8 @@ public:
CPPUNIT_TEST(test96097Doc);
CPPUNIT_TEST(testXAdES);
CPPUNIT_TEST(testXAdESGood);
- CPPUNIT_TEST(testSignatureLineImages);
+ CPPUNIT_TEST(testSignatureLineOOXML);
+ CPPUNIT_TEST(testSignatureLineODF);
#if HAVE_FEATURE_GPGVERIFY
CPPUNIT_TEST(testODFGoodGPG);
CPPUNIT_TEST(testODFUntrustedGoodGPG);
@@ -850,7 +852,7 @@ void SigningTest::testXAdESGood()
(nActual == SignatureState::NOTVALIDATED || nActual == SignatureState::OK));
}
-void SigningTest::testSignatureLineImages()
+void SigningTest::testSignatureLineOOXML()
{
// Given: A document (docx) with a signature line and a valid signature
uno::Reference<security::XDocumentDigitalSignatures> xSignatures(
@@ -876,6 +878,24 @@ void SigningTest::testSignatureLineImages()
CPPUNIT_ASSERT(xSignatureInfo[0].InvalidSignatureLineImage.is());
}
+void SigningTest::testSignatureLineODF()
+{
+ createDoc(m_directories.getURLFromSrc(DATA_DIRECTORY) + "signatureline.odt");
+ SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
+ CPPUNIT_ASSERT(pBaseModel);
+ SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell();
+ CPPUNIT_ASSERT(pObjectShell);
+
+ uno::Sequence<security::DocumentSignatureInformation> xSignatureInfo
+ = pObjectShell->GetDocumentSignatureInformation(false);
+
+ CPPUNIT_ASSERT(xSignatureInfo[0].SignatureIsValid);
+ CPPUNIT_ASSERT_EQUAL(OUString("{41CF56EE-331B-4125-97D8-2F5669DD3AAC}"),
+ xSignatureInfo[0].SignatureLineId);
+ CPPUNIT_ASSERT(xSignatureInfo[0].ValidSignatureLineImage.is());
+ CPPUNIT_ASSERT(xSignatureInfo[0].InvalidSignatureLineImage.is());
+}
+
#if HAVE_FEATURE_GPGVERIFY
void SigningTest::testODFGoodGPG()
{
More information about the Libreoffice-commits
mailing list