diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-01-13 09:35:35 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-01-13 09:54:50 +0100 |
commit | 64b49f20af80150ec551d0c4d9638731e023217f (patch) | |
tree | 7a5ceb5207061aacf7c4ebd5d6e6461738e4778a /xmlsecurity/source/helper/xmlsignaturehelper.cxx | |
parent | e62ba5bb3f032e7064bf1f643bae449b0e612787 (diff) |
xmlsecurity: read OOXML signature relations
Change-Id: I9d2f6e6285e3db6c72d298a7d0b4ebb321936506
Diffstat (limited to 'xmlsecurity/source/helper/xmlsignaturehelper.cxx')
-rw-r--r-- | xmlsecurity/source/helper/xmlsignaturehelper.cxx | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx index e2d808c01b73..89d5d95215fd 100644 --- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx +++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx @@ -35,12 +35,17 @@ #include <com/sun/star/io/XActiveDataSource.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/StringPair.hpp> #include <com/sun/star/xml/sax/Parser.hpp> #include <com/sun/star/xml/sax/Writer.hpp> #include <com/sun/star/xml/crypto/SEInitializer.hpp> +#include <com/sun/star/embed/ElementModes.hpp> +#include <com/sun/star/embed/XStorage.hpp> #include <tools/date.hxx> #include <tools/time.hxx> +#include <comphelper/ofopxmlhelper.hxx> +#include <comphelper/sequence.hxx> #define TAG_DOCUMENTSIGNATURES "document-signatures" #define NS_DOCUMENTSIGNATURES "http://openoffice.org/2004/documentsignatures" @@ -301,11 +306,6 @@ bool XMLSignatureHelper::ReadAndVerifySignature( const com::sun::star::uno::Refe return !mbError; } -bool XMLSignatureHelper::ReadAndVerifySignatureStorage(const css::uno::Reference<css::embed::XStorage>& /*xStorage*/) -{ - return true; -} - SignatureInformation XMLSignatureHelper::GetSignatureInformation( sal_Int32 nSecurityId ) const { return mpXSecController->getSignatureInformation( nSecurityId ); @@ -344,4 +344,36 @@ IMPL_LINK_NOARG_TYPED( XMLSignatureHelper, StartVerifySignatureElement, LinkPara } } +namespace +{ +bool lcl_isSignatureType(const beans::StringPair& rPair) +{ + return rPair.First == "Type" && rPair.Second == "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature"; +} +} + +bool XMLSignatureHelper::ReadAndVerifySignatureStorage(const uno::Reference<embed::XStorage>& xStorage) +{ + sal_Int32 nOpenMode = embed::ElementModes::READ; + uno::Reference<embed::XStorage> xSubStorage = xStorage->openStorageElement("_rels", nOpenMode); + uno::Reference<io::XInputStream> xRelStream(xSubStorage->openStreamElement("origin.sigs.rels", nOpenMode), uno::UNO_QUERY); + uno::Sequence< uno::Sequence<beans::StringPair> > aRelationsInfo; + aRelationsInfo = comphelper::OFOPXMLHelper::ReadRelationsInfoSequence(xRelStream, "origin.sigs.rels", mxCtx); + + for (const uno::Sequence<beans::StringPair>& rRelation : aRelationsInfo) + { + auto aRelation = comphelper::sequenceToContainer< std::vector<beans::StringPair> >(rRelation); + if (std::find_if(aRelation.begin(), aRelation.end(), lcl_isSignatureType) != aRelation.end()) + { + std::vector<beans::StringPair>::iterator it = std::find_if(aRelation.begin(), aRelation.end(), [](const beans::StringPair& rPair) { return rPair.First == "Target"; }); + if (it != aRelation.end()) + { + // TODO now handle it->Second + } + } + } + + return true; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |