Commit Graph

184 Commits

Author SHA1 Message Date
Noel Grandin
0fe6f1a196 use actual UNO enums in vcl..xmlsecurity
Change-Id: Id862544f27ebcbe8363f93dc83192d0f0cddb5cc
Reviewed-on: https://gerrit.libreoffice.org/36041
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-04-03 11:05:13 +00:00
Andrea Gelmini
f727186145 Fix typos
Change-Id: I23b16792005d66588e3439eb6482adda96c45673
Reviewed-on: https://gerrit.libreoffice.org/35064
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2017-03-11 12:13:42 +00:00
Samuel Mehrbrodt
88ac77c0bc gpg4libre: List and view GPG keys
* Add GPG implementation of css::xml::crypto UNO interfaces (part of that is only stub atm)
* List gpg keys along with other certificates
* Viewing gpg certificates: Not all properties are implemented yet

Change-Id: I7f60b26efe949a94bf8fe1b8d4d428002c2995b1
Reviewed-on: https://gerrit.libreoffice.org/33843
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Siegmund Gorr <siegmund.gorr@cib.de>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2017-03-04 10:26:43 +00:00
Miklos Vajna
42460fd4eb xmlsecurity: avoid using the SerialNumberAdapter wrapper
This service is only used in xmlsecurity and it's a wrapper around two
free functions in the same module.

Change-Id: Ibc5a026b51eda6c2b4b27b7254dedc220dbf909a
Reviewed-on: https://gerrit.libreoffice.org/34772
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
2017-03-02 08:35:54 +00:00
Noel Grandin
1c3e84d819 teach lolugin:stringconstant about calling constructors
so we can remove unnecessary calls to the OUString(literal) constructor
when calling constructors like this:
   Foo(OUString("xxx"), 1)

Change-Id: I1de60ef561437c86b27dc9cb095a5deb2e103b36
Reviewed-on: https://gerrit.libreoffice.org/33698
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-01-31 08:56:20 +00:00
Noel Grandin
f1d83ac45f loplugin:stringconstant check for unnecessary OUString constructor..
..calls when creating exceptions

Change-Id: I3bc58a5aa4dc6f0508ecb88b3a843b96b8c7ebfe
Reviewed-on: https://gerrit.libreoffice.org/33617
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-01-28 09:22:55 +00:00
Noel Grandin
6b8ee3c9ba convert VclButtonsType to scoped enum
Change-Id: I9b91108c18e190060dc71546977aa8a3c11f06e1
Reviewed-on: https://gerrit.libreoffice.org/32285
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thomas Arnhold <thomas@arnhold.org>
2016-12-21 16:19:37 +00:00
Miklos Vajna
81f7824a98 xmlsecurity DigitalSignaturesDialog: show signature type on the UI
The code already knew if the signature was AdES-enabled or not, but that
info wasn't available on the UI.

The values are all names of standards, Andras says it's OK to have them
non-translatable.

Change-Id: I20baf0871fe2c84b04b7fc64014061e341744db8
Reviewed-on: https://gerrit.libreoffice.org/31718
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
2016-12-07 12:45:12 +00:00
Miklos Vajna
7226ee0586 xmlsecurity: don't write unchanged signatures back to the file
It's not useful, OTOH it can happen that something goes wrong and the
result does not match the original.

One situation when this can happen is when non-XAdES signatures are
read, but the checkbox to write XAdES signature is enabled.

Change-Id: Icafad914175b29f7c0245220258bd1420ccd7b9c
Reviewed-on: https://gerrit.libreoffice.org/31437
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
2016-11-30 17:47:31 +00:00
Miklos Vajna
ece5862b5d xmlsecurity: fix alignment for XAdES checkbox
And rename it to AdES, as the PDF PAdES generation will be affected by
this checkbox in the near future.

