summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xmlsecurity/source/helper/ooxmlsecexporter.cxx168
-rw-r--r--xmlsecurity/source/helper/xmlsignaturehelper.cxx2
-rw-r--r--xmlsecurity/source/helper/xsecctl.cxx116
-rw-r--r--xmlsecurity/source/helper/xsecctl.hxx65
-rw-r--r--xmlsecurity/source/helper/xsecparser.cxx44
5 files changed, 175 insertions, 220 deletions
diff --git a/xmlsecurity/source/helper/ooxmlsecexporter.cxx b/xmlsecurity/source/helper/ooxmlsecexporter.cxx
index 38ca1418bffc..11d5ee8af654 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 7bf7ebe6ee55..2a43bb144de3 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 3d003fba0914..81a4e9cc5d83 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 faa6118ec7a5..e4693a93e2a3 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 cd9937623246..ddc689a63793 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;