diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-01-12 12:09:35 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-01-12 12:36:21 +0100 |
commit | 6861a8eefdbbfbc89a87011a7028ddbc7a393925 (patch) | |
tree | 7a663fb659c16035b5526b5b2bb8539bdebb2326 /xmlsecurity/source | |
parent | 1d436cdb3e8670fd8867774be1ed99ce370965b4 (diff) |
xmlsecurity: handle no META-INF in DocumentSignatureHelper
Change-Id: I7e0ac2d43e97fe9cb67a58c8dd8d83c1068f501d
Diffstat (limited to 'xmlsecurity/source')
-rw-r--r-- | xmlsecurity/source/helper/documentsignaturehelper.cxx | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/xmlsecurity/source/helper/documentsignaturehelper.cxx b/xmlsecurity/source/helper/documentsignaturehelper.cxx index 08a4f0b48e8b..fd916c651a4e 100644 --- a/xmlsecurity/source/helper/documentsignaturehelper.cxx +++ b/xmlsecurity/source/helper/documentsignaturehelper.cxx @@ -32,6 +32,7 @@ #include <osl/diagnose.h> #include <rtl/uri.hxx> +using namespace ::com::sun::star; using namespace ::com::sun::star::uno; namespace @@ -300,27 +301,34 @@ SignatureStreamHelper DocumentSignatureHelper::OpenSignatureStream( SignatureStreamHelper aHelper; - try + uno::Reference<container::XNameAccess> xNameAccess(rxStore, uno::UNO_QUERY); + if (!xNameAccess.is()) + return aHelper; + + if (xNameAccess->hasByName("META-INF")) { - OUString aSIGStoreName( "META-INF" ); - aHelper.xSignatureStorage = rxStore->openStorageElement( aSIGStoreName, nSubStorageOpenMode ); - if ( aHelper.xSignatureStorage.is() ) + try { - OUString aSIGStreamName; - if ( eDocSigMode == SignatureModeDocumentContent ) - aSIGStreamName = DocumentSignatureHelper::GetDocumentContentSignatureDefaultStreamName(); - else if ( eDocSigMode == SignatureModeMacros ) - aSIGStreamName = DocumentSignatureHelper::GetScriptingContentSignatureDefaultStreamName(); - else - aSIGStreamName = DocumentSignatureHelper::GetPackageSignatureDefaultStreamName(); - - aHelper.xSignatureStream = aHelper.xSignatureStorage->openStreamElement( aSIGStreamName, nOpenMode ); + OUString aSIGStoreName( "META-INF" ); + aHelper.xSignatureStorage = rxStore->openStorageElement( aSIGStoreName, nSubStorageOpenMode ); + if ( aHelper.xSignatureStorage.is() ) + { + OUString aSIGStreamName; + if ( eDocSigMode == SignatureModeDocumentContent ) + aSIGStreamName = DocumentSignatureHelper::GetDocumentContentSignatureDefaultStreamName(); + else if ( eDocSigMode == SignatureModeMacros ) + aSIGStreamName = DocumentSignatureHelper::GetScriptingContentSignatureDefaultStreamName(); + else + aSIGStreamName = DocumentSignatureHelper::GetPackageSignatureDefaultStreamName(); + + aHelper.xSignatureStream = aHelper.xSignatureStorage->openStreamElement( aSIGStreamName, nOpenMode ); + } + } + catch(css::io::IOException& ) + { + // Doesn't have to exist... + DBG_ASSERT( nOpenMode == css::embed::ElementModes::READ, "Error creating signature stream..." ); } - } - catch(css::io::IOException& ) - { - // Doesn't have to exist... - DBG_ASSERT( nOpenMode == css::embed::ElementModes::READ, "Error creating signature stream..." ); } return aHelper; |