Change-Id: I06121e4eb9debac7a55a737a71780c2fa5c4d084
Reviewed-on: https://gerrit.libreoffice.org/30908
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-11-16 15:52:16 +00:00
Tor Lillqvist
59547a5495 More work in progress on XAdES compliant ODF signing
Pass an XAdES flag to a couple more functions and adapt to that.

Factor out writeDigestMethod() and writeSignedProperties() from
OOXMLSecExporter::Impl to DocumentSignatureHelper and use them in an
additional place.

Write xd:UnsignedProperties with EncapsulatedX509Certificate. Probably
much more work needed.

Change-Id: I2a0cd1db6dd487b9c7ba256ad29473de3d271cd8
2016-11-10 17:52:01 +02:00
Miklos Vajna
a69873d212 xmlsecurity: move the sec context from the format helpers to the sign manager
The signature manager always creates an XML helper, and optionally creates a
PDF helper as well. Both of them initialize xmlsec, and when the signature
manager is deleted, there are two de-inits, leading to an assertion failure in
xmlsec.

Fix the problem by moving the duplicated xmlsec init to the signature manager.
This has the additional benefit that general security-related code no longer
has to talk to the XML helper, it can use the signature manager, which feels
more natural. (What viewing a certificate had to do with XML?)

Change-Id: If6a6bc433636445f3782849a367d4a7ac0be7688
Reviewed-on: https://gerrit.libreoffice.org/30695
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
2016-11-08 14:50:56 +00:00
Tor Lillqvist
b2318479c8 Work in progress on supporting XAdES-compliant signatures for ODF
xmlsecurity is such a mess. Too many different classes that actually
have more or less identical life-time, with names that smell of
delusions of grandeur. "Manager", "security framework controller" etc
for stuff that actually exist only during the execution of a simple
dialog. And then a "helper" class that actually in on a higher level
than a "framework controller". But oh well.

Change-Id: I86e461b1bc91a0d8f5b7fb9f13a5be201729df1e
2016-11-08 14:31:46 +02:00
Tor Lillqvist
7ec0eed345 Fix inconsistent indentation
Change-Id: I4b87541c6e64e6b2b7c912f47a80a4aa37842014
2016-11-01 17:17:35 +02:00
Tor Lillqvist
0bbc15aa24 Use enum class for two local enums
Change-Id: I0d7e6a14ec890b8a1dbdea3685b543b63426c628
2016-11-01 16:38:32 +02:00
Miklos Vajna
7f671122df xmlsecurity: show PDF signature right after adding it
Also:

- handle PDF in DocumentSignatureManager::write(), so the PDF file is
  not truncated when closing the document signatures dialog, and
- handle PDF in DigitalSignaturesDialog::canAddRemove()

Change-Id: I77c1fcdcbdcb079ce934f37546129d9d280e5d2e
2016-10-20 17:08:00 +02:00
Miklos Vajna
28fcdc4fec xmlsecurity: avoid checking storage streams of PDF files
DocumentSignatureHelper::isOOo3_2_Signature() checks if the manifest
stream of the ZIP package is signed. A PDF file has no storage, so don't
do that check for that format.

With this, a valid PDF signature is shown as valid in the Digital
Signatures dialog as well.

Change-Id: I58c1cbd665b7c5894d1cfa193061a9370f76c8c4
2016-10-14 18:09:49 +02:00
Miklos Vajna
3b6f7f3810 xmlsecuity: show PDF signature in the doc signatures dialog
It doesn't actually show any details yet, but it shows a selectable
empty line, to be filled in with details.

Change-Id: Ib35f13e5c779fe1a28933c1a0761682e9f5de62d
Reviewed-on: https://gerrit.libreoffice.org/29775
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2016-10-13 18:18:16 +00:00
Noel Grandin
954f752cf1 convert MapUnit to scoped enum
I left a prefix on the names "Map" so that I would not have to re-arrange
each name too much, since I can't start identifiers with digits like "100thMM"

