xmlsecurity: don't assume the signature is always a single stream
Change-Id: I07ce23d698fea9338a85b086a5a3c3418e8c8290
This commit is contained in:
parent
faf636b09f
commit
e62ba5bb3f
5 changed files with 34 additions and 2 deletions
|
@ -60,6 +60,13 @@ struct SignatureStreamHelper
|
|||
{
|
||||
css::uno::Reference < css::embed::XStorage > xSignatureStorage;
|
||||
css::uno::Reference < css::io::XStream > xSignatureStream;
|
||||
/// If this is embed::StorageFormats::OFOPXML, then it's expected that xSignatureStream is an empty reference.
|
||||
sal_Int32 nStorageFormat;
|
||||
|
||||
SignatureStreamHelper()
|
||||
: nStorageFormat(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -177,6 +177,9 @@ public:
|
|||
::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XWriter> CreateDocumentHandlerWithHeader( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xOutputStream );
|
||||
static void CloseDocumentHandler( const ::com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler>& xDocumentHandler );
|
||||
static void ExportSignature( const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler >& xDocumentHandler, const SignatureInformation& signatureInfo );
|
||||
|
||||
/// Read and verify an OOXML signature.
|
||||
bool ReadAndVerifySignatureStorage(const css::uno::Reference<css::embed::XStorage>& xStorage);
|
||||
};
|
||||
|
||||
#endif // INCLUDED_XMLSECURITY_INC_XMLSECURITY_XMLSIGNATUREHELPER_HXX
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <../dialogs/resourcemanager.hxx>
|
||||
#include <com/sun/star/embed/XStorage.hpp>
|
||||
#include <com/sun/star/embed/StorageFormats.hpp>
|
||||
#include <com/sun/star/embed/XTransactedObject.hpp>
|
||||
#include <com/sun/star/embed/ElementModes.hpp>
|
||||
#include <com/sun/star/ucb/XContent.hpp>
|
||||
|
@ -272,7 +273,7 @@ DocumentDigitalSignatures::ImplVerifySignatures(
|
|||
xInputStream.set( aStreamHelper.xSignatureStream, UNO_QUERY );
|
||||
}
|
||||
|
||||
if ( !xInputStream.is() )
|
||||
if (!xInputStream.is() && aStreamHelper.nStorageFormat != embed::StorageFormats::OFOPXML)
|
||||
return Sequence< ::com::sun::star::security::DocumentSignatureInformation >(0);
|
||||
|
||||
|
||||
|
@ -289,7 +290,10 @@ DocumentDigitalSignatures::ImplVerifySignatures(
|
|||
|
||||
aSignatureHelper.StartMission();
|
||||
|
||||
aSignatureHelper.ReadAndVerifySignature( xInputStream );
|
||||
if (xInputStream.is())
|
||||
aSignatureHelper.ReadAndVerifySignature(xInputStream);
|
||||
else if (aStreamHelper.nStorageFormat == embed::StorageFormats::OFOPXML)
|
||||
aSignatureHelper.ReadAndVerifySignatureStorage(aStreamHelper.xSignatureStorage);
|
||||
|
||||
aSignatureHelper.EndMission();
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <com/sun/star/lang/XComponent.hpp>
|
||||
#include <com/sun/star/lang/DisposedException.hpp>
|
||||
#include <com/sun/star/embed/XStorage.hpp>
|
||||
#include <com/sun/star/embed/StorageFormats.hpp>
|
||||
#include <com/sun/star/embed/ElementModes.hpp>
|
||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
|
||||
|
@ -330,6 +331,18 @@ SignatureStreamHelper DocumentSignatureHelper::OpenSignatureStream(
|
|||
DBG_ASSERT( nOpenMode == css::embed::ElementModes::READ, "Error creating signature stream..." );
|
||||
}
|
||||
}
|
||||
else if(xNameAccess->hasByName("_xmlsignatures"))
|
||||
{
|
||||
try
|
||||
{
|
||||
aHelper.xSignatureStorage = rxStore->openStorageElement("_xmlsignatures", nSubStorageOpenMode);
|
||||
aHelper.nStorageFormat = embed::StorageFormats::OFOPXML;
|
||||
}
|
||||
catch (const io::IOException& rException)
|
||||
{
|
||||
SAL_WARN("xmlsecurity.helper", "DocumentSignatureHelper::OpenSignatureStream: " << rException.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return aHelper;
|
||||
}
|
||||
|
|
|
@ -301,6 +301,11 @@ 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 );
|
||||
|
|
Loading…
Reference in a new issue