xmlsecurity: mark the Signature, not the SignedInfo during OOXML export

So that we pass the correct node to xmlSecDSigCtxSign().
SAXEventKeeperImpl::startElement() always marks the first node written
by XSecController, which is the Signature node for ODF, but for OOXML,
the Signature node is the root element.

Fix the problem by writing the root element in
XSecController::exportOOXMLSignature() instead of doing it earlier,
similar how it's done for ODF (where we intentionally want to not mark
the root node).

Change-Id: Id0a76f155726ad53a996e9327454b8795497ac7b
This commit is contained in:
Miklos Vajna
2016-02-09 13:34:18 +01:00
parent 0163501d57
commit 4dcee42b44
2 changed files with 7 additions and 6 deletions
@@ -500,17 +500,11 @@ bool XMLSignatureHelper::CreateAndWriteOOXMLSignature(css::uno::Reference<css::e
xSaxWriter->setOutputStream(xOutputStream);
xSaxWriter->startDocument();
SvXMLAttributeList* pAttributeList = new SvXMLAttributeList();
pAttributeList->AddAttribute(ATTR_XMLNS, NS_XMLDSIG);
pAttributeList->AddAttribute(ATTR_ID, "idPackageSignature");
xSaxWriter->startElement(TAG_SIGNATURE, uno::Reference<xml::sax::XAttributeList>(pAttributeList));
mbError = false;
uno::Reference<xml::sax::XDocumentHandler> xDocumentHandler(xSaxWriter, uno::UNO_QUERY);
if (!mpXSecController->WriteOOXMLSignature(xDocumentHandler))
mbError = true;
xSaxWriter->endElement(TAG_SIGNATURE);
xSaxWriter->endDocument();
return !mbError;
+7
View File
@@ -995,6 +995,12 @@ static bool lcl_isOOXMLBlacklist(const OUString& rStreamName)
void XSecController::exportOOXMLSignature(const uno::Reference<xml::sax::XDocumentHandler>& xDocumentHandler, const SignatureInformation& rInformation)
{
{
rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
pAttributeList->AddAttribute(ATTR_XMLNS, NS_XMLDSIG);
pAttributeList->AddAttribute(ATTR_ID, "idPackageSignature");
xDocumentHandler->startElement(TAG_SIGNATURE, uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
}
xDocumentHandler->startElement(TAG_SIGNEDINFO, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
{
@@ -1104,6 +1110,7 @@ void XSecController::exportOOXMLSignature(const uno::Reference<xml::sax::XDocume
xDocumentHandler->startElement(TAG_OBJECT, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
xDocumentHandler->endElement(TAG_OBJECT);
xDocumentHandler->endElement(TAG_SIGNATURE);
}
SignatureInformation XSecController::getSignatureInformation( sal_Int32 nSecurityId ) const