[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - offapi/com xmlsecurity/source

brinzing (via logerrit) logerrit at kemper.freedesktop.org
Mon Jun 29 07:12:22 UTC 2020


 offapi/com/sun/star/security/XDocumentDigitalSignatures.idl |   18 ++++
 xmlsecurity/source/component/documentdigitalsignatures.cxx  |   47 +++++++++++-
 2 files changed, 63 insertions(+), 2 deletions(-)

New commits:
commit 424deb432a3ff394bd8d9c1c52cefca9e4b31e3d
Author:     brinzing <oliver.brinzing at gmx.de>
AuthorDate: Thu Jan 2 18:12:31 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Jun 29 09:11:49 2020 +0200

    [API CHANGE] extend css.security.XDocumentDigitalSignatures
    
    Add support for macro and package signing with a provided certificate
    which is already possible for document signing since LO 6.2:
    
    boolean signScriptingContentWithCertificate(
              [in] ::com::sun::star::security::XCertificate xCertificate,
              [in] ::com::sun::star::embed::XStorage xStorage,
              [in] ::com::sun::star::io::XStream xStream);
    
    boolean signPackageWithCertificate(
              [in] ::com::sun::star::security::XCertificate xCertificate,
              [in] ::com::sun::star::embed::XStorage xStorage,
              [in] ::com::sun::star::io::XStream xStream);
    
    (cherry picked from commit 697989d11e25b3eb83e5ca2dad5d71b178abfbc1)
    
    Change-Id: I9783cd317a7202691913be186eca95964b1e0ff7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97257
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/offapi/com/sun/star/security/XDocumentDigitalSignatures.idl b/offapi/com/sun/star/security/XDocumentDigitalSignatures.idl
index dc6affc62a9b..541d1d822121 100644
--- a/offapi/com/sun/star/security/XDocumentDigitalSignatures.idl
+++ b/offapi/com/sun/star/security/XDocumentDigitalSignatures.idl
@@ -205,6 +205,24 @@ interface XDocumentDigitalSignatures : com::sun::star::uno::XInterface
         @since LibreOffice 6.3
     */
     void setParentWindow([in] ::com::sun::star::awt::XWindow xParentWindow);
+
+    /** signs the content of the Scripting including macros and basic dialogs with the provided certificate.
+
+        <p>The rest of document content will not be signed.</p>
+
+        @since LibreOffice 6.5
+    */
+    boolean signScriptingContentWithCertificate([in] ::com::sun::star::security::XCertificate xCertificate,
+                                                [in] ::com::sun::star::embed::XStorage xStorage,
+                                                [in] ::com::sun::star::io::XStream xStream);
+
+    /** signs the full Package, which means everything in the storage except the content of META-INF with the provided certificate.
+
+        @since LibreOffice 6.5
+    */
+    boolean signPackageWithCertificate([in] ::com::sun::star::security::XCertificate xCertificate,
+                                                [in] ::com::sun::star::embed::XStorage xStorage,
+                                                [in] ::com::sun::star::io::XStream xStream);
 };
 
 } ; } ; } ; } ;
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx
index dcfaad0af773..37ea37bf8992 100644
--- a/xmlsecurity/source/component/documentdigitalsignatures.cxx
+++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx
@@ -101,7 +101,12 @@ private:
     chooseCertificatesImpl(std::map<OUString, OUString>& rProperties, const UserAction eAction,
                            const CertificateKind certificateKind=CertificateKind_NONE);
 
-public:
+    bool signWithCertificateImpl(
+        css::uno::Reference<css::security::XCertificate> const& xCertificate,
+        css::uno::Reference<css::embed::XStorage> const& xStorage,
+        css::uno::Reference<css::io::XStream> const& xStream, DocumentSignatureMode eMode);
+
+ public:
     explicit DocumentDigitalSignatures(
         const css::uno::Reference<css::uno::XComponentContext>& rxCtx);
 
@@ -184,6 +189,16 @@ public:
                             css::uno::Reference<css::embed::XStorage> const & xStoragexStorage,
                             css::uno::Reference<css::io::XStream> const & xStream) override;
 
+    sal_Bool SAL_CALL signPackageWithCertificate(
+                            css::uno::Reference<css::security::XCertificate> const& xCertificate,
+                            css::uno::Reference<css::embed::XStorage> const& xStoragexStorage,
+                            css::uno::Reference<css::io::XStream> const& xStream) override;
+
+    sal_Bool SAL_CALL signScriptingContentWithCertificate(
+                            css::uno::Reference<css::security::XCertificate> const& xCertificate,
+                            css::uno::Reference<css::embed::XStorage> const& xStoragexStorage,
+                            css::uno::Reference<css::io::XStream> const& xStream) override;
+
     void SAL_CALL setParentWindow(const css::uno::Reference<css::awt::XWindow>& rParentwindow) override
     {
         mxParentWindow = rParentwindow;
@@ -764,7 +779,35 @@ sal_Bool DocumentDigitalSignatures::signDocumentWithCertificate(
             css::uno::Reference<css::embed::XStorage> const & xStorage,
             css::uno::Reference<css::io::XStream> const & xStream)
 {
-    DocumentSignatureManager aSignatureManager(mxCtx, DocumentSignatureMode::Content);
+    return signWithCertificateImpl(xCertificate, xStorage, xStream, DocumentSignatureMode::Content);
+}
+
+sal_Bool DocumentDigitalSignatures::signPackageWithCertificate(
+    css::uno::Reference<css::security::XCertificate> const& xCertificate,
+    css::uno::Reference<css::embed::XStorage> const& xStorage,
+    css::uno::Reference<css::io::XStream> const& xStream)
+{
+    return signWithCertificateImpl(xCertificate, xStorage, xStream, DocumentSignatureMode::Package);
+}
+
+sal_Bool DocumentDigitalSignatures::signScriptingContentWithCertificate(
+    css::uno::Reference<css::security::XCertificate> const& xCertificate,
+    css::uno::Reference<css::embed::XStorage> const& xStorage,
+    css::uno::Reference<css::io::XStream> const& xStream)
+{
+    return signWithCertificateImpl(xCertificate, xStorage, xStream, DocumentSignatureMode::Macros);
+}
+
+bool DocumentDigitalSignatures::signWithCertificateImpl(
+    css::uno::Reference<css::security::XCertificate> const& xCertificate,
+    css::uno::Reference<css::embed::XStorage> const& xStorage,
+    css::uno::Reference<css::io::XStream> const& xStream,
+    DocumentSignatureMode eMode)
+{
+    OSL_ENSURE(!m_sODFVersion.isEmpty(),
+               "DocumentDigitalSignatures: ODF Version not set, assuming minimum 1.2");
+
+    DocumentSignatureManager aSignatureManager(mxCtx, eMode);
 
     if (!aSignatureManager.init())
         return false;


More information about the Libreoffice-commits mailing list