diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-05-15 13:12:42 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-05-15 18:03:51 +0200 |
commit | 6e267990695548db227c918679b907c60263cb81 (patch) | |
tree | 96bca33746fe1a26a348a35c74a1dee8977c349d /xmlsecurity/source/helper | |
parent | 11bfced0a4f1d5f3ccaf8e1c87c11733ca71f29d (diff) |
loplugin:ostr in xmlsecurity
Change-Id: Ifb936c230f68447b3bb5993705adb5e5b790371f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167668
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'xmlsecurity/source/helper')
-rw-r--r-- | xmlsecurity/source/helper/UriBindingHelper.cxx | 4 | ||||
-rw-r--r-- | xmlsecurity/source/helper/documentsignaturehelper.cxx | 108 | ||||
-rw-r--r-- | xmlsecurity/source/helper/documentsignaturemanager.cxx | 11 | ||||
-rw-r--r-- | xmlsecurity/source/helper/ooxmlsecexporter.cxx | 302 | ||||
-rw-r--r-- | xmlsecurity/source/helper/ooxmlsecparser.cxx | 32 | ||||
-rw-r--r-- | xmlsecurity/source/helper/pdfsignaturehelper.cxx | 14 | ||||
-rw-r--r-- | xmlsecurity/source/helper/xmlsignaturehelper.cxx | 26 | ||||
-rw-r--r-- | xmlsecurity/source/helper/xsecctl.cxx | 170 | ||||
-rw-r--r-- | xmlsecurity/source/helper/xsecparser.cxx | 40 | ||||
-rw-r--r-- | xmlsecurity/source/helper/xsecsign.cxx | 2 | ||||
-rw-r--r-- | xmlsecurity/source/helper/xsecverify.cxx | 2 |
11 files changed, 362 insertions, 349 deletions
diff --git a/xmlsecurity/source/helper/UriBindingHelper.cxx b/xmlsecurity/source/helper/UriBindingHelper.cxx index 9bd101934e47..52cf6d07a4fa 100644 --- a/xmlsecurity/source/helper/UriBindingHelper.cxx +++ b/xmlsecurity/source/helper/UriBindingHelper.cxx @@ -83,7 +83,7 @@ uno::Reference < io::XInputStream > UriBindingHelper::OpenInputStream( const uno const OUString sName = ::rtl::Uri::decode( aURI, rtl_UriDecodeStrict, rtl_UriCharClassRelSegment); if (sName.isEmpty() && !aURI.isEmpty()) - throw uno::Exception("Could not decode URI for stream element.", nullptr); + throw uno::Exception(u"Could not decode URI for stream element."_ustr, nullptr); uno::Reference< io::XStream > xStream; if (!rxStore->hasByName(sName)) @@ -99,7 +99,7 @@ uno::Reference < io::XInputStream > UriBindingHelper::OpenInputStream( const uno const OUString aStoreName = ::rtl::Uri::decode( aURI.copy( 0, nSepPos ), rtl_UriDecodeStrict, rtl_UriCharClassRelSegment); if (aStoreName.isEmpty() && !aURI.isEmpty()) - throw uno::Exception("Could not decode URI for stream element.", nullptr); + throw uno::Exception(u"Could not decode URI for stream element."_ustr, nullptr); OUString aElement = aURI.copy( nSepPos+1 ); uno::Reference < embed::XStorage > xSubStore = rxStore->openStorageElement( aStoreName, embed::ElementModes::READ ); diff --git a/xmlsecurity/source/helper/documentsignaturehelper.cxx b/xmlsecurity/source/helper/documentsignaturehelper.cxx index 8e666b14ba6e..b35c709915f4 100644 --- a/xmlsecurity/source/helper/documentsignaturehelper.cxx +++ b/xmlsecurity/source/helper/documentsignaturehelper.cxx @@ -109,7 +109,7 @@ static void ImplFillElementList( rName, rtl_UriCharClassRelSegment, rtl_UriEncodeStrict, RTL_TEXTENCODING_UTF8); if (sEncName.isEmpty() && !rName.isEmpty()) - throw css::uno::RuntimeException("Failed to encode element name of XStorage", nullptr); + throw css::uno::RuntimeException(u"Failed to encode element name of XStorage"_ustr, nullptr); if ( rxStore->isStreamElement( rName ) ) { @@ -184,7 +184,7 @@ DocumentSignatureHelper::CreateElementList( const DocumentSignatureAlgorithm mode) { std::vector< OUString > aElements; - OUString aSep( "/" ); + OUString aSep( u"/"_ustr ); switch ( eMode ) { @@ -196,7 +196,7 @@ DocumentSignatureHelper::CreateElementList( ImplFillElementList(aElements, rxStore, std::u16string_view(), false, mode); // 2) Pictures... - OUString aSubStorageName( "Pictures" ); + OUString aSubStorageName( u"Pictures"_ustr ); try { Reference < css::embed::XStorage > xSubStore = rxStore->openStorageElement( aSubStorageName, css::embed::ElementModes::READ ); @@ -243,7 +243,7 @@ DocumentSignatureHelper::CreateElementList( case DocumentSignatureMode::Macros: { // 1) Macros - OUString aSubStorageName( "Basic" ); + OUString aSubStorageName( u"Basic"_ustr ); try { Reference < css::embed::XStorage > xSubStore = rxStore->openStorageElement( aSubStorageName, css::embed::ElementModes::READ ); @@ -294,11 +294,11 @@ DocumentSignatureHelper::CreateElementList( void DocumentSignatureHelper::AppendContentTypes(const uno::Reference<embed::XStorage>& xStorage, std::vector<OUString>& rElements) { - if (!xStorage.is() || !xStorage->hasByName("[Content_Types].xml")) + if (!xStorage.is() || !xStorage->hasByName(u"[Content_Types].xml"_ustr)) // ODF return; - uno::Reference<io::XInputStream> xRelStream(xStorage->openStreamElement("[Content_Types].xml", embed::ElementModes::READ), uno::UNO_QUERY); + uno::Reference<io::XInputStream> xRelStream(xStorage->openStreamElement(u"[Content_Types].xml"_ustr, embed::ElementModes::READ), uno::UNO_QUERY); uno::Sequence< uno::Sequence<beans::StringPair> > aContentTypeInfo = comphelper::OFOPXMLHelper::ReadContentTypeSequence(xRelStream, comphelper::getProcessComponentContext()); if (aContentTypeInfo.getLength() < 2) { @@ -349,11 +349,11 @@ SignatureStreamHelper DocumentSignatureHelper::OpenSignatureStream( if (!rxStore.is()) return aHelper; - if (rxStore->hasByName("META-INF")) + if (rxStore->hasByName(u"META-INF"_ustr)) { try { - aHelper.xSignatureStorage = rxStore->openStorageElement( "META-INF", nSubStorageOpenMode ); + aHelper.xSignatureStorage = rxStore->openStorageElement( u"META-INF"_ustr, nSubStorageOpenMode ); if ( aHelper.xSignatureStorage.is() ) { OUString aSIGStreamName; @@ -376,7 +376,7 @@ SignatureStreamHelper DocumentSignatureHelper::OpenSignatureStream( uno::UNO_QUERY); sal_Int64 nSize = 0; uno::Reference<beans::XPropertySet> xPropertySet(xInputStream, uno::UNO_QUERY); - xPropertySet->getPropertyValue("Size") >>= nSize; + xPropertySet->getPropertyValue(u"Size"_ustr) >>= nSize; if (nSize >= 0 || nSize < SAL_MAX_INT32) { uno::Sequence<sal_Int8> aData; @@ -400,15 +400,15 @@ SignatureStreamHelper DocumentSignatureHelper::OpenSignatureStream( SAL_WARN_IF( nOpenMode != css::embed::ElementModes::READ, "xmlsecurity.helper", "Error creating signature stream..." ); } } - else if(rxStore->hasByName("[Content_Types].xml")) + else if(rxStore->hasByName(u"[Content_Types].xml"_ustr)) { try { - if (rxStore->hasByName("_xmlsignatures") && (nOpenMode & embed::ElementModes::TRUNCATE)) + if (rxStore->hasByName(u"_xmlsignatures"_ustr) && (nOpenMode & embed::ElementModes::TRUNCATE)) // Truncate, then all signatures will be written -> remove previous ones. - rxStore->removeElement("_xmlsignatures"); + rxStore->removeElement(u"_xmlsignatures"_ustr); - aHelper.xSignatureStorage = rxStore->openStorageElement("_xmlsignatures", nSubStorageOpenMode); + aHelper.xSignatureStorage = rxStore->openStorageElement(u"_xmlsignatures"_ustr, nSubStorageOpenMode); aHelper.nStorageFormat = embed::StorageFormats::OFOPXML; } catch (const io::IOException&) @@ -428,7 +428,7 @@ bool DocumentSignatureHelper::CanSignWithGPG( if (!rxStore.is()) return false; - if (rxStore->hasByName("META-INF")) // ODF + if (rxStore->hasByName(u"META-INF"_ustr)) // ODF { return !isODFPre_1_2(sOdfVersion); } @@ -505,49 +505,49 @@ bool DocumentSignatureHelper::equalsReferenceUriManifestPath( OUString DocumentSignatureHelper::GetDocumentContentSignatureDefaultStreamName() { - return "documentsignatures.xml"; + return u"documentsignatures.xml"_ustr; } OUString DocumentSignatureHelper::GetScriptingContentSignatureDefaultStreamName() { - return "macrosignatures.xml"; + return u"macrosignatures.xml"_ustr; } OUString DocumentSignatureHelper::GetPackageSignatureDefaultStreamName() { - return "packagesignatures.xml"; + return u"packagesignatures.xml"_ustr; } void DocumentSignatureHelper::writeDigestMethod( const uno::Reference<xml::sax::XDocumentHandler>& xDocumentHandler) { rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); - pAttributeList->AddAttribute("Algorithm", ALGO_XMLDSIGSHA256); - xDocumentHandler->startElement("DigestMethod", uno::Reference<xml::sax::XAttributeList>(pAttributeList)); - xDocumentHandler->endElement("DigestMethod"); + pAttributeList->AddAttribute(u"Algorithm"_ustr, ALGO_XMLDSIGSHA256); + xDocumentHandler->startElement(u"DigestMethod"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); + xDocumentHandler->endElement(u"DigestMethod"_ustr); } static void WriteXadesCert( uno::Reference<xml::sax::XDocumentHandler> const& xDocumentHandler, SignatureInformation::X509CertInfo const& rCertInfo) { - xDocumentHandler->startElement("xd:Cert", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); - xDocumentHandler->startElement("xd:CertDigest", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + xDocumentHandler->startElement(u"xd:Cert"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + xDocumentHandler->startElement(u"xd:CertDigest"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); DocumentSignatureHelper::writeDigestMethod(xDocumentHandler); - xDocumentHandler->startElement("DigestValue", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + xDocumentHandler->startElement(u"DigestValue"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); assert(!rCertInfo.CertDigest.isEmpty()); xDocumentHandler->characters(rCertInfo.CertDigest); - xDocumentHandler->endElement("DigestValue"); - xDocumentHandler->endElement("xd:CertDigest"); - xDocumentHandler->startElement("xd:IssuerSerial", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); - xDocumentHandler->startElement("X509IssuerName", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + xDocumentHandler->endElement(u"DigestValue"_ustr); + xDocumentHandler->endElement(u"xd:CertDigest"_ustr); + xDocumentHandler->startElement(u"xd:IssuerSerial"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + xDocumentHandler->startElement(u"X509IssuerName"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); xDocumentHandler->characters(rCertInfo.X509IssuerName); - xDocumentHandler->endElement("X509IssuerName"); - xDocumentHandler->startElement("X509SerialNumber", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + xDocumentHandler->endElement(u"X509IssuerName"_ustr); + xDocumentHandler->startElement(u"X509SerialNumber"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); xDocumentHandler->characters(rCertInfo.X509SerialNumber); - xDocumentHandler->endElement("X509SerialNumber"); - xDocumentHandler->endElement("xd:IssuerSerial"); - xDocumentHandler->endElement("xd:Cert"); + xDocumentHandler->endElement(u"X509SerialNumber"_ustr); + xDocumentHandler->endElement(u"xd:IssuerSerial"_ustr); + xDocumentHandler->endElement(u"xd:Cert"_ustr); } void DocumentSignatureHelper::writeSignedProperties( @@ -557,15 +557,15 @@ void DocumentSignatureHelper::writeSignedProperties( { { rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); - pAttributeList->AddAttribute("Id", "idSignedProperties_" + signatureInfo.ouSignatureId); - xDocumentHandler->startElement("xd:SignedProperties", uno::Reference<xml::sax::XAttributeList>(pAttributeList)); + pAttributeList->AddAttribute(u"Id"_ustr, "idSignedProperties_" + signatureInfo.ouSignatureId); + xDocumentHandler->startElement(u"xd:SignedProperties"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); } - xDocumentHandler->startElement("xd:SignedSignatureProperties", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); - xDocumentHandler->startElement("xd:SigningTime", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + xDocumentHandler->startElement(u"xd:SignedSignatureProperties"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + xDocumentHandler->startElement(u"xd:SigningTime"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); xDocumentHandler->characters(sDate); - xDocumentHandler->endElement("xd:SigningTime"); - xDocumentHandler->startElement("xd:SigningCertificate", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + xDocumentHandler->endElement(u"xd:SigningTime"_ustr); + xDocumentHandler->startElement(u"xd:SigningCertificate"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); assert(signatureInfo.GetSigningCertificate() || !signatureInfo.ouGpgKeyID.isEmpty()); if (signatureInfo.GetSigningCertificate()) { @@ -586,35 +586,35 @@ void DocumentSignatureHelper::writeSignedProperties( temp.CertDigest = signatureInfo.ouGpgKeyID; WriteXadesCert(xDocumentHandler, temp); } - xDocumentHandler->endElement("xd:SigningCertificate"); - xDocumentHandler->startElement("xd:SignaturePolicyIdentifier", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); - xDocumentHandler->startElement("xd:SignaturePolicyImplied", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); - xDocumentHandler->endElement("xd:SignaturePolicyImplied"); - xDocumentHandler->endElement("xd:SignaturePolicyIdentifier"); + xDocumentHandler->endElement(u"xd:SigningCertificate"_ustr); + xDocumentHandler->startElement(u"xd:SignaturePolicyIdentifier"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + xDocumentHandler->startElement(u"xd:SignaturePolicyImplied"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + xDocumentHandler->endElement(u"xd:SignaturePolicyImplied"_ustr); + xDocumentHandler->endElement(u"xd:SignaturePolicyIdentifier"_ustr); if (bWriteSignatureLineData && !signatureInfo.ouSignatureLineId.isEmpty() && signatureInfo.aValidSignatureImage.is() && signatureInfo.aInvalidSignatureImage.is()) { rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); pAttributeList->AddAttribute( - "xmlns:loext", "urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"); + u"xmlns:loext"_ustr, u"urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"_ustr); xDocumentHandler->startElement( - "loext:SignatureLine", + u"loext:SignatureLine"_ustr, Reference<XAttributeList>(pAttributeList)); { // Write SignatureLineId element xDocumentHandler->startElement( - "loext:SignatureLineId", + u"loext:SignatureLineId"_ustr, Reference<XAttributeList>(new comphelper::AttributeList())); xDocumentHandler->characters(signatureInfo.ouSignatureLineId); - xDocumentHandler->endElement("loext:SignatureLineId"); + xDocumentHandler->endElement(u"loext:SignatureLineId"_ustr); } { // Write SignatureLineValidImage element xDocumentHandler->startElement( - "loext:SignatureLineValidImage", + u"loext:SignatureLineValidImage"_ustr, Reference<XAttributeList>(new comphelper::AttributeList())); OUString aGraphicInBase64; @@ -623,28 +623,28 @@ void DocumentSignatureHelper::writeSignedProperties( SAL_WARN("xmlsecurity.helper", "could not convert graphic to base64"); xDocumentHandler->characters(aGraphicInBase64); - xDocumentHandler->endElement("loext:SignatureLineValidImage"); + xDocumentHandler->endElement(u"loext:SignatureLineValidImage"_ustr); } { // Write SignatureLineInvalidImage element xDocumentHandler->startElement( - "loext:SignatureLineInvalidImage", + u"loext:SignatureLineInvalidImage"_ustr, Reference<XAttributeList>(new comphelper::AttributeList())); OUString aGraphicInBase64; Graphic aGraphic(signatureInfo.aInvalidSignatureImage); if (!XOutBitmap::GraphicToBase64(aGraphic, aGraphicInBase64, false)) SAL_WARN("xmlsecurity.helper", "could not convert graphic to base64"); xDocumentHandler->characters(aGraphicInBase64); - xDocumentHandler->endElement("loext:SignatureLineInvalidImage"); + xDocumentHandler->endElement(u"loext:SignatureLineInvalidImage"_ustr); } - xDocumentHandler->endElement("loext:SignatureLine"); + xDocumentHandler->endElement(u"loext:SignatureLine"_ustr); } - xDocumentHandler->endElement("xd:SignedSignatureProperties"); + xDocumentHandler->endElement(u"xd:SignedSignatureProperties"_ustr); - xDocumentHandler->endElement("xd:SignedProperties"); + xDocumentHandler->endElement(u"xd:SignedProperties"_ustr); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlsecurity/source/helper/documentsignaturemanager.cxx b/xmlsecurity/source/helper/documentsignaturemanager.cxx index 84d89ffeff72..620c85458afe 100644 --- a/xmlsecurity/source/helper/documentsignaturemanager.cxx +++ b/xmlsecurity/source/helper/documentsignaturemanager.cxx @@ -147,14 +147,15 @@ bool DocumentSignatureManager::readManifest() uno::Reference<packages::manifest::XManifestReader> xReader = packages::manifest::ManifestReader::create(mxContext); - if (mxStore->hasByName("META-INF")) + if (mxStore->hasByName(u"META-INF"_ustr)) { //Get the manifest.xml uno::Reference<embed::XStorage> xSubStore( - mxStore->openStorageElement("META-INF", embed::ElementModes::READ), UNO_SET_THROW); + mxStore->openStorageElement(u"META-INF"_ustr, embed::ElementModes::READ), + UNO_SET_THROW); uno::Reference<io::XInputStream> xStream( - xSubStore->openStreamElement("manifest.xml", css::embed::ElementModes::READ), + xSubStore->openStreamElement(u"manifest.xml"_ustr, css::embed::ElementModes::READ), UNO_QUERY_THROW); m_manifest = xReader->readManifestSequence(xStream); @@ -229,7 +230,7 @@ SignatureStreamHelper DocumentSignatureManager::ImplOpenSignatureStream(sal_Int3 bool bTempStream) { SignatureStreamHelper aHelper; - if (mxStore.is() && mxStore->hasByName("[Content_Types].xml")) + if (mxStore.is() && mxStore->hasByName(u"[Content_Types].xml"_ustr)) aHelper.nStorageFormat = embed::StorageFormats::OFOPXML; if (bTempStream) @@ -655,7 +656,7 @@ void DocumentSignatureManager::write(bool bXAdESCompliantIfODF) maSignatureHelper.EnsureSignaturesRelation(mxStore, /*bAdd=*/false); // Also remove the whole signature sub-storage: release our read-write reference + remove the element. aStreamHelper = SignatureStreamHelper(); - mxStore->removeElement("_xmlsignatures"); + mxStore->removeElement(u"_xmlsignatures"_ustr); } for (std::size_t i = 0; i < nSignatureCount; ++i) diff --git a/xmlsecurity/source/helper/ooxmlsecexporter.cxx b/xmlsecurity/source/helper/ooxmlsecexporter.cxx index 804cfd274802..874fc4079c28 100644 --- a/xmlsecurity/source/helper/ooxmlsecexporter.cxx +++ b/xmlsecurity/source/helper/ooxmlsecexporter.cxx @@ -112,32 +112,32 @@ bool OOXMLSecExporter::Impl::isOOXMLRelationDenylist(const OUString& rRelationNa void OOXMLSecExporter::Impl::writeSignedInfo() { - m_xDocumentHandler->startElement( - "SignedInfo", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + m_xDocumentHandler->startElement(u"SignedInfo"_ustr, uno::Reference<xml::sax::XAttributeList>( + new comphelper::AttributeList())); writeCanonicalizationMethod(); writeSignatureMethod(); writeSignedInfoReferences(); - m_xDocumentHandler->endElement("SignedInfo"); + m_xDocumentHandler->endElement(u"SignedInfo"_ustr); } void OOXMLSecExporter::Impl::writeCanonicalizationMethod() { rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); - pAttributeList->AddAttribute("Algorithm", ALGO_C14N); - m_xDocumentHandler->startElement("CanonicalizationMethod", + pAttributeList->AddAttribute(u"Algorithm"_ustr, ALGO_C14N); + m_xDocumentHandler->startElement(u"CanonicalizationMethod"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); - m_xDocumentHandler->endElement("CanonicalizationMethod"); + m_xDocumentHandler->endElement(u"CanonicalizationMethod"_ustr); } void OOXMLSecExporter::Impl::writeCanonicalizationTransform() { rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); - pAttributeList->AddAttribute("Algorithm", ALGO_C14N); - m_xDocumentHandler->startElement("Transform", + pAttributeList->AddAttribute(u"Algorithm"_ustr, ALGO_C14N); + m_xDocumentHandler->startElement(u"Transform"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); - m_xDocumentHandler->endElement("Transform"); + m_xDocumentHandler->endElement(u"Transform"_ustr); } void OOXMLSecExporter::Impl::writeSignatureMethod() @@ -145,13 +145,13 @@ void OOXMLSecExporter::Impl::writeSignatureMethod() rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); if (m_rInformation.eAlgorithmID == svl::crypto::SignatureMethodAlgorithm::ECDSA) - pAttributeList->AddAttribute("Algorithm", ALGO_ECDSASHA256); + pAttributeList->AddAttribute(u"Algorithm"_ustr, ALGO_ECDSASHA256); else - pAttributeList->AddAttribute("Algorithm", ALGO_RSASHA256); + pAttributeList->AddAttribute(u"Algorithm"_ustr, ALGO_RSASHA256); - m_xDocumentHandler->startElement("SignatureMethod", + m_xDocumentHandler->startElement(u"SignatureMethod"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); - m_xDocumentHandler->endElement("SignatureMethod"); + m_xDocumentHandler->endElement(u"SignatureMethod"_ustr); } void OOXMLSecExporter::Impl::writeSignedInfoReferences() @@ -165,82 +165,83 @@ void OOXMLSecExporter::Impl::writeSignedInfoReferences() rtl::Reference<comphelper::AttributeList> pAttributeList( new comphelper::AttributeList()); if (!rReference.ouURI.startsWith("idSignedProperties")) - pAttributeList->AddAttribute("Type", - "http://www.w3.org/2000/09/xmldsig#Object"); + pAttributeList->AddAttribute(u"Type"_ustr, + u"http://www.w3.org/2000/09/xmldsig#Object"_ustr); else - pAttributeList->AddAttribute("Type", - "http://uri.etsi.org/01903#SignedProperties"); - pAttributeList->AddAttribute("URI", "#" + rReference.ouURI); + pAttributeList->AddAttribute( + u"Type"_ustr, u"http://uri.etsi.org/01903#SignedProperties"_ustr); + pAttributeList->AddAttribute(u"URI"_ustr, "#" + rReference.ouURI); m_xDocumentHandler->startElement( - "Reference", uno::Reference<xml::sax::XAttributeList>(pAttributeList)); + u"Reference"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); } if (rReference.ouURI.startsWith("idSignedProperties")) { m_xDocumentHandler->startElement( - "Transforms", + u"Transforms"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); writeCanonicalizationTransform(); - m_xDocumentHandler->endElement("Transforms"); + m_xDocumentHandler->endElement(u"Transforms"_ustr); } DocumentSignatureHelper::writeDigestMethod(m_xDocumentHandler); m_xDocumentHandler->startElement( - "DigestValue", + u"DigestValue"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); m_xDocumentHandler->characters(rReference.ouDigestValue); - m_xDocumentHandler->endElement("DigestValue"); - m_xDocumentHandler->endElement("Reference"); + m_xDocumentHandler->endElement(u"DigestValue"_ustr); + m_xDocumentHandler->endElement(u"Reference"_ustr); } } } void OOXMLSecExporter::Impl::writeSignatureValue() { - m_xDocumentHandler->startElement("SignatureValue", uno::Reference<xml::sax::XAttributeList>( - new comphelper::AttributeList())); + m_xDocumentHandler->startElement( + u"SignatureValue"_ustr, + uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); m_xDocumentHandler->characters(m_rInformation.ouSignatureValue); - m_xDocumentHandler->endElement("SignatureValue"); + m_xDocumentHandler->endElement(u"SignatureValue"_ustr); } void OOXMLSecExporter::Impl::writeKeyInfo() { m_xDocumentHandler->startElement( - "KeyInfo", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + u"KeyInfo"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); assert(m_rInformation.GetSigningCertificate()); for (auto const& rData : m_rInformation.X509Datas) { - m_xDocumentHandler->startElement( - "X509Data", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + m_xDocumentHandler->startElement(u"X509Data"_ustr, uno::Reference<xml::sax::XAttributeList>( + new comphelper::AttributeList())); for (auto const& it : rData) { m_xDocumentHandler->startElement( - "X509Certificate", + u"X509Certificate"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); m_xDocumentHandler->characters(it.X509Certificate); - m_xDocumentHandler->endElement("X509Certificate"); + m_xDocumentHandler->endElement(u"X509Certificate"_ustr); } - m_xDocumentHandler->endElement("X509Data"); + m_xDocumentHandler->endElement(u"X509Data"_ustr); } - m_xDocumentHandler->endElement("KeyInfo"); + m_xDocumentHandler->endElement(u"KeyInfo"_ustr); } void OOXMLSecExporter::Impl::writePackageObject() { rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); - pAttributeList->AddAttribute("Id", "idPackageObject_" + m_rInformation.ouSignatureId); - m_xDocumentHandler->startElement("Object", + pAttributeList->AddAttribute(u"Id"_ustr, "idPackageObject_" + m_rInformation.ouSignatureId); + m_xDocumentHandler->startElement(u"Object"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); writeManifest(); writePackageObjectSignatureProperties(); - m_xDocumentHandler->endElement("Object"); + m_xDocumentHandler->endElement(u"Object"_ustr); } void OOXMLSecExporter::Impl::writeManifest() { - m_xDocumentHandler->startElement( - "Manifest", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + m_xDocumentHandler->startElement(u"Manifest"_ustr, uno::Reference<xml::sax::XAttributeList>( + new comphelper::AttributeList())); const SignatureReferenceInformations& rReferences = m_rInformation.vSignatureReferenceInfors; for (const SignatureReferenceInformation& rReference : rReferences) { @@ -252,7 +253,7 @@ void OOXMLSecExporter::Impl::writeManifest() writeManifestReference(rReference); } } - m_xDocumentHandler->endElement("Manifest"); + m_xDocumentHandler->endElement(u"Manifest"_ustr); } void OOXMLSecExporter::Impl::writeRelationshipTransform(const OUString& rURI) @@ -265,8 +266,8 @@ void OOXMLSecExporter::Impl::writeRelationshipTransform(const OUString& rURI) uno::UNO_QUERY); { rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); - pAttributeList->AddAttribute("Algorithm", ALGO_RELATIONSHIP); - m_xDocumentHandler->startElement("Transform", + pAttributeList->AddAttribute(u"Algorithm"_ustr, ALGO_RELATIONSHIP); + m_xDocumentHandler->startElement(u"Transform"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); } @@ -289,41 +290,41 @@ void OOXMLSecExporter::Impl::writeRelationshipTransform(const OUString& rURI) continue; rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); - pAttributeList->AddAttribute("xmlns:mdssi", NS_MDSSI); - pAttributeList->AddAttribute("SourceId", aId); - m_xDocumentHandler->startElement("mdssi:RelationshipReference", + pAttributeList->AddAttribute(u"xmlns:mdssi"_ustr, NS_MDSSI); + pAttributeList->AddAttribute(u"SourceId"_ustr, aId); + m_xDocumentHandler->startElement(u"mdssi:RelationshipReference"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); - m_xDocumentHandler->endElement("mdssi:RelationshipReference"); + m_xDocumentHandler->endElement(u"mdssi:RelationshipReference"_ustr); } - m_xDocumentHandler->endElement("Transform"); + m_xDocumentHandler->endElement(u"Transform"_ustr); } void OOXMLSecExporter::Impl::writePackageObjectSignatureProperties() { m_xDocumentHandler->startElement( - "SignatureProperties", + u"SignatureProperties"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); { rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); - pAttributeList->AddAttribute("Id", "idSignatureTime_" + m_rInformation.ouSignatureId); - pAttributeList->AddAttribute("Target", "#" + m_rInformation.ouSignatureId); - m_xDocumentHandler->startElement("SignatureProperty", + pAttributeList->AddAttribute(u"Id"_ustr, "idSignatureTime_" + m_rInformation.ouSignatureId); + pAttributeList->AddAttribute(u"Target"_ustr, "#" + m_rInformation.ouSignatureId); + m_xDocumentHandler->startElement(u"SignatureProperty"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); } { rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); - pAttributeList->AddAttribute("xmlns:mdssi", NS_MDSSI); - m_xDocumentHandler->startElement("mdssi:SignatureTime", + pAttributeList->AddAttribute(u"xmlns:mdssi"_ustr, NS_MDSSI); + m_xDocumentHandler->startElement(u"mdssi:SignatureTime"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); } - m_xDocumentHandler->startElement( - "mdssi:Format", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); - m_xDocumentHandler->characters("YYYY-MM-DDThh:mm:ssTZD"); - m_xDocumentHandler->endElement("mdssi:Format"); + m_xDocumentHandler->startElement(u"mdssi:Format"_ustr, uno::Reference<xml::sax::XAttributeList>( + new comphelper::AttributeList())); + m_xDocumentHandler->characters(u"YYYY-MM-DDThh:mm:ssTZD"_ustr); + m_xDocumentHandler->endElement(u"mdssi:Format"_ustr); - m_xDocumentHandler->startElement( - "mdssi:Value", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + m_xDocumentHandler->startElement(u"mdssi:Value"_ustr, uno::Reference<xml::sax::XAttributeList>( + new comphelper::AttributeList())); if (!m_rInformation.ouDateTime.isEmpty()) m_aSignatureTimeValue = m_rInformation.ouDateTime; else @@ -338,18 +339,18 @@ void OOXMLSecExporter::Impl::writePackageObjectSignatureProperties() } } m_xDocumentHandler->characters(m_aSignatureTimeValue); - m_xDocumentHandler->endElement("mdssi:Value"); + m_xDocumentHandler->endElement(u"mdssi:Value"_ustr); - m_xDocumentHandler->endElement("mdssi:SignatureTime"); - m_xDocumentHandler->endElement("SignatureProperty"); - m_xDocumentHandler->endElement("SignatureProperties"); + m_xDocumentHandler->endElement(u"mdssi:SignatureTime"_ustr); + m_xDocumentHandler->endElement(u"SignatureProperty"_ustr); + m_xDocumentHandler->endElement(u"SignatureProperties"_ustr); } void OOXMLSecExporter::Impl::writeManifestReference(const SignatureReferenceInformation& rReference) { rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); - pAttributeList->AddAttribute("URI", rReference.ouURI); - m_xDocumentHandler->startElement("Reference", + pAttributeList->AddAttribute(u"URI"_ustr, rReference.ouURI); + m_xDocumentHandler->startElement(u"Reference"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); // Transforms @@ -365,138 +366,149 @@ void OOXMLSecExporter::Impl::writeManifestReference(const SignatureReferenceInfo if (nQueryPos != -1) aURI = aURI.copy(0, nQueryPos); - m_xDocumentHandler->startElement("Transforms", uno::Reference<xml::sax::XAttributeList>( - new comphelper::AttributeList())); + m_xDocumentHandler->startElement( + u"Transforms"_ustr, + uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); writeRelationshipTransform(aURI); writeCanonicalizationTransform(); - m_xDocumentHandler->endElement("Transforms"); + m_xDocumentHandler->endElement(u"Transforms"_ustr); } DocumentSignatureHelper::writeDigestMethod(m_xDocumentHandler); - m_xDocumentHandler->startElement( - "DigestValue", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + m_xDocumentHandler->startElement(u"DigestValue"_ustr, uno::Reference<xml::sax::XAttributeList>( + new comphelper::AttributeList())); m_xDocumentHandler->characters(rReference.ouDigestValue); - m_xDocumentHandler->endElement("DigestValue"); - m_xDocumentHandler->endElement("Reference"); + m_xDocumentHandler->endElement(u"DigestValue"_ustr); + m_xDocumentHandler->endElement(u"Reference"_ustr); } void OOXMLSecExporter::Impl::writeOfficeObject() { { rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); - pAttributeList->AddAttribute("Id", "idOfficeObject_" + m_rInformation.ouSignatureId); - m_xDocumentHandler->startElement("Object", + pAttributeList->AddAttribute(u"Id"_ustr, "idOfficeObject_" + m_rInformation.ouSignatureId); + m_xDocumentHandler->startElement(u"Object"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); } m_xDocumentHandler->startElement( - "SignatureProperties", + u"SignatureProperties"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); { rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); - pAttributeList->AddAttribute("Id", "idOfficeV1Details_" + m_rInformation.ouSignatureId); - pAttributeList->AddAttribute("Target", "#" + m_rInformation.ouSignatureId); - m_xDocumentHandler->startElement("SignatureProperty", + pAttributeList->AddAttribute(u"Id"_ustr, + "idOfficeV1Details_" + m_rInformation.ouSignatureId); + pAttributeList->AddAttribute(u"Target"_ustr, "#" + m_rInformation.ouSignatureId); + m_xDocumentHandler->startElement(u"SignatureProperty"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); } writeSignatureInfo(); - m_xDocumentHandler->endElement("SignatureProperty"); - m_xDocumentHandler->endElement("SignatureProperties"); - m_xDocumentHandler->endElement("Object"); + m_xDocumentHandler->endElement(u"SignatureProperty"_ustr); + m_xDocumentHandler->endElement(u"SignatureProperties"_ustr); + m_xDocumentHandler->endElement(u"Object"_ustr); } void OOXMLSecExporter::Impl::writeSignatureInfo() { rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); - pAttributeList->AddAttribute("xmlns", "http://schemas.microsoft.com/office/2006/digsig"); - m_xDocumentHandler->startElement("SignatureInfoV1", + pAttributeList->AddAttribute(u"xmlns"_ustr, + u"http://schemas.microsoft.com/office/2006/digsig"_ustr); + m_xDocumentHandler->startElement(u"SignatureInfoV1"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); m_xDocumentHandler->startElement( - "SetupID", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + u"SetupID"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); m_xDocumentHandler->characters(m_rInformation.ouSignatureLineId); - m_xDocumentHandler->endElement("SetupID"); + m_xDocumentHandler->endElement(u"SetupID"_ustr); m_xDocumentHandler->startElement( - "SignatureText", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); - m_xDocumentHandler->endElement("SignatureText"); - m_xDocumentHandler->startElement("SignatureImage", uno::Reference<xml::sax::XAttributeList>( - new comphelper::AttributeList())); - m_xDocumentHandler->endElement("SignatureImage"); - m_xDocumentHandler->startElement("SignatureComments", uno::Reference<xml::sax::XAttributeList>( - new comphelper::AttributeList())); + u"SignatureText"_ustr, + uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + m_xDocumentHandler->endElement(u"SignatureText"_ustr); + m_xDocumentHandler->startElement( + u"SignatureImage"_ustr, + uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + m_xDocumentHandler->endElement(u"SignatureImage"_ustr); + m_xDocumentHandler->startElement( + u"SignatureComments"_ustr, + uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); m_xDocumentHandler->characters(m_rInformation.ouDescription); - m_xDocumentHandler->endElement("SignatureComments"); + m_xDocumentHandler->endElement(u"SignatureComments"_ustr); // Just hardcode something valid according to [MS-OFFCRYPTO]. - m_xDocumentHandler->startElement("WindowsVersion", uno::Reference<xml::sax::XAttributeList>( - new comphelper::AttributeList())); - m_xDocumentHandler->characters("6.1"); - m_xDocumentHandler->endElement("WindowsVersion"); m_xDocumentHandler->startElement( - "OfficeVersion", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); - m_xDocumentHandler->characters("16.0"); - m_xDocumentHandler->endElement("OfficeVersion"); - m_xDocumentHandler->startElement("ApplicationVersion", uno::Reference<xml::sax::XAttributeList>( - new comphelper::AttributeList())); - m_xDocumentHandler->characters("16.0"); - m_xDocumentHandler->endElement("ApplicationVersion"); + u"WindowsVersion"_ustr, + uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + m_xDocumentHandler->characters(u"6.1"_ustr); + m_xDocumentHandler->endElement(u"WindowsVersion"_ustr); m_xDocumentHandler->startElement( - "Monitors", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); - m_xDocumentHandler->characters("1"); - m_xDocumentHandler->endElement("Monitors"); + u"OfficeVersion"_ustr, + uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + m_xDocumentHandler->characters(u"16.0"_ustr); + m_xDocumentHandler->endElement(u"OfficeVersion"_ustr); m_xDocumentHandler->startElement( - "HorizontalResolution", + u"ApplicationVersion"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); - m_xDocumentHandler->characters("1280"); - m_xDocumentHandler->endElement("HorizontalResolution"); - m_xDocumentHandler->startElement("VerticalResolution", uno::Reference<xml::sax::XAttributeList>( - new comphelper::AttributeList())); - m_xDocumentHandler->characters("800"); - m_xDocumentHandler->endElement("VerticalResolution"); + m_xDocumentHandler->characters(u"16.0"_ustr); + m_xDocumentHandler->endElement(u"ApplicationVersion"_ustr); + m_xDocumentHandler->startElement(u"Monitors"_ustr, uno::Reference<xml::sax::XAttributeList>( + new comphelper::AttributeList())); + m_xDocumentHandler->characters(u"1"_ustr); + m_xDocumentHandler->endElement(u"Monitors"_ustr); m_xDocumentHandler->startElement( - "ColorDepth", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); - m_xDocumentHandler->characters("32"); - m_xDocumentHandler->endElement("ColorDepth"); + u"HorizontalResolution"_ustr, + uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + m_xDocumentHandler->characters(u"1280"_ustr); + m_xDocumentHandler->endElement(u"HorizontalResolution"_ustr); + m_xDocumentHandler->startElement( + u"VerticalResolution"_ustr, + uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + m_xDocumentHandler->characters(u"800"_ustr); + m_xDocumentHandler->endElement(u"VerticalResolution"_ustr); + m_xDocumentHandler->startElement(u"ColorDepth"_ustr, uno::Reference<xml::sax::XAttributeList>( + new comphelper::AttributeList())); + m_xDocumentHandler->characters(u"32"_ustr); + m_xDocumentHandler->endElement(u"ColorDepth"_ustr); m_xDocumentHandler->startElement( - "SignatureProviderId", + u"SignatureProviderId"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); - m_xDocumentHandler->characters("{00000000-0000-0000-0000-000000000000}"); - m_xDocumentHandler->endElement("SignatureProviderId"); + m_xDocumentHandler->characters(u"{00000000-0000-0000-0000-000000000000}"_ustr); + m_xDocumentHandler->endElement(u"SignatureProviderId"_ustr); m_xDocumentHandler->startElement( - "SignatureProviderUrl", + u"SignatureProviderUrl"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); - m_xDocumentHandler->endElement("SignatureProviderUrl"); + m_xDocumentHandler->endElement(u"SignatureProviderUrl"_ustr); m_xDocumentHandler->startElement( - "SignatureProviderDetails", + u"SignatureProviderDetails"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); m_xDocumentHandler->characters( - "9"); // This is what MSO 2016 writes, though [MS-OFFCRYPTO] doesn't document what the value means. - m_xDocumentHandler->endElement("SignatureProviderDetails"); + u"9"_ustr); // This is what MSO 2016 writes, though [MS-OFFCRYPTO] doesn't document what the value means. + m_xDocumentHandler->endElement(u"SignatureProviderDetails"_ustr); m_xDocumentHandler->startElement( - "SignatureType", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); - m_xDocumentHandler->characters("2"); - m_xDocumentHandler->endElement("SignatureType"); + u"SignatureType"_ustr, + uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + m_xDocumentHandler->characters(u"2"_ustr); + m_xDocumentHandler->endElement(u"SignatureType"_ustr); - m_xDocumentHandler->endElement("SignatureInfoV1"); + m_xDocumentHandler->endElement(u"SignatureInfoV1"_ustr); } void OOXMLSecExporter::Impl::writePackageSignature() { m_xDocumentHandler->startElement( - "Object", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + u"Object"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); { rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); - pAttributeList->AddAttribute("xmlns:xd", NS_XD); - pAttributeList->AddAttribute("Target", "#" + m_rInformation.ouSignatureId); - m_xDocumentHandler->startElement("xd:QualifyingProperties", + pAttributeList->AddAttribute(u"xmlns:xd"_ustr, NS_XD); + pAttributeList->AddAttribute(u"Target"_ustr, "#" + m_rInformation.ouSignatureId); + m_xDocumentHandler->startElement(u"xd:QualifyingProperties"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); } DocumentSignatureHelper::writeSignedProperties(m_xDocumentHandler, m_rInformation, m_aSignatureTimeValue, false); - m_xDocumentHandler->endElement("xd:QualifyingProperties"); - m_xDocumentHandler->endElement("Object"); + m_xDocumentHandler->endElement(u"xd:QualifyingProperties"_ustr); + m_xDocumentHandler->endElement(u"Object"_ustr); } void OOXMLSecExporter::Impl::writeSignatureLineImages() @@ -504,37 +516,37 @@ void OOXMLSecExporter::Impl::writeSignatureLineImages() if (m_rInformation.aValidSignatureImage.is()) { rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); - pAttributeList->AddAttribute("Id", "idValidSigLnImg"); - m_xDocumentHandler->startElement("Object", + pAttributeList->AddAttribute(u"Id"_ustr, u"idValidSigLnImg"_ustr); + m_xDocumentHandler->startElement(u"Object"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); OUString aGraphicInBase64; Graphic aGraphic(m_rInformation.aValidSignatureImage); if (!XOutBitmap::GraphicToBase64(aGraphic, aGraphicInBase64, false, ConvertDataFormat::EMF)) SAL_WARN("xmlsecurity.helper", "could not convert graphic to base64"); m_xDocumentHandler->characters(aGraphicInBase64); - m_xDocumentHandler->endElement("Object"); + m_xDocumentHandler->endElement(u"Object"_ustr); } if (!m_rInformation.aInvalidSignatureImage.is()) return; rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); - pAttributeList->AddAttribute("Id", "idInvalidSigLnImg"); - m_xDocumentHandler->startElement("Object", + pAttributeList->AddAttribute(u"Id"_ustr, u"idInvalidSigLnImg"_ustr); + m_xDocumentHandler->startElement(u"Object"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); OUString aGraphicInBase64; Graphic aGraphic(m_rInformation.aInvalidSignatureImage); if (!XOutBitmap::GraphicToBase64(aGraphic, aGraphicInBase64, false, ConvertDataFormat::EMF)) SAL_WARN("xmlsecurity.helper", "could not convert graphic to base64"); m_xDocumentHandler->characters(aGraphicInBase64); - m_xDocumentHandler->endElement("Object"); + m_xDocumentHandler->endElement(u"Object"_ustr); } void OOXMLSecExporter::Impl::writeSignature() { rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); - pAttributeList->AddAttribute("xmlns", NS_XMLDSIG); - pAttributeList->AddAttribute("Id", m_rInformation.ouSignatureId); - getDocumentHandler()->startElement("Signature", + pAttributeList->AddAttribute(u"xmlns"_ustr, NS_XMLDSIG); + pAttributeList->AddAttribute(u"Id"_ustr, m_rInformation.ouSignatureId); + getDocumentHandler()->startElement(u"Signature"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); writeSignedInfo(); @@ -545,7 +557,7 @@ void OOXMLSecExporter::Impl::writeSignature() writePackageSignature(); writeSignatureLineImages(); - getDocumentHandler()->endElement("Signature"); + getDocumentHandler()->endElement(u"Signature"_ustr); } OOXMLSecExporter::OOXMLSecExporter( diff --git a/xmlsecurity/source/helper/ooxmlsecparser.cxx b/xmlsecurity/source/helper/ooxmlsecparser.cxx index c75a8c6f4aa6..ff1802e02943 100644 --- a/xmlsecurity/source/helper/ooxmlsecparser.cxx +++ b/xmlsecurity/source/helper/ooxmlsecparser.cxx @@ -370,7 +370,7 @@ class OOXMLSecParser::DsDigestMethodContext virtual void StartElement( css::uno::Reference<css::xml::sax::XAttributeList> const& xAttrs) override { - OUString ouAlgorithm = xAttrs->getValueByName("Algorithm"); + OUString ouAlgorithm = xAttrs->getValueByName(u"Algorithm"_ustr); SAL_WARN_IF( ouAlgorithm.isEmpty(), "xmlsecurity.helper", "no Algorithm in Reference" ); if (ouAlgorithm.isEmpty()) @@ -409,7 +409,7 @@ class OOXMLSecParser::DsTransformContext virtual void StartElement( css::uno::Reference<css::xml::sax::XAttributeList> const& xAttrs) override { - OUString aAlgorithm = xAttrs->getValueByName("Algorithm"); + OUString aAlgorithm = xAttrs->getValueByName(u"Algorithm"_ustr); if (aAlgorithm == ALGO_RELATIONSHIP) { @@ -469,10 +469,10 @@ class OOXMLSecParser::DsReferenceContext { m_rParser.HandleIdAttr(xAttrs); - m_URI = xAttrs->getValueByName("URI"); + m_URI = xAttrs->getValueByName(u"URI"_ustr); SAL_WARN_IF(m_URI.isEmpty(), "xmlsecurity.helper", "URI is empty"); // Remember the type of this reference. - m_Type = xAttrs->getValueByName("Type"); + m_Type = xAttrs->getValueByName(u"Type"_ustr); } virtual void EndElement() override @@ -535,7 +535,7 @@ class OOXMLSecParser::DsSignatureMethodContext virtual void StartElement( css::uno::Reference<css::xml::sax::XAttributeList> const& xAttrs) override { - OUString ouAlgorithm = xAttrs->getValueByName("Algorithm"); + OUString ouAlgorithm = xAttrs->getValueByName(u"Algorithm"_ustr); if (ouAlgorithm == ALGO_ECDSASHA1 || ouAlgorithm == ALGO_ECDSASHA256 || ouAlgorithm == ALGO_ECDSASHA512) { @@ -701,7 +701,7 @@ class OOXMLSecParser::XadesSigningTimeContext { if (m_isReferenced) { - m_rParser.m_pXSecController->setDate("", m_Value); + m_rParser.m_pXSecController->setDate(u""_ustr, m_Value); } else { @@ -897,7 +897,7 @@ class OOXMLSecParser::MsodigsigSignatureInfoV1Context } if (!m_SignatureComments.isEmpty()) { - m_rParser.m_pXSecController->setDescription("", m_SignatureComments); + m_rParser.m_pXSecController->setDescription(u""_ustr, m_SignatureComments); } } @@ -1223,13 +1223,13 @@ OOXMLSecParser::OOXMLSecParser(XMLSignatureHelper& rXMLSignatureHelper, XSecCont { using namespace xmloff::token; m_pNamespaceMap->Add( GetXMLToken(XML_XML), GetXMLToken(XML_N_XML), XML_NAMESPACE_XML ); - m_pNamespaceMap->Add( "_ds", GetXMLToken(XML_N_DS), XML_NAMESPACE_DS ); - m_pNamespaceMap->Add( "_xades132", GetXMLToken(XML_N_XADES132), XML_NAMESPACE_XADES132); - m_pNamespaceMap->Add( "_xades141", GetXMLToken(XML_N_XADES141), XML_NAMESPACE_XADES141); - m_pNamespaceMap->Add( "_dc", GetXMLToken(XML_N_DC), XML_NAMESPACE_DC ); - m_pNamespaceMap->Add( "_mdssi", NS_MDSSI, XML_NAMESPACE_MDSSI ); - m_pNamespaceMap->Add( "_msodigsig", "http://schemas.microsoft.com/office/2006/digsig", XML_NAMESPACE_MSODIGSIG ); - m_pNamespaceMap->Add( "_office_libo", + m_pNamespaceMap->Add( u"_ds"_ustr, GetXMLToken(XML_N_DS), XML_NAMESPACE_DS ); + m_pNamespaceMap->Add( u"_xades132"_ustr, GetXMLToken(XML_N_XADES132), XML_NAMESPACE_XADES132); + m_pNamespaceMap->Add( u"_xades141"_ustr, GetXMLToken(XML_N_XADES141), XML_NAMESPACE_XADES141); + m_pNamespaceMap->Add( u"_dc"_ustr, GetXMLToken(XML_N_DC), XML_NAMESPACE_DC ); + m_pNamespaceMap->Add( u"_mdssi"_ustr, NS_MDSSI, XML_NAMESPACE_MDSSI ); + m_pNamespaceMap->Add( u"_msodigsig"_ustr, u"http://schemas.microsoft.com/office/2006/digsig"_ustr, XML_NAMESPACE_MSODIGSIG ); + m_pNamespaceMap->Add( u"_office_libo"_ustr, GetXMLToken(XML_N_LO_EXT), XML_NAMESPACE_LO_EXT); } @@ -1239,7 +1239,7 @@ OOXMLSecParser::~OOXMLSecParser() OUString OOXMLSecParser::HandleIdAttr(css::uno::Reference<css::xml::sax::XAttributeList> const& xAttrs) { - OUString const aId = xAttrs->getValueByName("Id"); + OUString const aId = xAttrs->getValueByName(u"Id"_ustr); if (!aId.isEmpty()) { m_pXSecController->collectToVerify(aId); @@ -1275,7 +1275,7 @@ void SAL_CALL OOXMLSecParser::startElement(const OUString& rName, const uno::Ref if (nPrefix != XML_NAMESPACE_DS || localName != "Signature") { throw css::xml::sax::SAXException( - "xmlsecurity: unexpected root element", nullptr, + u"xmlsecurity: unexpected root element"_ustr, nullptr, css::uno::Any()); } diff --git a/xmlsecurity/source/helper/pdfsignaturehelper.cxx b/xmlsecurity/source/helper/pdfsignaturehelper.cxx index 3c0084c8b4e2..d5f789bd6b65 100644 --- a/xmlsecurity/source/helper/pdfsignaturehelper.cxx +++ b/xmlsecurity/source/helper/pdfsignaturehelper.cxx @@ -53,7 +53,7 @@ bool GetSignatureLinePage(const uno::Reference<frame::XModel>& xModel, sal_Int32 return false; } - return xPage->getPropertyValue("Number") >>= rPage; + return xPage->getPropertyValue(u"Number"_ustr) >>= rPage; } /// If the currently selected shape is a Draw signature line, export that to PDF. @@ -82,8 +82,8 @@ void GetSignatureLineShape(const uno::Reference<frame::XModel>& xModel, sal_Int3 return; } - comphelper::SequenceAsHashMap aMap(xShapeProps->getPropertyValue("InteropGrabBag")); - auto it = aMap.find("SignatureCertificate"); + comphelper::SequenceAsHashMap aMap(xShapeProps->getPropertyValue(u"InteropGrabBag"_ustr)); + auto it = aMap.find(u"SignatureCertificate"_ustr); if (it == aMap.end()) { return; @@ -99,14 +99,14 @@ void GetSignatureLineShape(const uno::Reference<frame::XModel>& xModel, sal_Int3 // Export just the signature line. utl::MediaDescriptor aMediaDescriptor; - aMediaDescriptor["FilterName"] <<= OUString("draw_pdf_Export"); + aMediaDescriptor[u"FilterName"_ustr] <<= u"draw_pdf_Export"_ustr; SvMemoryStream aStream; uno::Reference<io::XOutputStream> xStream(new utl::OStreamWrapper(aStream)); - aMediaDescriptor["OutputStream"] <<= xStream; + aMediaDescriptor[u"OutputStream"_ustr] <<= xStream; uno::Sequence<beans::PropertyValue> aFilterData( comphelper::InitPropertySequence({ { "Selection", uno::Any(xShapes) } })); - aMediaDescriptor["FilterData"] <<= aFilterData; - xStorable->storeToURL("private:stream", aMediaDescriptor.getAsConstPropertyValueList()); + aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData; + xStorable->storeToURL(u"private:stream"_ustr, aMediaDescriptor.getAsConstPropertyValueList()); xStream->flush(); aStream.Seek(0); diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx index 3bb0b04c4ea1..d69b48ae076b 100644 --- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx +++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx @@ -195,12 +195,12 @@ uno::Reference<xml::sax::XWriter> XMLSignatureHelper::CreateDocumentHandlerWithH sNamespace = NS_DOCUMENTSIGNATURES_ODF_1_2; pAttributeList->AddAttribute( - "xmlns", + u"xmlns"_ustr, sNamespace); xSaxWriter->startDocument(); xSaxWriter->startElement( - "document-signatures", + u"document-signatures"_ustr, pAttributeList); return xSaxWriter; @@ -208,7 +208,7 @@ uno::Reference<xml::sax::XWriter> XMLSignatureHelper::CreateDocumentHandlerWithH void XMLSignatureHelper::CloseDocumentHandler( const uno::Reference<xml::sax::XDocumentHandler>& xDocumentHandler ) { - xDocumentHandler->endElement( "document-signatures" ); + xDocumentHandler->endElement( u"document-signatures"_ustr ); xDocumentHandler->endDocument(); } @@ -321,14 +321,14 @@ bool lcl_isSignatureOriginType(const beans::StringPair& rPair) bool XMLSignatureHelper::ReadAndVerifySignatureStorage(const uno::Reference<embed::XStorage>& xStorage, bool bCacheLastSignature) { sal_Int32 nOpenMode = embed::ElementModes::READ; - if (xStorage.is() && !xStorage->hasByName("_rels")) + if (xStorage.is() && !xStorage->hasByName(u"_rels"_ustr)) { SAL_WARN("xmlsecurity.helper", "expected stream, in signature storage but not found: _rels"); return false; } - uno::Reference<embed::XStorage> xSubStorage = xStorage->openStorageElement("_rels", nOpenMode); - uno::Reference<io::XInputStream> xRelStream(xSubStorage->openStreamElement("origin.sigs.rels", nOpenMode), uno::UNO_QUERY); + uno::Reference<embed::XStorage> xSubStorage = xStorage->openStorageElement(u"_rels"_ustr, nOpenMode); + uno::Reference<io::XInputStream> xRelStream(xSubStorage->openStreamElement(u"origin.sigs.rels"_ustr, nOpenMode), uno::UNO_QUERY); uno::Sequence< uno::Sequence<beans::StringPair> > aRelationsInfo = comphelper::OFOPXMLHelper::ReadRelationsInfoSequence(xRelStream, u"origin.sigs.rels", mxCtx); for (sal_Int32 i = 0; i < aRelationsInfo.getLength(); ++i) @@ -364,7 +364,7 @@ bool XMLSignatureHelper::ReadAndVerifySignatureStorage(const uno::Reference<embe continue; sal_Int64 nSize = 0; - xPropertySet->getPropertyValue("Size") >>= nSize; + xPropertySet->getPropertyValue(u"Size"_ustr) >>= nSize; if (nSize < 0 || nSize > SAL_MAX_INT32) { SAL_WARN("xmlsecurity.helper", "bogus signature size: " << nSize); @@ -417,8 +417,8 @@ bool XMLSignatureHelper::ReadAndVerifySignatureStorageStream(const css::uno::Ref void XMLSignatureHelper::EnsureSignaturesRelation(const css::uno::Reference<css::embed::XStorage>& xStorage, bool bAdd) { sal_Int32 nOpenMode = embed::ElementModes::READWRITE; - uno::Reference<embed::XStorage> xSubStorage = xStorage->openStorageElement("_rels", nOpenMode); - uno::Reference<io::XInputStream> xRelStream(xSubStorage->openStreamElement(".rels", nOpenMode), uno::UNO_QUERY); + uno::Reference<embed::XStorage> xSubStorage = xStorage->openStorageElement(u"_rels"_ustr, nOpenMode); + uno::Reference<io::XInputStream> xRelStream(xSubStorage->openStreamElement(u".rels"_ustr, nOpenMode), uno::UNO_QUERY); std::vector< uno::Sequence<beans::StringPair> > aRelationsInfo = comphelper::sequenceToContainer< std::vector< uno::Sequence<beans::StringPair> > >(comphelper::OFOPXMLHelper::ReadRelationsInfoSequence(xRelStream, u".rels", mxCtx)); // Do we have a relation already? @@ -474,14 +474,14 @@ void XMLSignatureHelper::ExportSignatureRelations(const css::uno::Reference<css: { // Write the empty file, its relations will be the signatures. sal_Int32 nOpenMode = embed::ElementModes::READWRITE; - uno::Reference<io::XOutputStream> xOriginStream(xStorage->openStreamElement("origin.sigs", nOpenMode), uno::UNO_QUERY); + uno::Reference<io::XOutputStream> xOriginStream(xStorage->openStreamElement(u"origin.sigs"_ustr, nOpenMode), uno::UNO_QUERY); uno::Reference<io::XTruncate> xTruncate(xOriginStream, uno::UNO_QUERY); xTruncate->truncate(); xOriginStream->closeOutput(); // Write the relations. - uno::Reference<embed::XStorage> xSubStorage = xStorage->openStorageElement("_rels", nOpenMode); - uno::Reference<io::XOutputStream> xRelStream(xSubStorage->openStreamElement("origin.sigs.rels", nOpenMode), uno::UNO_QUERY); + uno::Reference<embed::XStorage> xSubStorage = xStorage->openStorageElement(u"_rels"_ustr, nOpenMode); + uno::Reference<io::XOutputStream> xRelStream(xSubStorage->openStreamElement(u"origin.sigs.rels"_ustr, nOpenMode), uno::UNO_QUERY); std::vector< uno::Sequence<beans::StringPair> > aRelations; for (int i = 0; i < nSignatureCount; ++i) { @@ -498,7 +498,7 @@ void XMLSignatureHelper::ExportSignatureRelations(const css::uno::Reference<css: void XMLSignatureHelper::ExportSignatureContentTypes(const css::uno::Reference<css::embed::XStorage>& xStorage, int nSignatureCount) { - uno::Reference<io::XStream> xStream = xStorage->openStreamElement("[Content_Types].xml", embed::ElementModes::READWRITE); + uno::Reference<io::XStream> xStream = xStorage->openStreamElement(u"[Content_Types].xml"_ustr, embed::ElementModes::READWRITE); uno::Reference<io::XInputStream> xInputStream = xStream->getInputStream(); uno::Sequence< uno::Sequence<beans::StringPair> > aContentTypeInfo = comphelper::OFOPXMLHelper::ReadContentTypeSequence(xInputStream, mxCtx); if (aContentTypeInfo.getLength() < 2) diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx index 08b822f15757..fd68c3486d76 100644 --- a/xmlsecurity/source/helper/xsecctl.cxx +++ b/xmlsecurity/source/helper/xsecctl.cxx @@ -182,7 +182,7 @@ void XSecController::createXSecComponent( ) m_xXMLSignature.set(new XMLSignature_GpgImpl()); else // xmlsec or mscrypt #endif - m_xXMLSignature.set(xMCF->createInstanceWithContext("com.sun.star.xml.crypto.XMLSignature", mxCtx), css::uno::UNO_QUERY); + m_xXMLSignature.set(xMCF->createInstanceWithContext(u"com.sun.star.xml.crypto.XMLSignature"_ustr, mxCtx), css::uno::UNO_QUERY); bool bSuccess = m_xXMLSignature.is(); if ( bSuccess ) @@ -531,32 +531,32 @@ void writeUnsignedProperties( { { rtl::Reference<comphelper::AttributeList> pAttributeList(new comphelper::AttributeList()); - pAttributeList->AddAttribute("Id", "idUnsignedProperties_" + signatureInfo.ouSignatureId); - xDocumentHandler->startElement("xd:UnsignedProperties", uno::Reference<xml::sax::XAttributeList>(pAttributeList)); + pAttributeList->AddAttribute(u"Id"_ustr, "idUnsignedProperties_" + signatureInfo.ouSignatureId); + xDocumentHandler->startElement(u"xd:UnsignedProperties"_ustr, uno::Reference<xml::sax::XAttributeList>(pAttributeList)); } { - xDocumentHandler->startElement("xd:UnsignedSignatureProperties", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + xDocumentHandler->startElement(u"xd:UnsignedSignatureProperties"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); { - xDocumentHandler->startElement("xd:CertificateValues", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + xDocumentHandler->startElement(u"xd:CertificateValues"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); { for (const auto& i: signatureInfo.maEncapsulatedX509Certificates) { - xDocumentHandler->startElement("xd:EncapsulatedX509Certificate", uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); + xDocumentHandler->startElement(u"xd:EncapsulatedX509Certificate"_ustr, uno::Reference<xml::sax::XAttributeList>(new comphelper::AttributeList())); xDocumentHandler->characters(i); - xDocumentHandler->endElement("xd:EncapsulatedX509Certificate"); + xDocumentHandler->endElement(u"xd:EncapsulatedX509Certificate"_ustr); } } - xDocumentHandler->endElement("xd:CertificateValues"); + xDocumentHandler->endElement(u"xd:CertificateValues"_ustr); } - xDocumentHandler->endElement("xd:UnsignedSignatureProperties"); + xDocumentHandler->endElement(u"xd:UnsignedSignatureProperties"_ustr); } - xDocumentHandler->endElement("xd:UnsignedProperties"); + xDocumentHandler->endElement(u"xd:UnsignedProperties"_ustr); } } @@ -586,30 +586,30 @@ void XSecController::exportSignature( */ pAttributeList = new comphelper::AttributeList(); pAttributeList->AddAttribute( - "xmlns", + u"xmlns"_ustr, NS_XMLDSIG); if (!signatureInfo.ouSignatureId.isEmpty()) { pAttributeList->AddAttribute( - "Id", + u"Id"_ustr, signatureInfo.ouSignatureId); } - xDocumentHandler->startElement( "Signature", pAttributeList); + xDocumentHandler->startElement( u"Signature"_ustr, pAttributeList); { /* Write SignedInfo element */ xDocumentHandler->startElement( - "SignedInfo", + u"SignedInfo"_ustr, css::uno::Reference< css::xml::sax::XAttributeList > (new comphelper::AttributeList())); { /* Write CanonicalizationMethod element */ pAttributeList = new comphelper::AttributeList(); pAttributeList->AddAttribute( - "Algorithm", + u"Algorithm"_ustr, ALGO_C14N); - xDocumentHandler->startElement( "CanonicalizationMethod", pAttributeList ); - xDocumentHandler->endElement( "CanonicalizationMethod" ); + xDocumentHandler->startElement( u"CanonicalizationMethod"_ustr, pAttributeList ); + xDocumentHandler->endElement( u"CanonicalizationMethod"_ustr ); /* Write SignatureMethod element */ pAttributeList = new comphelper::AttributeList(); @@ -620,10 +620,10 @@ void XSecController::exportSignature( // Assume that all Reference elements use the same DigestMethod:Algorithm, and that the // SignatureMethod:Algorithm should be the corresponding one. pAttributeList->AddAttribute( - "Algorithm", + u"Algorithm"_ustr, getSignatureURI(signatureInfo.eAlgorithmID, vReferenceInfors[0].nDigestID)); - xDocumentHandler->startElement( "SignatureMethod", pAttributeList ); - xDocumentHandler->endElement( "SignatureMethod" ); + xDocumentHandler->startElement( u"SignatureMethod"_ustr, pAttributeList ); + xDocumentHandler->endElement( u"SignatureMethod"_ustr ); /* Write Reference element */ int j; @@ -640,7 +640,7 @@ void XSecController::exportSignature( */ { pAttributeList->AddAttribute( - "URI", + u"URI"_ustr, refInfor.ouURI); } else @@ -650,23 +650,23 @@ void XSecController::exportSignature( { if (refInfor.ouURI.startsWith("idSignedProperties")) { - pAttributeList->AddAttribute("URI", "#idSignedProperties_" + signatureInfo.ouSignatureId); + pAttributeList->AddAttribute(u"URI"_ustr, "#idSignedProperties_" + signatureInfo.ouSignatureId); if (bXAdESCompliantIfODF && !refInfor.ouType.isEmpty()) { // The reference which points to the SignedProperties // shall have this specific type. - pAttributeList->AddAttribute("Type", refInfor.ouType); + pAttributeList->AddAttribute(u"Type"_ustr, refInfor.ouType); } } else { pAttributeList->AddAttribute( - "URI", + u"URI"_ustr, "#" + refInfor.ouURI); } } - xDocumentHandler->startElement( "Reference", pAttributeList ); + xDocumentHandler->startElement( u"Reference"_ustr, pAttributeList ); { /* Write Transforms element */ if (refInfor.nType == SignatureReferenceType::XMLSTREAM) @@ -675,90 +675,90 @@ void XSecController::exportSignature( */ { xDocumentHandler->startElement( - "Transforms", + u"Transforms"_ustr, css::uno::Reference< css::xml::sax::XAttributeList > (new comphelper::AttributeList())); { pAttributeList = new comphelper::AttributeList(); pAttributeList->AddAttribute( - "Algorithm", + u"Algorithm"_ustr, ALGO_C14N); xDocumentHandler->startElement( - "Transform", + u"Transform"_ustr, pAttributeList ); - xDocumentHandler->endElement( "Transform" ); + xDocumentHandler->endElement( u"Transform"_ustr ); } - xDocumentHandler->endElement( "Transforms" ); + xDocumentHandler->endElement( u"Transforms"_ustr ); } /* Write DigestMethod element */ pAttributeList = new comphelper::AttributeList(); pAttributeList->AddAttribute( - "Algorithm", + u"Algorithm"_ustr, getDigestURI(refInfor.nDigestID)); xDocumentHandler->startElement( - "DigestMethod", + u"DigestMethod"_ustr, pAttributeList ); - xDocumentHandler->endElement( "DigestMethod" ); + xDocumentHandler->endElement( u"DigestMethod"_ustr ); /* Write DigestValue element */ xDocumentHandler->startElement( - "DigestValue", + u"DigestValue"_ustr, css::uno::Reference< css::xml::sax::XAttributeList > (new comphelper::AttributeList())); xDocumentHandler->characters( refInfor.ouDigestValue ); - xDocumentHandler->endElement( "DigestValue" ); + xDocumentHandler->endElement( u"DigestValue"_ustr ); } - xDocumentHandler->endElement( "Reference" ); + xDocumentHandler->endElement( u"Reference"_ustr ); } } - xDocumentHandler->endElement( "SignedInfo" ); + xDocumentHandler->endElement( u"SignedInfo"_ustr ); /* Write SignatureValue element */ xDocumentHandler->startElement( - "SignatureValue", + u"SignatureValue"_ustr, css::uno::Reference< css::xml::sax::XAttributeList > (new comphelper::AttributeList())); xDocumentHandler->characters( signatureInfo.ouSignatureValue ); - xDocumentHandler->endElement( "SignatureValue" ); + xDocumentHandler->endElement( u"SignatureValue"_ustr ); /* Write KeyInfo element */ xDocumentHandler->startElement( - "KeyInfo", + u"KeyInfo"_ustr, css::uno::Reference< css::xml::sax::XAttributeList > (new comphelper::AttributeList())); { // GPG or X509 key? if (!signatureInfo.ouGpgCertificate.isEmpty()) { pAttributeList = new comphelper::AttributeList(); - pAttributeList->AddAttribute("xmlns:loext", NS_LOEXT); + pAttributeList->AddAttribute(u"xmlns:loext"_ustr, NS_LOEXT); /* Write PGPData element */ xDocumentHandler->startElement( - "PGPData", + u"PGPData"_ustr, pAttributeList); { /* Write keyid element */ xDocumentHandler->startElement( - "PGPKeyID", + u"PGPKeyID"_ustr, css::uno::Reference< css::xml::sax::XAttributeList > (new comphelper::AttributeList())); xDocumentHandler->characters(signatureInfo.ouGpgKeyID); - xDocumentHandler->endElement( "PGPKeyID" ); + xDocumentHandler->endElement( u"PGPKeyID"_ustr ); /* Write PGPKeyPacket element */ if (!signatureInfo.ouGpgCertificate.isEmpty()) { xDocumentHandler->startElement( - "PGPKeyPacket", + u"PGPKeyPacket"_ustr, css::uno::Reference< css::xml::sax::XAttributeList > (new comphelper::AttributeList())); xDocumentHandler->characters( signatureInfo.ouGpgCertificate ); - xDocumentHandler->endElement( "PGPKeyPacket" ); + xDocumentHandler->endElement( u"PGPKeyPacket"_ustr ); } /* Write PGPOwner element */ xDocumentHandler->startElement( - "loext:PGPOwner", + u"loext:PGPOwner"_ustr, css::uno::Reference< css::xml::sax::XAttributeList >(new comphelper::AttributeList())); xDocumentHandler->characters( signatureInfo.ouGpgOwner ); - xDocumentHandler->endElement( "loext:PGPOwner" ); + xDocumentHandler->endElement( u"loext:PGPOwner"_ustr ); } - xDocumentHandler->endElement( "PGPData" ); + xDocumentHandler->endElement( u"PGPData"_ustr ); } else { @@ -767,82 +767,82 @@ void XSecController::exportSignature( { /* Write X509Data element */ xDocumentHandler->startElement( - "X509Data", + u"X509Data"_ustr, css::uno::Reference< css::xml::sax::XAttributeList > (new comphelper::AttributeList())); { for (auto const& it : rData) { /* Write X509IssuerSerial element */ xDocumentHandler->startElement( - "X509IssuerSerial", + u"X509IssuerSerial"_ustr, css::uno::Reference< css::xml::sax::XAttributeList > (new comphelper::AttributeList())); { /* Write X509IssuerName element */ xDocumentHandler->startElement( - "X509IssuerName", + u"X509IssuerName"_ustr, css::uno::Reference< css::xml::sax::XAttributeList > (new comphelper::AttributeList())); xDocumentHandler->characters(it.X509IssuerName); - xDocumentHandler->endElement( "X509IssuerName" ); + xDocumentHandler->endElement( u"X509IssuerName"_ustr ); /* Write X509SerialNumber element */ xDocumentHandler->startElement( - "X509SerialNumber", + u"X509SerialNumber"_ustr, css::uno::Reference< css::xml::sax::XAttributeList > (new comphelper::AttributeList())); xDocumentHandler->characters(it.X509SerialNumber); - xDocumentHandler->endElement( "X509SerialNumber" ); + xDocumentHandler->endElement( u"X509SerialNumber"_ustr ); } - xDocumentHandler->endElement( "X509IssuerSerial" ); + xDocumentHandler->endElement( u"X509IssuerSerial"_ustr ); /* Write X509Certificate element */ if (!it.X509Certificate.isEmpty()) { xDocumentHandler->startElement( - "X509Certificate", + u"X509Certificate"_ustr, css::uno::Reference< css::xml::sax::XAttributeList > (new comphelper::AttributeList())); xDocumentHandler->characters(it.X509Certificate); - xDocumentHandler->endElement( "X509Certificate" ); + xDocumentHandler->endElement( u"X509Certificate"_ustr ); } } } - xDocumentHandler->endElement( "X509Data" ); + xDocumentHandler->endElement( u"X509Data"_ustr ); } } } - xDocumentHandler->endElement( "KeyInfo" ); + xDocumentHandler->endElement( u"KeyInfo"_ustr ); OUString sDate; /* Write Object element */ xDocumentHandler->startElement( - "Object", + u"Object"_ustr, css::uno::Reference< css::xml::sax::XAttributeList > (new comphelper::AttributeList())); { /* Write SignatureProperties element */ xDocumentHandler->startElement( - "SignatureProperties", + u"SignatureProperties"_ustr, css::uno::Reference< css::xml::sax::XAttributeList > (new comphelper::AttributeList())); { /* Write SignatureProperty element */ pAttributeList = new comphelper::AttributeList(); pAttributeList->AddAttribute( - "Id", + u"Id"_ustr, signatureInfo.ouDateTimePropertyId); pAttributeList->AddAttribute( - "Target", + u"Target"_ustr, "#" + signatureInfo.ouSignatureId); xDocumentHandler->startElement( - "SignatureProperty", + u"SignatureProperty"_ustr, pAttributeList); { /* Write timestamp element */ pAttributeList = new comphelper::AttributeList(); pAttributeList->AddAttribute( - "xmlns:dc", + u"xmlns:dc"_ustr, NS_DC); xDocumentHandler->startElement( - "dc:date", + u"dc:date"_ustr, pAttributeList); OUStringBuffer buffer; @@ -863,9 +863,9 @@ void XSecController::exportSignature( xDocumentHandler->characters( sDate ); xDocumentHandler->endElement( - "dc:date"); + u"dc:date"_ustr); } - xDocumentHandler->endElement( "SignatureProperty" ); + xDocumentHandler->endElement( u"SignatureProperty"_ustr ); } // Write signature description. @@ -873,49 +873,49 @@ void XSecController::exportSignature( { // SignatureProperty element. pAttributeList = new comphelper::AttributeList(); - pAttributeList->AddAttribute("Id", signatureInfo.ouDescriptionPropertyId); - pAttributeList->AddAttribute("Target", "#" + signatureInfo.ouSignatureId); - xDocumentHandler->startElement("SignatureProperty", pAttributeList); + pAttributeList->AddAttribute(u"Id"_ustr, signatureInfo.ouDescriptionPropertyId); + pAttributeList->AddAttribute(u"Target"_ustr, "#" + signatureInfo.ouSignatureId); + xDocumentHandler->startElement(u"SignatureProperty"_ustr, pAttributeList); { // Description element. pAttributeList = new comphelper::AttributeList(); - pAttributeList->AddAttribute("xmlns:dc", NS_DC); + pAttributeList->AddAttribute(u"xmlns:dc"_ustr, NS_DC); - xDocumentHandler->startElement("dc:description", pAttributeList); + xDocumentHandler->startElement(u"dc:description"_ustr, pAttributeList); xDocumentHandler->characters(signatureInfo.ouDescription); - xDocumentHandler->endElement("dc:description"); + xDocumentHandler->endElement(u"dc:description"_ustr); } - xDocumentHandler->endElement("SignatureProperty"); + xDocumentHandler->endElement(u"SignatureProperty"_ustr); } - xDocumentHandler->endElement( "SignatureProperties" ); + xDocumentHandler->endElement( u"SignatureProperties"_ustr ); } - xDocumentHandler->endElement( "Object" ); + xDocumentHandler->endElement( u"Object"_ustr ); // In XAdES, write another Object element for the QualifyingProperties if (bXAdESCompliantIfODF) { pAttributeList = new comphelper::AttributeList(); - pAttributeList->AddAttribute("xmlns:xd", NS_XD); + pAttributeList->AddAttribute(u"xmlns:xd"_ustr, NS_XD); xDocumentHandler->startElement( - "Object", + u"Object"_ustr, pAttributeList); { pAttributeList = new comphelper::AttributeList(); - pAttributeList->AddAttribute("Target", "#" + signatureInfo.ouSignatureId); + pAttributeList->AddAttribute(u"Target"_ustr, "#" + signatureInfo.ouSignatureId); xDocumentHandler->startElement( - "xd:QualifyingProperties", + u"xd:QualifyingProperties"_ustr, pAttributeList); DocumentSignatureHelper::writeSignedProperties(xDocumentHandler, signatureInfo, sDate, true); writeUnsignedProperties(xDocumentHandler, signatureInfo); - xDocumentHandler->endElement( "xd:QualifyingProperties" ); + xDocumentHandler->endElement( u"xd:QualifyingProperties"_ustr ); } - xDocumentHandler->endElement( "Object" ); + xDocumentHandler->endElement( u"Object"_ustr ); } } - xDocumentHandler->endElement( "Signature" ); + xDocumentHandler->endElement( u"Signature"_ustr ); } 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/xsecparser.cxx b/xmlsecurity/source/helper/xsecparser.cxx index cf4f0bbe09fe..fc714e44eaf5 100644 --- a/xmlsecurity/source/helper/xsecparser.cxx +++ b/xmlsecurity/source/helper/xsecparser.cxx @@ -489,7 +489,7 @@ class XSecParser::DsDigestMethodContext virtual void StartElement( css::uno::Reference<css::xml::sax::XAttributeList> const& xAttrs) override { - OUString ouAlgorithm = xAttrs->getValueByName("Algorithm"); + OUString ouAlgorithm = xAttrs->getValueByName(u"Algorithm"_ustr); SAL_WARN_IF( ouAlgorithm.isEmpty(), "xmlsecurity.helper", "no Algorithm in Reference" ); if (ouAlgorithm.isEmpty()) @@ -528,7 +528,7 @@ class XSecParser::DsTransformContext virtual void StartElement( css::uno::Reference<css::xml::sax::XAttributeList> const& xAttrs) override { - OUString ouAlgorithm = xAttrs->getValueByName("Algorithm"); + OUString ouAlgorithm = xAttrs->getValueByName(u"Algorithm"_ustr); if (ouAlgorithm == ALGO_C14N) /* @@ -591,10 +591,10 @@ class XSecParser::DsReferenceContext { m_rParser.HandleIdAttr(xAttrs); - m_URI = xAttrs->getValueByName("URI"); + m_URI = xAttrs->getValueByName(u"URI"_ustr); SAL_WARN_IF(m_URI.isEmpty(), "xmlsecurity.helper", "URI is empty"); // Remember the type of this reference. - m_Type = xAttrs->getValueByName("Type"); + m_Type = xAttrs->getValueByName(u"Type"_ustr); } virtual void EndElement() override @@ -657,7 +657,7 @@ class XSecParser::DsSignatureMethodContext virtual void StartElement( css::uno::Reference<css::xml::sax::XAttributeList> const& xAttrs) override { - OUString ouAlgorithm = xAttrs->getValueByName("Algorithm"); + OUString ouAlgorithm = xAttrs->getValueByName(u"Algorithm"_ustr); if (ouAlgorithm == ALGO_ECDSASHA1 || ouAlgorithm == ALGO_ECDSASHA256 || ouAlgorithm == ALGO_ECDSASHA512) { @@ -1081,7 +1081,7 @@ class XSecParser::XadesSigningTimeContext { if (m_isReferenced) { - m_rParser.m_pXSecController->setDate("", m_Value); + m_rParser.m_pXSecController->setDate(u""_ustr, m_Value); } else { @@ -1442,13 +1442,13 @@ XSecParser::XSecParser(XMLSignatureHelper& rXMLSignatureHelper, { using namespace xmloff::token; m_pNamespaceMap->Add( GetXMLToken(XML_XML), GetXMLToken(XML_N_XML), XML_NAMESPACE_XML ); - m_pNamespaceMap->Add( "_dsig_ooo", GetXMLToken(XML_N_DSIG_OOO), XML_NAMESPACE_DSIG_OOO ); - m_pNamespaceMap->Add( "_dsig", GetXMLToken(XML_N_DSIG), XML_NAMESPACE_DSIG ); - m_pNamespaceMap->Add( "_ds", GetXMLToken(XML_N_DS), XML_NAMESPACE_DS ); - m_pNamespaceMap->Add( "_xades132", GetXMLToken(XML_N_XADES132), XML_NAMESPACE_XADES132); - m_pNamespaceMap->Add( "_xades141", GetXMLToken(XML_N_XADES141), XML_NAMESPACE_XADES141); - m_pNamespaceMap->Add( "_dc", GetXMLToken(XML_N_DC), XML_NAMESPACE_DC ); - m_pNamespaceMap->Add( "_office_libo", + m_pNamespaceMap->Add( u"_dsig_ooo"_ustr, GetXMLToken(XML_N_DSIG_OOO), XML_NAMESPACE_DSIG_OOO ); + m_pNamespaceMap->Add( u"_dsig"_ustr, GetXMLToken(XML_N_DSIG), XML_NAMESPACE_DSIG ); + m_pNamespaceMap->Add( u"_ds"_ustr, GetXMLToken(XML_N_DS), XML_NAMESPACE_DS ); + m_pNamespaceMap->Add( u"_xades132"_ustr, GetXMLToken(XML_N_XADES132), XML_NAMESPACE_XADES132); + m_pNamespaceMap->Add( u"_xades141"_ustr, GetXMLToken(XML_N_XADES141), XML_NAMESPACE_XADES141); + m_pNamespaceMap->Add( u"_dc"_ustr, GetXMLToken(XML_N_DC), XML_NAMESPACE_DC ); + m_pNamespaceMap->Add( u"_office_libo"_ustr, GetXMLToken(XML_N_LO_EXT), XML_NAMESPACE_LO_EXT); } @@ -1464,11 +1464,11 @@ OUString XSecParser::HandleIdAttr(css::uno::Reference<css::xml::sax::XAttributeL OUString XSecParser::getIdAttr(const css::uno::Reference< css::xml::sax::XAttributeList >& xAttribs ) { - OUString ouIdAttr = xAttribs->getValueByName("id"); + OUString ouIdAttr = xAttribs->getValueByName(u"id"_ustr); if (ouIdAttr.isEmpty()) { - ouIdAttr = xAttribs->getValueByName("Id"); + ouIdAttr = xAttribs->getValueByName(u"Id"_ustr); } return ouIdAttr; @@ -1512,7 +1512,7 @@ void SAL_CALL XSecParser::startElement( || localName != "document-signatures") { throw css::xml::sax::SAXException( - "xmlsecurity: unexpected root element", nullptr, + u"xmlsecurity: unexpected root element"_ustr, nullptr, css::uno::Any()); } @@ -1540,13 +1540,13 @@ void SAL_CALL XSecParser::startElement( {//getCaughtException MUST be the first line in the catch block css::uno::Any exc = cppu::getCaughtException(); throw css::xml::sax::SAXException( - "xmlsecurity: Exception in XSecParser::startElement", + u"xmlsecurity: Exception in XSecParser::startElement"_ustr, nullptr, exc); } catch (...) { throw css::xml::sax::SAXException( - "xmlsecurity: unexpected exception in XSecParser::startElement", nullptr, + u"xmlsecurity: unexpected exception in XSecParser::startElement"_ustr, nullptr, css::uno::Any()); } } @@ -1568,13 +1568,13 @@ void SAL_CALL XSecParser::endElement(const OUString& rName) {//getCaughtException MUST be the first line in the catch block css::uno::Any exc = cppu::getCaughtException(); throw css::xml::sax::SAXException( - "xmlsecurity: Exception in XSecParser::endElement", + u"xmlsecurity: Exception in XSecParser::endElement"_ustr, nullptr, exc); } catch (...) { throw css::xml::sax::SAXException( - "xmlsecurity: unexpected exception in XSecParser::endElement", nullptr, + u"xmlsecurity: unexpected exception in XSecParser::endElement"_ustr, nullptr, css::uno::Any()); } diff --git a/xmlsecurity/source/helper/xsecsign.cxx b/xmlsecurity/source/helper/xsecsign.cxx index 6788f694ec2d..633f51517fce 100644 --- a/xmlsecurity/source/helper/xsecsign.cxx +++ b/xmlsecurity/source/helper/xsecsign.cxx @@ -139,7 +139,7 @@ css::uno::Reference< css::xml::crypto::sax::XReferenceResolvedListener > XSecCon { OUString aId = "idSignedProperties_" + internalSignatureInfor.signatureInfor.ouSignatureId; // We write a new reference, so it's possible to use the correct type URI. - internalSignatureInfor.addReference(SignatureReferenceType::SAMEDOCUMENT, digestID, aId, -1, "http://uri.etsi.org/01903#SignedProperties"); + internalSignatureInfor.addReference(SignatureReferenceType::SAMEDOCUMENT, digestID, aId, -1, u"http://uri.etsi.org/01903#SignedProperties"_ustr); size++; } diff --git a/xmlsecurity/source/helper/xsecverify.cxx b/xmlsecurity/source/helper/xsecverify.cxx index c45bece5fed9..553486ca8d36 100644 --- a/xmlsecurity/source/helper/xsecverify.cxx +++ b/xmlsecurity/source/helper/xsecverify.cxx @@ -486,7 +486,7 @@ Reference<css::graphic::XGraphic> lcl_getGraphicFromString(std::u16string_view r graphic::GraphicProvider::create(comphelper::getProcessComponentContext()) ); Reference< io::XInputStream > xInputStream( new ::comphelper::SequenceInputStream( seq ) ); - Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue("InputStream", xInputStream) }; + Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(u"InputStream"_ustr, xInputStream) }; xGraphic = xGraphicProvider->queryGraphic(aArgs); return xGraphic; |