And remove RSC_EXTRAMAPUNIT, which doesn't seem to be doing anything anymore.

Change-Id: I5187824aa87e30caf5357b51b5384b5ab919d224
Reviewed-on: https://gerrit.libreoffice.org/29096
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-10-05 06:51:20 +00:00
Stephan Bergmann
106ea87205 Remove _TYPED suffix from tools/link.hxx macros
...which was introduced with 3ead3ad52f "Gradually
typed Link" to distinguish the new, typed versions from the old, untyped ones,
but is no longer necessary since 382eb1a23c
"remove untyped Link<>" removed the old versions.

Change-Id: I494025df486a16a45861fcd8192dfe0275b1103c
2016-10-05 07:56:12 +02:00
Caolán McNamara
a860df25dd masses of MessBoxes not being disposed promptly
since...

commit ba81e5c6bd
Date:   Thu May 28 21:35:43 2015 +0100

    tdf#91702 - fix stack-based MessBox allocation.

There is no special ScopedVclPtr<X>::Create or
ScopedVclPtrInstance<X>::Create just
VclPtr<X>::Create and a raw VclPtr<X>::Create()->foo
doesn't call dispose on the owned X

Change-Id: Ifacc8d5e742820701307c3c37b9b86487667d84f
2016-07-26 11:26:52 +01:00
Noel Grandin
9f4e283fc8 loplugin:sallogareas
Change-Id: I6ce045db236b81aa8bc7bce2a0e20c4132c5931f
2016-06-13 10:25:40 +02:00
Noel Grandin
c2d195447f Convert DBG_ASSERT in xmlsecurity
Change-Id: Ideec43617ff214b7e0dcbb0a1969955b34ee19e4
Reviewed-on: https://gerrit.libreoffice.org/26196
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-06-13 06:53:42 +00:00
Noel Grandin
ab10f9fc11 convert DBG_ASSERT(false, to SAL_WARN(
Change-Id: I400d728c5d99228c5ca52e369037395b4da2af5c
Reviewed-on: https://gerrit.libreoffice.org/26187
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-06-12 09:04:15 +00:00
Noel Grandin
9f138ffe9d remove unused constants in HRC files
Change-Id: Ia034fb16ce75caeb69fd746d4a602cd5fcfef6d1
Reviewed-on: https://gerrit.libreoffice.org/25817
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-06-06 07:01:43 +00:00
Noel Grandin
b860b73f2b Convert VCL_MESSAGE to scoped enum
Change-Id: I976536849fa5585c96cee23b660c56d3d0116933
Reviewed-on: https://gerrit.libreoffice.org/25720
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-06-01 06:46:29 +00:00
Tor Lillqvist
e0849330bc Get rid of unnecessary directory levels $D/inc/$D
Change-Id: Ibf313b8948a493043006ebf3a8281487c1f67b48
Reviewed-on: https://gerrit.libreoffice.org/25532
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2016-05-27 17:10:45 +00:00
Caolán McNamara
07f1a39509 (nearly) nothing uses GetUniqueId anymore, so remove it.
The odd one out is the usage in Formula, which attempts
to restore focus to a particular window identified by
an unique id. In this case restore focus by keeping a VclPtr
to the desired window.

Change-Id: I1dc335325c109d75745c6bba2e12662e6ae50638
2016-05-25 14:24:20 +01:00
Noel Grandin
43d57d105d com::sun::star->css in xmlsecurity/
Change-Id: I4b89f97671ab526e5731d2f1f99802e23f3fd4b5
2016-03-14 13:28:04 +02:00
Miklos Vajna
170e0e0280 xmlsecurity: extract final signature export logic from DigitalSignaturesDialog
To be able to unit-test this later without creating a vcl dialog.

Change-Id: I4794e212ffefc2efa3bddaf58e6c6bf2a4ea8d9a
2016-03-07 15:00:14 +01:00
Miklos Vajna
4351ff1f12 xmlsecurity: extract signature removal logic from DigitalSignaturesDialog
So that it'll be possible to call that code without an active dialog,
from a headless unit test.

Change-Id: I1728a666ff5d84b337efd7e2b7eb68469896257a
2016-03-04 16:01:34 +01:00
Miklos Vajna
e89610dad6 xmlsecurity OOXML export: only cache existing signatures, not our temp. one
When adding a signature, first we export it to a temp. storage, then
read it back, show the verification to the user, and then later we do or
do not write the temp. storage back to the original one.

This means the signature gets exported two times, and MSO only considers
the final result valid. So when caching signatures (to avoid a real
export based on our data model), don't cache the one we just added to
the temp. storage, but do a real export second time as well.

With this, MSO considers our appended signature (next to an existing
one) valid, too.

Change-Id: I4d615298463e037ea4e654ff5c3addcef8b0a094
2016-03-04 11:48:48 +01:00
Miklos Vajna
565346a4fe xmlsecurity: factor out DocumentSignatureManager from DigitalSignaturesDialog
It's hard to unit test signing when the logic is implemented in the Add
and OK button handlers.

Change-Id: I5e07df69cd808cf170e21dfd55f2f44bc79c58a8
2016-02-15 17:24:47 +01:00
Miklos Vajna
6e8be4c99e xmlsecurity OOXML export: register signature content types
Our own importer is happy about the export result already, but MSO is
more picky, and mandates the correct content types for both
_xmlsignatures/origin.sigs and the individual signature streams.

With this, MSO can open the signed file again (while previously it just
declared the file corrupted), though it still declares the signature
invalid.

Change-Id: I199ad96bb91e7ce03fdf1f10f9500db4e05bb5c1
2016-02-11 13:33:59 +01:00
Miklos Vajna
5cd3c87d5d xmlsecurity OOXML export: write signature streams to persistent storage
Change-Id: Ia24a1b64d4adfc0db537704779ca25cfd86cac8f
2016-02-11 11:00:44 +01:00
Miklos Vajna
6778514883 xmlsecurity: export OOXML signature relations to persistent storage
With this, _xmlsignatures/_rels/origin.sigs.rels and
_xmlsignatures/origin.sigs is written to the destination file.

Change-Id: I8d63a182e7cf05ed20195f88c90fba2a9a05379e
2016-02-11 11:00:44 +01:00
Miklos Vajna
f4b2e23625 xmlsecurity: fix reading OOXML signature from temp storage
When reading a signature, we just take the ODF signature stream or OOXML
signature storage.

When writing, we write to an ODF temporary stream / OOXML temporary
storage, read it back, and only the signatures dialog close handler
writes the signature back to the original file.

The underlying OOXML temporary storage's stream is the signature stream,
so only try to load signatures from the stream if it's not OOXML,
throwing a ZIP file at an XML parser is not a great idea.

Change-Id: I6e42d117b9c97676aaeaad158e78e39a2c39a5e8
2016-02-10 17:53:06 +01:00
Miklos Vajna
ff1982dc3f xmlsecurity OOXML export: use RelationshipTransform for relations
Change-Id: I5fd400f095998184107c10afa95fe8b12c123d33
2016-02-10 13:45:45 +01:00
Miklos Vajna
6dc0a4431f xmlsecurity OOXML export: fix prefix and suffix of stream references
In ODF, they're relative to the package root, in OOXML they always start
with a leading slash.

Also, in OOXML the stream URI should have its content type as the
suffix.

Change-Id: Iac570ed15533a23c8a6098f99b716f90e1bac0e0
2016-02-09 17:13:44 +01:00
Miklos Vajna
5138223ebf xmlsecurity: log temporary OOXML storage location during export
This can be inspected after the add button handler finishes, but the
dialog is still alive.

Change-Id: I18ece31545de6d306a26b44d372f54df8221a456
2016-02-08 15:34:35 +01:00
Miklos Vajna
b79ab28356 xmlsecurity: write initial OOXML signature streams
It's just the root element so far.

Change-Id: If32e9e5bf339f639a20fa88d85e826e14f65dac2
2016-02-05 16:25:13 +01:00
Miklos Vajna
f26019532b xmlsecurity: write OOXML signature relations on export
_rels/origin.sigs.rels of the _xmlsignatures temporary storage now
contains references to the individual signature streams.

Change-Id: I619bd81989e3b62fc4282e0e72fbfa780d1fb8bd
2016-02-05 16:25:13 +01:00
Miklos Vajna
976ec559d9 xmlsecurity: write origin.sigs when exporting OOXML signature
It's an empty file, with the only purpose to have relations, referencing
the individual signature streams. The only tricky part is that a temp
file needs closeOutput() to flush its contents, flush() is not enough.

Change-Id: I92ac61bce201c97a727ff02b1bb74599573a1807
2016-02-05 15:03:14 +01:00
Miklos Vajna
79d565408e xmlsecurity: ensure OOXML signatures relation when adding a signature
A 'signatures relation' is kind of a pointer that says where is the list
of signatures. When adding the first signature, this has to be created,
in addition to the actual signature relation.

This is yet another difference to ODF signing, where the signature is
just another additional stream in the package, while OOXML signing first
modifies the package to add the signatures relation, and then signs the
streams, so the input storage of the OOXML signing can't be a read-only
storage.

Change-Id: I81a976c945b28ddf7f347c4a7bfd51f98a1fc225
2016-02-05 11:02:32 +01:00
Miklos Vajna
8865a3b092 sfx2: avoid writing META-INF/ when signing OOXML files
Instead just pass an empty stream, xmlsecurity knows how to look up its
signature storage from the root one.

With this, opening the digital signatures dialog, clicking on add, and
then OK in both dialogs no longer results in an (empty) META-INF storage
written to an OOXML file.

Change-Id: I7e4a93687465ec19be307917ec00cde08ed8092f
2016-02-04 18:30:44 +01:00
Miklos Vajna
8f2f125802 xmlsecurity: don't write the stream of an OOXML storage
We'll need individual streams instead for OOXML.

Change-Id: Ia3a7172af39ebfb815d44b645b217da15e41c197
2016-02-04 17:18:10 +01:00
Miklos Vajna
f065747552 xmlsecurity: support tmp storage instead of tmp stream for OOXML
First step towards having a working export, since OOXML uses one stream
/ signature, so we need a storage for all signatures, not just a stream.

Change-Id: Id5edfd3ce7e8e4177b0071badc6eb4330a525281
2016-02-04 17:18:10 +01:00
Miklos Vajna
c0870b2a15 xmlsecurity: fix crash on closing DigitalSignaturesDialog without ...
... a signature stream. ODF has a signature stream, OOXML has a
signature storage instead.

Code tries to export all signatures on closing the dialog, but OOXML at
the moment has only an importer; so just fail gracefully in case we only
have a storage, not a stream.

With this, closing the dialog no longer results in a crash for OOXML
documents.

Change-Id: I3e6580ddb20ec31fb0c5a4abe1fab3d8046d0ee5
2016-02-04 10:02:36 +01:00
Miklos Vajna
8b8b5e21b0 xmlsecurity: handle OOXML signatures in ImplGetSignatureInformations()
With this, DigitalSignaturesDialog correctly shows the "Signed by" field
when reading a single valid OOXML signature.

Change-Id: Ic52a56767f65ab30924b07073d31677cb3a27de5
2016-01-19 17:32:34 +01:00
Miklos Vajna
fd3bd60449 xmlsecurity: gracefully handle lack of META-INF storage stream
Change-Id: Ic0b33f7b014ea7cfb16cc1babb69f2d2b6ba8dee
2016-01-12 12:36:21 +01:00