aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrinzing <oliver.brinzing@gmx.de>2020-01-02 18:12:31 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-12-22 09:04:17 +0100
commit201ceeefb1f4cf4731589fc38debeaa9d8b1ad7f (patch)
tree32717a15f2595625d0f56dfaab884c2d9c1fc3b8
parent2eb77e11249867d1aa07ae51c0be6ce22df38653 (diff)
[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); Change-Id: I9783cd317a7202691913be186eca95964b1e0ff7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86141 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> (cherry picked from commit 697989d11e25b3eb83e5ca2dad5d71b178abfbc1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107756 Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r--offapi/com/sun/star/security/XDocumentDigitalSignatures.idl18
-rw-r--r--xmlsecurity/source/component/documentdigitalsignatures.cxx47
2 files changed, 63 insertions, 2 deletions
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;