[Libreoffice-commits] core.git: xmlsecurity/source
Tor Lillqvist
tml at collabora.com
Fri Oct 28 05:36:08 UTC 2016
xmlsecurity/source/helper/ooxmlsecexporter.cxx | 168 +++++++++++------------
xmlsecurity/source/helper/xmlsignaturehelper.cxx | 2
xmlsecurity/source/helper/xsecctl.cxx | 116 +++++++--------
xmlsecurity/source/helper/xsecctl.hxx | 65 +-------
xmlsecurity/source/helper/xsecparser.cxx | 44 +++---
5 files changed, 175 insertions(+), 220 deletions(-)
New commits:
commit d1111863835fe25edb6e15961d41fa2305e9b734
Author: Tor Lillqvist <tml at collabora.com>
Date: Fri Oct 28 01:02:08 2016 +0300
Bin unnecessary TAG_ and ATTR_ macros and expand in-place
They just make grepping harder, and don't really avoid a risk of
mistyping. For instance, there were both TAG_TRANSFORM and
TAG_TRANSFORMS (with values "Transform" and "Transforms"), so if you
think you are likely to misspell "Transforms" as "Transform", you are
as likely to misspell TAG_TRANSFORMS as TAG_TRANSFORM. Typos affecting
generated XML should be catched by unit tests anyway.
Some of the (newer) code here is already in this style, using string
literals directly for tags and attributes, so this change just makes
the style more uniform.
I did not touch the macros that have long URIs as value. For them
there is some usefulness in having the shorter macros in the
code. (But the names of the ALGO_* macros are not consistently
constructed from the URIs.)
Change-Id: I9130395f45fafc13fb2a6ac47e98177647e27cf9
diff --git a/xmlsecurity/source/helper/ooxmlsecexporter.cxx b/xmlsecurity/source/helper/ooxmlsecexporter.cxx
index 38ca141..11d5ee8 100644
--- a/xmlsecurity/source/helper/ooxmlsecexporter.cxx
+++ b/xmlsecurity/source/helper/ooxmlsecexporter.cxx
@@ -108,47 +108,47 @@ bool OOXMLSecExporter::Impl::isOOXMLRelationBlacklist(const OUString& rRelationN
void OOXMLSecExporter::Impl::writeSignedInfo()
{
- m_xDocumentHandler->startElement(TAG_SIGNEDINFO, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
+ m_xDocumentHandler->startElement("SignedInfo", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
writeCanonicalizationMethod();
writeSignatureMethod();
writeSignedInfoReferences();
- m_xDocumentHandler->endElement(TAG_SIGNEDINFO);
+ m_xDocumentHandler->endElement("SignedInfo");
}
void OOXMLSecExporter::Impl::writeCanonicalizationMethod()
{
rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
- pAttributeList->AddAttribute(ATTR_ALGORITHM, ALGO_C14N);
- m_xDocumentHandler->startElement(TAG_CANONICALIZATIONMETHOD, uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
- m_xDocumentHandler->endElement(TAG_CANONICALIZATIONMETHOD);
+ pAttributeList->AddAttribute("Algorithm", ALGO_C14N);
+ m_xDocumentHandler->startElement("CanonicalizationMethod", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+ m_xDocumentHandler->endElement("CanonicalizationMethod");
}
void OOXMLSecExporter::Impl::writeCanonicalizationTransform()
{
rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
- pAttributeList->AddAttribute(ATTR_ALGORITHM, ALGO_C14N);
- m_xDocumentHandler->startElement(TAG_TRANSFORM, uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
- m_xDocumentHandler->endElement(TAG_TRANSFORM);
+ pAttributeList->AddAttribute("Algorithm", ALGO_C14N);
+ m_xDocumentHandler->startElement("Transform", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+ m_xDocumentHandler->endElement("Transform");
}
void OOXMLSecExporter::Impl::writeDigestMethod()
{
rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
- pAttributeList->AddAttribute(ATTR_ALGORITHM, ALGO_XMLDSIGSHA256);
- m_xDocumentHandler->startElement(TAG_DIGESTMETHOD, uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
- m_xDocumentHandler->endElement(TAG_DIGESTMETHOD);
+ pAttributeList->AddAttribute("Algorithm", ALGO_XMLDSIGSHA256);
+ m_xDocumentHandler->startElement("DigestMethod", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+ m_xDocumentHandler->endElement("DigestMethod");
}
void OOXMLSecExporter::Impl::writeSignatureMethod()
{
rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
- pAttributeList->AddAttribute(ATTR_ALGORITHM, ALGO_RSASHA256);
- m_xDocumentHandler->startElement(TAG_SIGNATUREMETHOD, uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
- m_xDocumentHandler->endElement(TAG_SIGNATUREMETHOD);
+ pAttributeList->AddAttribute("Algorithm", ALGO_RSASHA256);
+ m_xDocumentHandler->startElement("SignatureMethod", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+ m_xDocumentHandler->endElement("SignatureMethod");
}
void OOXMLSecExporter::Impl::writeSignedInfoReferences()
@@ -164,58 +164,58 @@ void OOXMLSecExporter::Impl::writeSignedInfoReferences()
pAttributeList->AddAttribute("Type", "http://www.w3.org/2000/09/xmldsig#Object");
else
pAttributeList->AddAttribute("Type", "http://uri.etsi.org/01903#SignedProperties");
- pAttributeList->AddAttribute(ATTR_URI, "#" + rReference.ouURI);
- m_xDocumentHandler->startElement(TAG_REFERENCE, uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+ pAttributeList->AddAttribute("URI", "#" + rReference.ouURI);
+ m_xDocumentHandler->startElement("Reference", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
}
if (rReference.ouURI == "idSignedProperties")
{
- m_xDocumentHandler->startElement(TAG_TRANSFORMS, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
+ m_xDocumentHandler->startElement("Transforms", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
writeCanonicalizationTransform();
- m_xDocumentHandler->endElement(TAG_TRANSFORMS);
+ m_xDocumentHandler->endElement("Transforms");
}
writeDigestMethod();
- m_xDocumentHandler->startElement(TAG_DIGESTVALUE, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
+ m_xDocumentHandler->startElement("DigestValue", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
m_xDocumentHandler->characters(rReference.ouDigestValue);
- m_xDocumentHandler->endElement(TAG_DIGESTVALUE);
- m_xDocumentHandler->endElement(TAG_REFERENCE);
+ m_xDocumentHandler->endElement("DigestValue");
+ m_xDocumentHandler->endElement("Reference");
}
}
}
void OOXMLSecExporter::Impl::writeSignatureValue()
{
- m_xDocumentHandler->startElement(TAG_SIGNATUREVALUE, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
+ m_xDocumentHandler->startElement("SignatureValue", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
m_xDocumentHandler->characters(m_rInformation.ouSignatureValue);
- m_xDocumentHandler->endElement(TAG_SIGNATUREVALUE);
+ m_xDocumentHandler->endElement("SignatureValue");
}
void OOXMLSecExporter::Impl::writeKeyInfo()
{
- m_xDocumentHandler->startElement(TAG_KEYINFO, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
- m_xDocumentHandler->startElement(TAG_X509DATA, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
- m_xDocumentHandler->startElement(TAG_X509CERTIFICATE, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
+ m_xDocumentHandler->startElement("KeyInfo", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
+ m_xDocumentHandler->startElement("X509Data", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
+ m_xDocumentHandler->startElement("X509Certificate", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
m_xDocumentHandler->characters(m_rInformation.ouX509Certificate);
- m_xDocumentHandler->endElement(TAG_X509CERTIFICATE);
- m_xDocumentHandler->endElement(TAG_X509DATA);
- m_xDocumentHandler->endElement(TAG_KEYINFO);
+ m_xDocumentHandler->endElement("X509Certificate");
+ m_xDocumentHandler->endElement("X509Data");
+ m_xDocumentHandler->endElement("KeyInfo");
}
void OOXMLSecExporter::Impl::writePackageObject()
{
rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
- pAttributeList->AddAttribute(ATTR_ID, "idPackageObject");
- m_xDocumentHandler->startElement(TAG_OBJECT, uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+ pAttributeList->AddAttribute("Id", "idPackageObject");
+ m_xDocumentHandler->startElement("Object", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
writeManifest();
writePackageObjectSignatureProperties();
- m_xDocumentHandler->endElement(TAG_OBJECT);
+ m_xDocumentHandler->endElement("Object");
}
void OOXMLSecExporter::Impl::writeManifest()
{
- m_xDocumentHandler->startElement(TAG_MANIFEST, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
+ m_xDocumentHandler->startElement("Manifest", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
const SignatureReferenceInformations& rReferences = m_rInformation.vSignatureReferenceInfors;
for (const SignatureReferenceInformation& rReference : rReferences)
{
@@ -227,7 +227,7 @@ void OOXMLSecExporter::Impl::writeManifest()
writeManifestReference(rReference);
}
}
- m_xDocumentHandler->endElement(TAG_MANIFEST);
+ m_xDocumentHandler->endElement("Manifest");
}
void OOXMLSecExporter::Impl::writeRelationshipTransform(const OUString& rURI)
@@ -236,8 +236,8 @@ void OOXMLSecExporter::Impl::writeRelationshipTransform(const OUString& rURI)
uno::Reference<io::XInputStream> xRelStream(xHierarchicalStorageAccess->openStreamElementByHierarchicalName(rURI, embed::ElementModes::READ), uno::UNO_QUERY);
{
rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
- pAttributeList->AddAttribute(ATTR_ALGORITHM, ALGO_RELATIONSHIP);
- m_xDocumentHandler->startElement(TAG_TRANSFORM, uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+ pAttributeList->AddAttribute("Algorithm", ALGO_RELATIONSHIP);
+ m_xDocumentHandler->startElement("Transform", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
}
uno::Sequence< uno::Sequence<beans::StringPair> > aRelationsInfo = comphelper::OFOPXMLHelper::ReadRelationsInfoSequence(xRelStream, rURI, m_xComponentContext);
@@ -257,34 +257,34 @@ void OOXMLSecExporter::Impl::writeRelationshipTransform(const OUString& rURI)
continue;
rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
- pAttributeList->AddAttribute(ATTR_XMLNS ":" NSTAG_MDSSI, NS_MDSSI);
- pAttributeList->AddAttribute(ATTR_SOURCEID, aId);
- m_xDocumentHandler->startElement(NSTAG_MDSSI ":" TAG_RELATIONSHIPREFERENCE, uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
- m_xDocumentHandler->endElement(NSTAG_MDSSI ":" TAG_RELATIONSHIPREFERENCE);
+ pAttributeList->AddAttribute("xmlns:mdssi", NS_MDSSI);
+ pAttributeList->AddAttribute("SourceId", aId);
+ m_xDocumentHandler->startElement("mdssi:RelationshipReference", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+ m_xDocumentHandler->endElement("mdssi:RelationshipReference");
}
- m_xDocumentHandler->endElement(TAG_TRANSFORM);
+ m_xDocumentHandler->endElement("Transform");
}
void OOXMLSecExporter::Impl::writePackageObjectSignatureProperties()
{
- m_xDocumentHandler->startElement(TAG_SIGNATUREPROPERTIES, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
+ m_xDocumentHandler->startElement("SignatureProperties", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
{
rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
- pAttributeList->AddAttribute(ATTR_ID, "idSignatureTime");
- pAttributeList->AddAttribute(ATTR_TARGET, "#idPackageSignature");
- m_xDocumentHandler->startElement(TAG_SIGNATUREPROPERTY, uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+ pAttributeList->AddAttribute("Id", "idSignatureTime");
+ pAttributeList->AddAttribute("Target", "#idPackageSignature");
+ m_xDocumentHandler->startElement("SignatureProperty", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
}
{
rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
- pAttributeList->AddAttribute(ATTR_XMLNS ":" NSTAG_MDSSI, NS_MDSSI);
- m_xDocumentHandler->startElement(NSTAG_MDSSI ":" TAG_SIGNATURETIME, uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+ pAttributeList->AddAttribute("xmlns:mdssi", NS_MDSSI);
+ m_xDocumentHandler->startElement("mdssi:SignatureTime", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
}
- m_xDocumentHandler->startElement(NSTAG_MDSSI ":" TAG_FORMAT, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
+ m_xDocumentHandler->startElement("mdssi:Format", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
m_xDocumentHandler->characters("YYYY-MM-DDThh:mm:ssTZD");
- m_xDocumentHandler->endElement(NSTAG_MDSSI ":" TAG_FORMAT);
+ m_xDocumentHandler->endElement("mdssi:Format");
- m_xDocumentHandler->startElement(NSTAG_MDSSI ":" TAG_VALUE, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
+ m_xDocumentHandler->startElement("mdssi:Value", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
if (!m_rInformation.ouDateTime.isEmpty())
m_aSignatureTimeValue = m_rInformation.ouDateTime;
else
@@ -299,18 +299,18 @@ void OOXMLSecExporter::Impl::writePackageObjectSignatureProperties()
}
}
m_xDocumentHandler->characters(m_aSignatureTimeValue);
- m_xDocumentHandler->endElement(NSTAG_MDSSI ":" TAG_VALUE);
+ m_xDocumentHandler->endElement("mdssi:Value");
- m_xDocumentHandler->endElement(NSTAG_MDSSI ":" TAG_SIGNATURETIME);
- m_xDocumentHandler->endElement(TAG_SIGNATUREPROPERTY);
- m_xDocumentHandler->endElement(TAG_SIGNATUREPROPERTIES);
+ m_xDocumentHandler->endElement("mdssi:SignatureTime");
+ m_xDocumentHandler->endElement("SignatureProperty");
+ m_xDocumentHandler->endElement("SignatureProperties");
}
void OOXMLSecExporter::Impl::writeManifestReference(const SignatureReferenceInformation& rReference)
{
rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
- pAttributeList->AddAttribute(ATTR_URI, rReference.ouURI);
- m_xDocumentHandler->startElement(TAG_REFERENCE, uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+ pAttributeList->AddAttribute("URI", rReference.ouURI);
+ m_xDocumentHandler->startElement("Reference", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
// Transforms
if (rReference.ouURI.endsWith("?ContentType=application/vnd.openxmlformats-package.relationships+xml"))
@@ -324,45 +324,45 @@ void OOXMLSecExporter::Impl::writeManifestReference(const SignatureReferenceInfo
if (nQueryPos != -1)
aURI = aURI.copy(0, nQueryPos);
- m_xDocumentHandler->startElement(TAG_TRANSFORMS, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
+ m_xDocumentHandler->startElement("Transforms", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
writeRelationshipTransform(aURI);
writeCanonicalizationTransform();
- m_xDocumentHandler->endElement(TAG_TRANSFORMS);
+ m_xDocumentHandler->endElement("Transforms");
}
writeDigestMethod();
- m_xDocumentHandler->startElement(TAG_DIGESTVALUE, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
+ m_xDocumentHandler->startElement("DigestValue", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
m_xDocumentHandler->characters(rReference.ouDigestValue);
- m_xDocumentHandler->endElement(TAG_DIGESTVALUE);
- m_xDocumentHandler->endElement(TAG_REFERENCE);
+ m_xDocumentHandler->endElement("DigestValue");
+ m_xDocumentHandler->endElement("Reference");
}
void OOXMLSecExporter::Impl::writeOfficeObject()
{
{
rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
- pAttributeList->AddAttribute(ATTR_ID, "idOfficeObject");
- m_xDocumentHandler->startElement(TAG_OBJECT, uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+ pAttributeList->AddAttribute("Id", "idOfficeObject");
+ m_xDocumentHandler->startElement("Object", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
}
- m_xDocumentHandler->startElement(TAG_SIGNATUREPROPERTIES, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
+ m_xDocumentHandler->startElement("SignatureProperties", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
{
rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
- pAttributeList->AddAttribute(ATTR_ID, "idOfficeV1Details");
- pAttributeList->AddAttribute(ATTR_TARGET, "#idPackageSignature");
- m_xDocumentHandler->startElement(TAG_SIGNATUREPROPERTY, uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+ pAttributeList->AddAttribute("Id", "idOfficeV1Details");
+ pAttributeList->AddAttribute("Target", "#idPackageSignature");
+ m_xDocumentHandler->startElement("SignatureProperty", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
}
writeSignatureInfo();
- m_xDocumentHandler->endElement(TAG_SIGNATUREPROPERTY);
- m_xDocumentHandler->endElement(TAG_SIGNATUREPROPERTIES);
- m_xDocumentHandler->endElement(TAG_OBJECT);
+ m_xDocumentHandler->endElement("SignatureProperty");
+ m_xDocumentHandler->endElement("SignatureProperties");
+ m_xDocumentHandler->endElement("Object");
}
void OOXMLSecExporter::Impl::writeSignatureInfo()
{
rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
- pAttributeList->AddAttribute(ATTR_XMLNS, "http://schemas.microsoft.com/office/2006/digsig");
+ pAttributeList->AddAttribute("xmlns", "http://schemas.microsoft.com/office/2006/digsig");
m_xDocumentHandler->startElement("SignatureInfoV1", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
m_xDocumentHandler->startElement("SetupId", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
@@ -413,26 +413,26 @@ void OOXMLSecExporter::Impl::writeSignatureInfo()
void OOXMLSecExporter::Impl::writePackageSignature()
{
- m_xDocumentHandler->startElement(TAG_OBJECT, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
+ m_xDocumentHandler->startElement("Object", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
{
rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
- pAttributeList->AddAttribute(ATTR_XMLNS ":" NSTAG_XD, NS_XD);
- pAttributeList->AddAttribute(ATTR_TARGET, "#idPackageSignature");
- m_xDocumentHandler->startElement(NSTAG_XD ":" TAG_QUALIFYINGPROPERTIES, uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+ pAttributeList->AddAttribute("xmlns:xd", NS_XD);
+ pAttributeList->AddAttribute("Target", "#idPackageSignature");
+ m_xDocumentHandler->startElement("xd:QualifyingProperties", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
}
writeSignedProperties();
- m_xDocumentHandler->endElement(NSTAG_XD ":" TAG_QUALIFYINGPROPERTIES);
- m_xDocumentHandler->endElement(TAG_OBJECT);
+ m_xDocumentHandler->endElement("xd:QualifyingProperties");
+ m_xDocumentHandler->endElement("Object");
}
void OOXMLSecExporter::Impl::writeSignedProperties()
{
{
rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
- pAttributeList->AddAttribute(ATTR_ID, "idSignedProperties");
- m_xDocumentHandler->startElement(NSTAG_XD ":" TAG_SIGNEDPROPERTIES, uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+ pAttributeList->AddAttribute("Id", "idSignedProperties");
+ m_xDocumentHandler->startElement("xd:SignedProperties", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
}
m_xDocumentHandler->startElement("xd:SignedSignatureProperties", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
@@ -466,7 +466,7 @@ void OOXMLSecExporter::Impl::writeSignedProperties()
m_xDocumentHandler->endElement("xd:SignaturePolicyIdentifier");
m_xDocumentHandler->endElement("xd:SignedSignatureProperties");
- m_xDocumentHandler->endElement(NSTAG_XD ":" TAG_SIGNEDPROPERTIES);
+ m_xDocumentHandler->endElement("xd:SignedProperties");
}
OOXMLSecExporter::OOXMLSecExporter(const uno::Reference<uno::XComponentContext>& xComponentContext,
@@ -484,9 +484,9 @@ OOXMLSecExporter::~OOXMLSecExporter()
void OOXMLSecExporter::writeSignature()
{
rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
- pAttributeList->AddAttribute(ATTR_XMLNS, NS_XMLDSIG);
- pAttributeList->AddAttribute(ATTR_ID, "idPackageSignature");
- m_pImpl->m_xDocumentHandler->startElement(TAG_SIGNATURE, uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+ pAttributeList->AddAttribute("xmlns", NS_XMLDSIG);
+ pAttributeList->AddAttribute("Id", "idPackageSignature");
+ m_pImpl->m_xDocumentHandler->startElement("Signature", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
m_pImpl->writeSignedInfo();
m_pImpl->writeSignatureValue();
@@ -495,7 +495,7 @@ void OOXMLSecExporter::writeSignature()
m_pImpl->writeOfficeObject();
m_pImpl->writePackageSignature();
- m_pImpl->m_xDocumentHandler->endElement(TAG_SIGNATURE);
+ m_pImpl->m_xDocumentHandler->endElement("Signature");
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
index 7bf7ebe..2a43bb1 100644
--- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
@@ -177,7 +177,7 @@ uno::Reference<xml::sax::XWriter> XMLSignatureHelper::CreateDocumentHandlerWithH
sNamespace = NS_DOCUMENTSIGNATURES_ODF_1_2;
pAttributeList->AddAttribute(
- ATTR_XMLNS,
+ "xmlns",
sNamespace);
xSaxWriter->startDocument();
diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx
index 3d003fb..81a4e9c 100644
--- a/xmlsecurity/source/helper/xsecctl.cxx
+++ b/xmlsecurity/source/helper/xsecctl.cxx
@@ -589,38 +589,38 @@ void XSecController::exportSignature(
*/
pAttributeList = new SvXMLAttributeList();
pAttributeList->AddAttribute(
- ATTR_XMLNS,
+ "xmlns",
NS_XMLDSIG);
if (!signatureInfo.ouSignatureId.isEmpty())
{
pAttributeList->AddAttribute(
- ATTR_ID,
+ "Id",
OUString(signatureInfo.ouSignatureId));
}
- xDocumentHandler->startElement( TAG_SIGNATURE, cssu::Reference< cssxs::XAttributeList > (pAttributeList));
+ xDocumentHandler->startElement( "Signature", cssu::Reference< cssxs::XAttributeList > (pAttributeList));
{
/* Write SignedInfo element */
xDocumentHandler->startElement(
- TAG_SIGNEDINFO,
+ "SignedInfo",
cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
{
/* Write CanonicalizationMethod element */
pAttributeList = new SvXMLAttributeList();
pAttributeList->AddAttribute(
- ATTR_ALGORITHM,
+ "Algorithm",
ALGO_C14N);
- xDocumentHandler->startElement( TAG_CANONICALIZATIONMETHOD, cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
- xDocumentHandler->endElement( TAG_CANONICALIZATIONMETHOD );
+ xDocumentHandler->startElement( "CanonicalizationMethod", cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
+ xDocumentHandler->endElement( "CanonicalizationMethod" );
/* Write SignatureMethod element */
pAttributeList = new SvXMLAttributeList();
pAttributeList->AddAttribute(
- ATTR_ALGORITHM,
+ "Algorithm",
ALGO_RSASHA1);
- xDocumentHandler->startElement( TAG_SIGNATUREMETHOD, cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
- xDocumentHandler->endElement( TAG_SIGNATUREMETHOD );
+ xDocumentHandler->startElement( "SignatureMethod", cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
+ xDocumentHandler->endElement( "SignatureMethod" );
/* Write Reference element */
int j;
@@ -637,7 +637,7 @@ void XSecController::exportSignature(
*/
{
pAttributeList->AddAttribute(
- ATTR_URI,
+ "URI",
refInfor.ouURI);
}
else
@@ -646,11 +646,11 @@ void XSecController::exportSignature(
*/
{
pAttributeList->AddAttribute(
- ATTR_URI,
+ "URI",
"#" + refInfor.ouURI);
}
- xDocumentHandler->startElement( TAG_REFERENCE, cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
+ xDocumentHandler->startElement( "Reference", cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
{
/* Write Transforms element */
if (refInfor.nType == SignatureReferenceType::XMLSTREAM)
@@ -659,126 +659,126 @@ void XSecController::exportSignature(
*/
{
xDocumentHandler->startElement(
- TAG_TRANSFORMS,
+ "Transforms",
cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
{
pAttributeList = new SvXMLAttributeList();
pAttributeList->AddAttribute(
- ATTR_ALGORITHM,
+ "Algorithm",
ALGO_C14N);
xDocumentHandler->startElement(
- TAG_TRANSFORM,
+ "Transform",
cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
- xDocumentHandler->endElement( TAG_TRANSFORM );
+ xDocumentHandler->endElement( "Transform" );
}
- xDocumentHandler->endElement( TAG_TRANSFORMS );
+ xDocumentHandler->endElement( "Transforms" );
}
/* Write DigestMethod element */
pAttributeList = new SvXMLAttributeList();
pAttributeList->AddAttribute(
- ATTR_ALGORITHM,
+ "Algorithm",
ALGO_XMLDSIGSHA1);
xDocumentHandler->startElement(
- TAG_DIGESTMETHOD,
+ "DigestMethod",
cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
- xDocumentHandler->endElement( TAG_DIGESTMETHOD );
+ xDocumentHandler->endElement( "DigestMethod" );
/* Write DigestValue element */
xDocumentHandler->startElement(
- TAG_DIGESTVALUE,
+ "DigestValue",
cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
xDocumentHandler->characters( refInfor.ouDigestValue );
- xDocumentHandler->endElement( TAG_DIGESTVALUE );
+ xDocumentHandler->endElement( "DigestValue" );
}
- xDocumentHandler->endElement( TAG_REFERENCE );
+ xDocumentHandler->endElement( "Reference" );
}
}
- xDocumentHandler->endElement( TAG_SIGNEDINFO );
+ xDocumentHandler->endElement( "SignedInfo" );
/* Write SignatureValue element */
xDocumentHandler->startElement(
- TAG_SIGNATUREVALUE,
+ "SignatureValue",
cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
xDocumentHandler->characters( signatureInfo.ouSignatureValue );
- xDocumentHandler->endElement( TAG_SIGNATUREVALUE );
+ xDocumentHandler->endElement( "SignatureValue" );
/* Write KeyInfo element */
xDocumentHandler->startElement(
- TAG_KEYINFO,
+ "KeyInfo",
cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
{
/* Write X509Data element */
xDocumentHandler->startElement(
- TAG_X509DATA,
+ "X509Data",
cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
{
/* Write X509IssuerSerial element */
xDocumentHandler->startElement(
- TAG_X509ISSUERSERIAL,
+ "X509IssuerSerial",
cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
{
/* Write X509IssuerName element */
xDocumentHandler->startElement(
- TAG_X509ISSUERNAME,
+ "X509IssuerName",
cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
xDocumentHandler->characters( signatureInfo.ouX509IssuerName );
- xDocumentHandler->endElement( TAG_X509ISSUERNAME );
+ xDocumentHandler->endElement( "X509IssuerName" );
/* Write X509SerialNumber element */
xDocumentHandler->startElement(
- TAG_X509SERIALNUMBER,
+ "X509SerialNumber",
cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
xDocumentHandler->characters( signatureInfo.ouX509SerialNumber );
- xDocumentHandler->endElement( TAG_X509SERIALNUMBER );
+ xDocumentHandler->endElement( "X509SerialNumber" );
}
- xDocumentHandler->endElement( TAG_X509ISSUERSERIAL );
+ xDocumentHandler->endElement( "X509IssuerSerial" );
/* Write X509Certificate element */
if (!signatureInfo.ouX509Certificate.isEmpty())
{
xDocumentHandler->startElement(
- TAG_X509CERTIFICATE,
+ "X509Certificate",
cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
xDocumentHandler->characters( signatureInfo.ouX509Certificate );
- xDocumentHandler->endElement( TAG_X509CERTIFICATE );
+ xDocumentHandler->endElement( "X509Certificate" );
}
}
- xDocumentHandler->endElement( TAG_X509DATA );
+ xDocumentHandler->endElement( "X509Data" );
}
- xDocumentHandler->endElement( TAG_KEYINFO );
+ xDocumentHandler->endElement( "KeyInfo" );
/* Write Object element */
xDocumentHandler->startElement(
- TAG_OBJECT,
+ "Object",
cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
{
/* Write SignatureProperties element */
xDocumentHandler->startElement(
- TAG_SIGNATUREPROPERTIES,
+ "SignatureProperties",
cssu::Reference< cssxs::XAttributeList > (new SvXMLAttributeList()));
{
/* Write SignatureProperty element */
pAttributeList = new SvXMLAttributeList();
pAttributeList->AddAttribute(
- ATTR_ID,
+ "Id",
signatureInfo.ouPropertyId);
pAttributeList->AddAttribute(
- ATTR_TARGET,
+ "Target",
"#" + signatureInfo.ouSignatureId);
xDocumentHandler->startElement(
- TAG_SIGNATUREPROPERTY,
+ "SignatureProperty",
cssu::Reference< cssxs::XAttributeList > (pAttributeList));
{
/* Write timestamp element */
pAttributeList = new SvXMLAttributeList();
pAttributeList->AddAttribute(
- ATTR_XMLNS ":" NSTAG_DC,
+ "xmlns:dc",
NS_DC);
xDocumentHandler->startElement(
- NSTAG_DC ":" TAG_DATE,
+ "dc:date",
cssu::Reference< cssxs::XAttributeList > (pAttributeList));
OUStringBuffer buffer;
@@ -795,9 +795,9 @@ void XSecController::exportSignature(
xDocumentHandler->characters( buffer.makeStringAndClear() );
xDocumentHandler->endElement(
- NSTAG_DC ":" TAG_DATE);
+ "dc:date");
}
- xDocumentHandler->endElement( TAG_SIGNATUREPROPERTY );
+ xDocumentHandler->endElement( "SignatureProperty" );
}
// Write signature description.
@@ -805,28 +805,28 @@ void XSecController::exportSignature(
{
// SignatureProperty element.
pAttributeList = new SvXMLAttributeList();
- pAttributeList->AddAttribute(ATTR_ID, signatureInfo.ouDescriptionPropertyId);
- pAttributeList->AddAttribute(ATTR_TARGET, "#" + signatureInfo.ouSignatureId);
- xDocumentHandler->startElement(TAG_SIGNATUREPROPERTY, uno::Reference<xml::sax::XAttributeList>(pAttributeList));
+ pAttributeList->AddAttribute("Id", signatureInfo.ouDescriptionPropertyId);
+ pAttributeList->AddAttribute("Target", "#" + signatureInfo.ouSignatureId);
+ xDocumentHandler->startElement("SignatureProperty", uno::Reference<xml::sax::XAttributeList>(pAttributeList));
{
// Description element.
pAttributeList = new SvXMLAttributeList();
- pAttributeList->AddAttribute(ATTR_XMLNS ":" NSTAG_DC, NS_DC);
+ pAttributeList->AddAttribute("xmlns:dc", NS_DC);
- xDocumentHandler->startElement(NSTAG_DC ":" TAG_DESCRIPTION, uno::Reference<xml::sax::XAttributeList>(pAttributeList));
+ xDocumentHandler->startElement("dc:description", uno::Reference<xml::sax::XAttributeList>(pAttributeList));
xDocumentHandler->characters(signatureInfo.ouDescription);
- xDocumentHandler->endElement(NSTAG_DC ":" TAG_DESCRIPTION);
+ xDocumentHandler->endElement("dc:description");
}
- xDocumentHandler->endElement(TAG_SIGNATUREPROPERTY);
+ xDocumentHandler->endElement("SignatureProperty");
}
- xDocumentHandler->endElement( TAG_SIGNATUREPROPERTIES );
+ xDocumentHandler->endElement( "SignatureProperties" );
}
- xDocumentHandler->endElement( TAG_OBJECT );
+ xDocumentHandler->endElement( "Object" );
}
- xDocumentHandler->endElement( TAG_SIGNATURE );
+ xDocumentHandler->endElement( "Signature" );
}
void XSecController::exportOOXMLSignature(const uno::Reference<embed::XStorage>& xRootStorage, const uno::Reference<xml::sax::XDocumentHandler>& xDocumentHandler, const SignatureInformation& rInformation)
diff --git a/xmlsecurity/source/helper/xsecctl.hxx b/xmlsecurity/source/helper/xsecctl.hxx
index faa6118..e4693a9 100644
--- a/xmlsecurity/source/helper/xsecctl.hxx
+++ b/xmlsecurity/source/helper/xsecctl.hxx
@@ -56,62 +56,17 @@
#define ERROR_IOEXCEPTIONDURINGCREATION "An IO exception is throwed during signature creation."
#define ERROR_EXCEPTIONDURINGCREATION "An exception is throwed during signature creation."
-/*
- * all stringS in signature element
- */
-#define TAG_SIGNATURE "Signature"
-#define TAG_SIGNEDINFO "SignedInfo"
-#define TAG_CANONICALIZATIONMETHOD "CanonicalizationMethod"
-#define TAG_SIGNATUREMETHOD "SignatureMethod"
-#define TAG_REFERENCE "Reference"
-#define TAG_TRANSFORMS "Transforms"
-#define TAG_TRANSFORM "Transform"
-#define TAG_DIGESTMETHOD "DigestMethod"
-#define TAG_DIGESTVALUE "DigestValue"
-#define TAG_SIGNATUREVALUE "SignatureValue"
-#define TAG_KEYINFO "KeyInfo"
-#define TAG_X509DATA "X509Data"
-#define TAG_X509ISSUERSERIAL "X509IssuerSerial"
-#define TAG_X509ISSUERNAME "X509IssuerName"
-#define TAG_X509SERIALNUMBER "X509SerialNumber"
-#define TAG_X509CERTIFICATE "X509Certificate"
-#define TAG_OBJECT "Object"
-#define TAG_SIGNATUREPROPERTIES "SignatureProperties"
-#define TAG_SIGNATUREPROPERTY "SignatureProperty"
-#define TAG_MANIFEST "Manifest"
-#define TAG_TIMESTAMP "timestamp"
-#define TAG_DATE "date"
-#define TAG_DESCRIPTION "description"
-#define TAG_QUALIFYINGPROPERTIES "QualifyingProperties"
-#define TAG_SIGNEDPROPERTIES "SignedProperties"
-#define TAG_RELATIONSHIPREFERENCE "RelationshipReference"
-#define TAG_SIGNATURETIME "SignatureTime"
-#define TAG_FORMAT "Format"
-#define TAG_VALUE "Value"
-
-#define ATTR_XMLNS "xmlns"
-#define ATTR_ALGORITHM "Algorithm"
-#define ATTR_URI "URI"
-#define ATTR_ID "Id"
-#define ATTR_TARGET "Target"
-#define ATTR_SOURCEID "SourceId"
-
-#define NSTAG_DC "dc"
-#define NSTAG_XD "xd"
-#define NSTAG_MDSSI "mdssi"
-
-#define NS_XMLDSIG "http://www.w3.org/2000/09/xmldsig#"
-//#define NS_DATETIME "http://www.ietf.org/rfcXXXX.txt"
-#define NS_DC "http://purl.org/dc/elements/1.1/"
-#define NS_XD "http://uri.etsi.org/01903/v1.3.2#"
-#define NS_MDSSI "http://schemas.openxmlformats.org/package/2006/digital-signature"
-
-#define ALGO_C14N "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
-#define ALGO_RSASHA1 "http://www.w3.org/2000/09/xmldsig#rsa-sha1"
-#define ALGO_RSASHA256 "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
-#define ALGO_XMLDSIGSHA1 "http://www.w3.org/2000/09/xmldsig#sha1"
+#define NS_XMLDSIG "http://www.w3.org/2000/09/xmldsig#"
+#define NS_DC "http://purl.org/dc/elements/1.1/"
+#define NS_XD "http://uri.etsi.org/01903/v1.3.2#"
+#define NS_MDSSI "http://schemas.openxmlformats.org/package/2006/digital-signature"
+
+#define ALGO_C14N "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
+#define ALGO_RSASHA1 "http://www.w3.org/2000/09/xmldsig#rsa-sha1"
+#define ALGO_RSASHA256 "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
+#define ALGO_XMLDSIGSHA1 "http://www.w3.org/2000/09/xmldsig#sha1"
#define ALGO_XMLDSIGSHA256 "http://www.w3.org/2001/04/xmlenc#sha256"
-#define ALGO_RELATIONSHIP "http://schemas.openxmlformats.org/package/2006/RelationshipTransform"
+#define ALGO_RELATIONSHIP "http://schemas.openxmlformats.org/package/2006/RelationshipTransform"
class XSecParser;
diff --git a/xmlsecurity/source/helper/xsecparser.cxx b/xmlsecurity/source/helper/xsecparser.cxx
index cd99376..ddc689a 100644
--- a/xmlsecurity/source/helper/xsecparser.cxx
+++ b/xmlsecurity/source/helper/xsecparser.cxx
@@ -96,7 +96,7 @@ void SAL_CALL XSecParser::startElement(
m_pXSecController->collectToVerify( ouIdAttr );
}
- if ( aName == TAG_SIGNATURE )
+ if ( aName == "Signature" )
{
m_pXSecController->addSignature();
if (ouIdAttr != nullptr)
@@ -104,9 +104,9 @@ void SAL_CALL XSecParser::startElement(
m_pXSecController->setId( ouIdAttr );
}
}
- else if ( aName == TAG_REFERENCE )
+ else if ( aName == "Reference" )
{
- OUString ouUri = xAttribs->getValueByName(ATTR_URI);
+ OUString ouUri = xAttribs->getValueByName("URI");
SAL_WARN_IF( ouUri == nullptr, "xmlsecurity.helper", "URI == NULL" );
if (ouUri.startsWith("#"))
@@ -125,11 +125,11 @@ void SAL_CALL XSecParser::startElement(
m_bReferenceUnresolved = true;
}
}
- else if (aName == TAG_TRANSFORM)
+ else if (aName == "Transform")
{
if ( m_bReferenceUnresolved )
{
- OUString ouAlgorithm = xAttribs->getValueByName(ATTR_ALGORITHM);
+ OUString ouAlgorithm = xAttribs->getValueByName("Algorithm");
if (ouAlgorithm != nullptr && ouAlgorithm == ALGO_C14N)
/*
@@ -141,44 +141,44 @@ void SAL_CALL XSecParser::startElement(
}
}
}
- else if (aName == TAG_X509ISSUERNAME)
+ else if (aName == "X509IssuerName")
{
m_ouX509IssuerName.clear();
m_bInX509IssuerName = true;
}
- else if (aName == TAG_X509SERIALNUMBER)
+ else if (aName == "X509SerialNumber")
{
m_ouX509SerialNumber.clear();
m_bInX509SerialNumber = true;
}
- else if (aName == TAG_X509CERTIFICATE)
+ else if (aName == "X509Certificate")
{
m_ouX509Certificate.clear();
m_bInX509Certificate = true;
}
- else if (aName == TAG_SIGNATUREVALUE)
+ else if (aName == "SignatureValue")
{
m_ouSignatureValue.clear();
m_bInSignatureValue = true;
}
- else if (aName == TAG_DIGESTVALUE)
+ else if (aName == "DigestValue")
{
m_ouDigestValue.clear();
m_bInDigestValue = true;
}
- else if ( aName == TAG_SIGNATUREPROPERTY )
+ else if ( aName == "SignatureProperty" )
{
if (ouIdAttr != nullptr)
{
m_pXSecController->setPropertyId( ouIdAttr );
}
}
- else if (aName == NSTAG_DC ":" TAG_DATE)
+ else if (aName == "dc:date")
{
m_ouDate.clear();
m_bInDate = true;
}
- else if (aName == NSTAG_DC ":" TAG_DESCRIPTION)
+ else if (aName == "dc:description")
{
m_ouDescription.clear();
m_bInDescription = true;
@@ -209,11 +209,11 @@ void SAL_CALL XSecParser::endElement( const OUString& aName )
{
try
{
- if (aName == TAG_DIGESTVALUE)
+ if (aName == "DigestValue")
{
m_bInDigestValue = false;
}
- else if ( aName == TAG_REFERENCE )
+ else if ( aName == "Reference" )
{
if ( m_bReferenceUnresolved )
/*
@@ -226,36 +226,36 @@ void SAL_CALL XSecParser::endElement( const OUString& aName )
m_pXSecController->setDigestValue( m_ouDigestValue );
}
- else if ( aName == TAG_SIGNEDINFO )
+ else if ( aName == "SignedInfo" )
{
m_pXSecController->setReferenceCount();
}
- else if ( aName == TAG_SIGNATUREVALUE )
+ else if ( aName == "SignatureValue" )
{
m_pXSecController->setSignatureValue( m_ouSignatureValue );
m_bInSignatureValue = false;
}
- else if (aName == TAG_X509ISSUERNAME)
+ else if (aName == "X509IssuerName")
{
m_pXSecController->setX509IssuerName( m_ouX509IssuerName );
m_bInX509IssuerName = false;
}
- else if (aName == TAG_X509SERIALNUMBER)
+ else if (aName == "X509SerialNumber")
{
m_pXSecController->setX509SerialNumber( m_ouX509SerialNumber );
m_bInX509SerialNumber = false;
}
- else if (aName == TAG_X509CERTIFICATE)
+ else if (aName == "X509Certificate")
{
m_pXSecController->setX509Certificate( m_ouX509Certificate );
m_bInX509Certificate = false;
}
- else if (aName == NSTAG_DC ":" TAG_DATE)
+ else if (aName == "dc:date")
{
m_pXSecController->setDate( m_ouDate );
m_bInDate = false;
}
- else if (aName == NSTAG_DC ":" TAG_DESCRIPTION)
+ else if (aName == "dc:description")
{
m_pXSecController->setDescription( m_ouDescription );
m_bInDescription = false;
More information about the Libreoffice-commits
mailing list