summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-11-25 14:53:59 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-11-26 09:46:13 +0100
commit2132da5066143d7828984bc1aa42d10223bc5824 (patch)
tree1741ac4d1e3a7bc293777629d14c21877b3631b0 /package
parenta916adba23e81c8c661369d2c06fbe9c6714d9c2 (diff)
loplugin:stringliteraldefine in package
Change-Id: I91ce2f65513ea9ae74841c6b0286c01d4e6dd82f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125812 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'package')
-rw-r--r--package/inc/PackageConstants.hxx10
-rw-r--r--package/source/manifest/ManifestDefines.hxx127
-rw-r--r--package/source/manifest/ManifestExport.cxx147
-rw-r--r--package/source/manifest/ManifestImport.cxx170
4 files changed, 175 insertions, 279 deletions
diff --git a/package/inc/PackageConstants.hxx b/package/inc/PackageConstants.hxx
index 141da220ec69..82aa94fc180c 100644
--- a/package/inc/PackageConstants.hxx
+++ b/package/inc/PackageConstants.hxx
@@ -48,14 +48,14 @@ const sal_Int32 n_ConstDigestDecrypt = 1056; // 1024 + 32
#define PKG_SIZE_ENCR_MNFST 12
// the properties related constants
-#define ENCRYPTION_KEY_PROPERTY "EncryptionKey"
-#define STORAGE_ENCRYPTION_KEYS_PROPERTY "StorageEncryptionKeys"
-#define ENCRYPTION_ALGORITHMS_PROPERTY "EncryptionAlgorithms"
-#define ENCRYPTION_GPG_PROPERTIES "EncryptionGpGProperties"
+inline constexpr OUStringLiteral ENCRYPTION_KEY_PROPERTY = u"EncryptionKey";
+inline constexpr OUStringLiteral STORAGE_ENCRYPTION_KEYS_PROPERTY = u"StorageEncryptionKeys";
+inline constexpr OUStringLiteral ENCRYPTION_ALGORITHMS_PROPERTY = u"EncryptionAlgorithms";
+inline constexpr OUStringLiteral ENCRYPTION_GPG_PROPERTIES = u"EncryptionGpGProperties";
#define HAS_ENCRYPTED_ENTRIES_PROPERTY "HasEncryptedEntries"
#define HAS_NONENCRYPTED_ENTRIES_PROPERTY "HasNonEncryptedEntries"
#define IS_INCONSISTENT_PROPERTY "IsInconsistent"
-#define MEDIATYPE_FALLBACK_USED_PROPERTY "MediaTypeFallbackUsed"
+inline constexpr OUStringLiteral MEDIATYPE_FALLBACK_USED_PROPERTY = u"MediaTypeFallbackUsed";
#endif
diff --git a/package/source/manifest/ManifestDefines.hxx b/package/source/manifest/ManifestDefines.hxx
index 44c0cb4c5254..ecb789eadff0 100644
--- a/package/source/manifest/ManifestDefines.hxx
+++ b/package/source/manifest/ManifestDefines.hxx
@@ -16,83 +16,80 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef INCLUDED_PACKAGE_SOURCE_MANIFEST_MANIFESTDEFINES_HXX
-#define INCLUDED_PACKAGE_SOURCE_MANIFEST_MANIFESTDEFINES_HXX
+#pragma once
#include <PackageConstants.hxx>
-#define MANIFEST_NSPREFIX "manifest:"
-#define ELEMENT_MANIFEST "manifest:manifest"
-#define ATTRIBUTE_XMLNS "xmlns:manifest"
-#define ATTRIBUTE_XMLNS_LOEXT "xmlns:loext"
-#define MANIFEST_NAMESPACE "http://openoffice.org/2001/manifest"
-#define MANIFEST_OASIS_NAMESPACE "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"
-#define MANIFEST_LOEXT_NAMESPACE "urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
-#define MANIFEST_DOCTYPE "<!DOCTYPE manifest:manifest PUBLIC \"-//OpenOffice.org//DTD Manifest 1.0//EN\" \"Manifest.dtd\">"
-#define ATTRIBUTE_CDATA "CDATA"
+inline constexpr OUStringLiteral MANIFEST_NSPREFIX = u"manifest:";
+inline constexpr OUStringLiteral ELEMENT_MANIFEST = u"manifest:manifest";
+inline constexpr OUStringLiteral ATTRIBUTE_XMLNS = u"xmlns:manifest";
+inline constexpr OUStringLiteral ATTRIBUTE_XMLNS_LOEXT = u"xmlns:loext";
+inline constexpr OUStringLiteral MANIFEST_NAMESPACE = u"http://openoffice.org/2001/manifest";
+inline constexpr OUStringLiteral MANIFEST_OASIS_NAMESPACE = u"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0";
+inline constexpr OUStringLiteral MANIFEST_LOEXT_NAMESPACE = u"urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0";
+inline constexpr OUStringLiteral MANIFEST_DOCTYPE = u"<!DOCTYPE manifest:manifest PUBLIC \"-//OpenOffice.org//DTD Manifest 1.0//EN\" \"Manifest.dtd\">";
+inline constexpr OUStringLiteral ATTRIBUTE_CDATA = u"CDATA";
-#define ELEMENT_FILE_ENTRY "manifest:file-entry"
-#define ATTRIBUTE_FULL_PATH "manifest:full-path"
-#define ATTRIBUTE_VERSION "manifest:version"
-#define ATTRIBUTE_MEDIA_TYPE "manifest:media-type"
-#define ATTRIBUTE_SIZE "manifest:size"
-#define ELEMENT_MANIFEST_KEYINFO "loext:keyinfo"
-#define ELEMENT_ENCRYPTED_KEYINFO "loext:KeyInfo"
-#define ELEMENT_ENCRYPTEDKEY "loext:encrypted-key"
-#define ELEMENT_ENCRYPTIONMETHOD "loext:encryption-method"
-#define ELEMENT_PGPDATA "loext:PGPData"
-#define ELEMENT_PGPKEYID "loext:PGPKeyID"
-#define ELEMENT_PGPKEYPACKET "loext:PGPKeyPacket"
-#define ATTRIBUTE_ALGORITHM "loext:PGPAlgorithm"
-#define ELEMENT_CIPHERDATA "loext:CipherData"
-#define ELEMENT_CIPHERVALUE "loext:CipherValue"
-#define ELEMENT_MANIFEST13_KEYINFO "manifest:keyinfo"
-#define ELEMENT_ENCRYPTEDKEY13 "manifest:encrypted-key"
-#define ELEMENT_ENCRYPTIONMETHOD13 "manifest:encryption-method"
-#define ELEMENT_PGPDATA13 "manifest:PGPData"
-#define ELEMENT_PGPKEYID13 "manifest:PGPKeyID"
-#define ELEMENT_PGPKEYPACKET13 "manifest:PGPKeyPacket"
-#define ATTRIBUTE_ALGORITHM13 "manifest:PGPAlgorithm"
-#define ELEMENT_CIPHERDATA13 "manifest:CipherData"
-#define ELEMENT_CIPHERVALUE13 "manifest:CipherValue"
+inline constexpr OUStringLiteral ELEMENT_FILE_ENTRY = u"manifest:file-entry";
+inline constexpr OUStringLiteral ATTRIBUTE_FULL_PATH = u"manifest:full-path";
+inline constexpr OUStringLiteral ATTRIBUTE_VERSION = u"manifest:version";
+inline constexpr OUStringLiteral ATTRIBUTE_MEDIA_TYPE = u"manifest:media-type";
+inline constexpr OUStringLiteral ATTRIBUTE_SIZE = u"manifest:size";
+inline constexpr OUStringLiteral ELEMENT_MANIFEST_KEYINFO = u"loext:keyinfo";
+inline constexpr OUStringLiteral ELEMENT_ENCRYPTED_KEYINFO = u"loext:KeyInfo";
+inline constexpr OUStringLiteral ELEMENT_ENCRYPTEDKEY = u"loext:encrypted-key";
+inline constexpr OUStringLiteral ELEMENT_ENCRYPTIONMETHOD = u"loext:encryption-method";
+inline constexpr OUStringLiteral ELEMENT_PGPDATA = u"loext:PGPData";
+inline constexpr OUStringLiteral ELEMENT_PGPKEYID = u"loext:PGPKeyID";
+inline constexpr OUStringLiteral ELEMENT_PGPKEYPACKET = u"loext:PGPKeyPacket";
+inline constexpr OUStringLiteral ATTRIBUTE_ALGORITHM = u"loext:PGPAlgorithm";
+inline constexpr OUStringLiteral ELEMENT_CIPHERDATA = u"loext:CipherData";
+inline constexpr OUStringLiteral ELEMENT_CIPHERVALUE = u"loext:CipherValue";
+inline constexpr OUStringLiteral ELEMENT_MANIFEST13_KEYINFO = u"manifest:keyinfo";
+inline constexpr OUStringLiteral ELEMENT_ENCRYPTEDKEY13 = u"manifest:encrypted-key";
+inline constexpr OUStringLiteral ELEMENT_ENCRYPTIONMETHOD13 = u"manifest:encryption-method";
+inline constexpr OUStringLiteral ELEMENT_PGPDATA13 = u"manifest:PGPData";
+inline constexpr OUStringLiteral ELEMENT_PGPKEYID13 = u"manifest:PGPKeyID";
+inline constexpr OUStringLiteral ELEMENT_PGPKEYPACKET13 = u"manifest:PGPKeyPacket";
+inline constexpr OUStringLiteral ATTRIBUTE_ALGORITHM13 = u"manifest:PGPAlgorithm";
+inline constexpr OUStringLiteral ELEMENT_CIPHERDATA13 = u"manifest:CipherData";
+inline constexpr OUStringLiteral ELEMENT_CIPHERVALUE13 = u"manifest:CipherValue";
-#define ELEMENT_ENCRYPTION_DATA "manifest:encryption-data"
-#define ATTRIBUTE_CHECKSUM_TYPE "manifest:checksum-type"
-#define ATTRIBUTE_CHECKSUM "manifest:checksum"
+inline constexpr OUStringLiteral ELEMENT_ENCRYPTION_DATA = u"manifest:encryption-data";
+inline constexpr OUStringLiteral ATTRIBUTE_CHECKSUM_TYPE = u"manifest:checksum-type";
+inline constexpr OUStringLiteral ATTRIBUTE_CHECKSUM = u"manifest:checksum";
-#define ELEMENT_ALGORITHM "manifest:algorithm"
-#define ATTRIBUTE_ALGORITHM_NAME "manifest:algorithm-name"
-#define ATTRIBUTE_INITIALISATION_VECTOR "manifest:initialisation-vector"
+inline constexpr OUStringLiteral ELEMENT_ALGORITHM = u"manifest:algorithm";
+inline constexpr OUStringLiteral ATTRIBUTE_ALGORITHM_NAME = u"manifest:algorithm-name";
+inline constexpr OUStringLiteral ATTRIBUTE_INITIALISATION_VECTOR = u"manifest:initialisation-vector";
-#define ELEMENT_START_KEY_GENERATION "manifest:start-key-generation"
-#define ATTRIBUTE_START_KEY_GENERATION_NAME "manifest:start-key-generation-name"
-#define ATTRIBUTE_KEY_SIZE "manifest:key-size"
+inline constexpr OUStringLiteral ELEMENT_START_KEY_GENERATION = u"manifest:start-key-generation";
+inline constexpr OUStringLiteral ATTRIBUTE_START_KEY_GENERATION_NAME = u"manifest:start-key-generation-name";
+inline constexpr OUStringLiteral ATTRIBUTE_KEY_SIZE = u"manifest:key-size";
-#define ELEMENT_KEY_DERIVATION "manifest:key-derivation"
-#define ATTRIBUTE_KEY_DERIVATION_NAME "manifest:key-derivation-name"
-#define ATTRIBUTE_SALT "manifest:salt"
-#define ATTRIBUTE_ITERATION_COUNT "manifest:iteration-count"
+inline constexpr OUStringLiteral ELEMENT_KEY_DERIVATION = u"manifest:key-derivation";
+inline constexpr OUStringLiteral ATTRIBUTE_KEY_DERIVATION_NAME = u"manifest:key-derivation-name";
+inline constexpr OUStringLiteral ATTRIBUTE_SALT = u"manifest:salt";
+inline constexpr OUStringLiteral ATTRIBUTE_ITERATION_COUNT = u"manifest:iteration-count";
/// OFFICE-3708: wrong URL cited in ODF 1.2 and used since OOo 3.4 beta
-#define SHA256_URL_ODF12 "http://www.w3.org/2000/09/xmldsig#sha256"
-#define SHA256_URL "http://www.w3.org/2001/04/xmlenc#sha256"
-#define SHA1_NAME "SHA1"
-#define SHA1_URL "http://www.w3.org/2000/09/xmldsig#sha1"
+inline constexpr OUStringLiteral SHA256_URL_ODF12 = u"http://www.w3.org/2000/09/xmldsig#sha256";
+inline constexpr OUStringLiteral SHA256_URL = u"http://www.w3.org/2001/04/xmlenc#sha256";
+inline constexpr OUStringLiteral SHA1_NAME = u"SHA1";
+inline constexpr OUStringLiteral SHA1_URL = u"http://www.w3.org/2000/09/xmldsig#sha1";
-#define SHA1_1K_NAME "SHA1/1K"
-#define SHA1_1K_URL "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0#sha1-1k"
-#define SHA256_1K_URL "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0#sha256-1k"
+inline constexpr OUStringLiteral SHA1_1K_NAME = u"SHA1/1K";
+inline constexpr OUStringLiteral SHA1_1K_URL = u"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0#sha1-1k";
+inline constexpr OUStringLiteral SHA256_1K_URL = u"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0#sha256-1k";
-#define BLOWFISH_NAME "Blowfish CFB"
-#define BLOWFISH_URL "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0#blowfish"
-#define AES128_URL "http://www.w3.org/2001/04/xmlenc#aes128-cbc"
-#define AES192_URL "http://www.w3.org/2001/04/xmlenc#aes192-cbc"
-#define AES256_URL "http://www.w3.org/2001/04/xmlenc#aes256-cbc"
+inline constexpr OUStringLiteral BLOWFISH_NAME = u"Blowfish CFB";
+inline constexpr OUStringLiteral BLOWFISH_URL = u"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0#blowfish";
+inline constexpr OUStringLiteral AES128_URL = u"http://www.w3.org/2001/04/xmlenc#aes128-cbc";
+inline constexpr OUStringLiteral AES192_URL = u"http://www.w3.org/2001/04/xmlenc#aes192-cbc";
+inline constexpr OUStringLiteral AES256_URL = u"http://www.w3.org/2001/04/xmlenc#aes256-cbc";
-#define PBKDF2_NAME "PBKDF2"
-#define PGP_NAME "PGP"
-#define PBKDF2_URL "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0#pbkdf2"
-
-#endif
+inline constexpr OUStringLiteral PBKDF2_NAME = u"PBKDF2";
+inline constexpr OUStringLiteral PGP_NAME = u"PGP";
+inline constexpr OUStringLiteral PBKDF2_URL = u"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0#pbkdf2";
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/package/source/manifest/ManifestExport.cxx b/package/source/manifest/ManifestExport.cxx
index 0c0e963e1c4b..b603200f061a 100644
--- a/package/source/manifest/ManifestExport.cxx
+++ b/package/source/manifest/ManifestExport.cxx
@@ -48,47 +48,6 @@ using namespace ::com::sun::star;
ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > const & xHandler, const uno::Sequence< uno::Sequence < beans::PropertyValue > >& rManList )
{
- const OUString sFileEntryElement ( ELEMENT_FILE_ENTRY );
- const OUString sManifestElement ( ELEMENT_MANIFEST );
- const OUString sEncryptionDataElement( ELEMENT_ENCRYPTION_DATA );
- const OUString sAlgorithmElement ( ELEMENT_ALGORITHM );
- const OUString sStartKeyGenerationElement ( ELEMENT_START_KEY_GENERATION );
- const OUString sKeyDerivationElement ( ELEMENT_KEY_DERIVATION );
-
- const OUString sCdataAttribute ( ATTRIBUTE_CDATA );
- const OUString sMediaTypeAttribute ( ATTRIBUTE_MEDIA_TYPE );
- const OUString sVersionAttribute ( ATTRIBUTE_VERSION );
- const OUString sFullPathAttribute ( ATTRIBUTE_FULL_PATH );
- const OUString sSizeAttribute ( ATTRIBUTE_SIZE );
- const OUString sKeySizeAttribute ( ATTRIBUTE_KEY_SIZE );
- const OUString sSaltAttribute ( ATTRIBUTE_SALT );
- const OUString sInitialisationVectorAttribute ( ATTRIBUTE_INITIALISATION_VECTOR );
- const OUString sIterationCountAttribute ( ATTRIBUTE_ITERATION_COUNT );
- const OUString sAlgorithmNameAttribute ( ATTRIBUTE_ALGORITHM_NAME );
- const OUString sStartKeyGenerationNameAttribute ( ATTRIBUTE_START_KEY_GENERATION_NAME );
- const OUString sKeyDerivationNameAttribute ( ATTRIBUTE_KEY_DERIVATION_NAME );
- const OUString sChecksumTypeAttribute ( ATTRIBUTE_CHECKSUM_TYPE );
- const OUString sChecksumAttribute ( ATTRIBUTE_CHECKSUM);
-
- const OUString sKeyInfoElement ( ELEMENT_ENCRYPTED_KEYINFO );
- const OUString sManifestKeyInfoElement ( ELEMENT_MANIFEST_KEYINFO );
- const OUString sEncryptedKeyElement ( ELEMENT_ENCRYPTEDKEY );
- const OUString sEncryptionMethodElement ( ELEMENT_ENCRYPTIONMETHOD );
- const OUString sPgpDataElement ( ELEMENT_PGPDATA );
- const OUString sPgpKeyIDElement ( ELEMENT_PGPKEYID );
- const OUString sPGPKeyPacketElement ( ELEMENT_PGPKEYPACKET );
- const OUString sAlgorithmAttribute ( ATTRIBUTE_ALGORITHM );
- const OUString sCipherDataElement ( ELEMENT_CIPHERDATA );
- const OUString sCipherValueElement ( ELEMENT_CIPHERVALUE );
- const OUString sManifestKeyInfoElement13 ( ELEMENT_MANIFEST13_KEYINFO );
- const OUString sEncryptedKeyElement13 ( ELEMENT_ENCRYPTEDKEY13 );
- const OUString sEncryptionMethodElement13 ( ELEMENT_ENCRYPTIONMETHOD13 );
- const OUString sPgpDataElement13 ( ELEMENT_PGPDATA13 );
- const OUString sPgpKeyIDElement13 ( ELEMENT_PGPKEYID13 );
- const OUString sPGPKeyPacketElement13 ( ELEMENT_PGPKEYPACKET13 );
- const OUString sAlgorithmAttribute13 ( ATTRIBUTE_ALGORITHM13 );
- const OUString sCipherDataElement13 ( ELEMENT_CIPHERDATA13 );
- const OUString sCipherValueElement13 ( ELEMENT_CIPHERVALUE13 );
static const OUStringLiteral sKeyInfo ( u"KeyInfo" );
static const OUStringLiteral sPgpKeyIDProperty ( u"KeyId" );
static const OUStringLiteral sPgpKeyPacketProperty ( u"KeyPacket" );
@@ -185,7 +144,7 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con
{
// oasis format
pRootAttrList->AddAttribute ( ATTRIBUTE_XMLNS,
- sCdataAttribute,
+ ATTRIBUTE_CDATA,
MANIFEST_OASIS_NAMESPACE );
bAcceptNonemptyVersion = true;
if ( aDocVersion.compareTo( ODFVER_012_TEXT ) >= 0 )
@@ -193,10 +152,10 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con
// this is ODF12 or later generation, let encrypted
// streams contain start-key-generation entry
bStoreStartKeyGeneration = true;
- pRootAttrList->AddAttribute ( sVersionAttribute, sCdataAttribute, aDocVersion );
+ pRootAttrList->AddAttribute ( ATTRIBUTE_VERSION, ATTRIBUTE_CDATA, aDocVersion );
// plus gpg4libre extensions - loext NS for that
pRootAttrList->AddAttribute ( ATTRIBUTE_XMLNS_LOEXT,
- sCdataAttribute,
+ ATTRIBUTE_CDATA,
MANIFEST_LOEXT_NAMESPACE );
}
}
@@ -205,7 +164,7 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con
// even if it is no SO6 format the namespace must be specified
// thus SO6 format is used as default one
pRootAttrList->AddAttribute ( ATTRIBUTE_XMLNS,
- sCdataAttribute,
+ ATTRIBUTE_CDATA,
MANIFEST_NAMESPACE );
bProvideDTD = true;
@@ -219,7 +178,7 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con
xExtHandler->unknown ( MANIFEST_DOCTYPE );
xHandler->ignorableWhitespace ( sWhiteSpace );
}
- xHandler->startElement( sManifestElement, pRootAttrList );
+ xHandler->startElement( ELEMENT_MANIFEST, pRootAttrList );
const uno::Any *pKeyInfoProperty = nullptr;
if ( pRootFolderPropSeq )
@@ -243,7 +202,7 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con
bool const isODF13(aDocVersion.compareTo(ODFVER_013_TEXT) >= 0);
if (!isODF13)
{
- xHandler->startElement(sManifestKeyInfoElement, nullptr);
+ xHandler->startElement(ELEMENT_MANIFEST_KEYINFO, nullptr);
}
xHandler->ignorableWhitespace ( sWhiteSpace );
@@ -267,68 +226,68 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con
if (aPgpKeyID.hasElements() && aCipherValue.hasElements() )
{
// ==== manifest:encrypted-key & children - one for each recipient
- xHandler->startElement(isODF13 ? sEncryptedKeyElement13 : sEncryptedKeyElement, nullptr);
+ xHandler->startElement(isODF13 ? OUString(ELEMENT_ENCRYPTEDKEY13) : OUString(ELEMENT_ENCRYPTEDKEY), nullptr);
xHandler->ignorableWhitespace ( sWhiteSpace );
rtl::Reference<::comphelper::AttributeList> pNewAttrList = new ::comphelper::AttributeList;
// TODO: the algorithm should rather be configurable
pNewAttrList->AddAttribute(
- isODF13 ? sAlgorithmAttribute13 : sAlgorithmAttribute,
- sCdataAttribute,
+ isODF13 ? OUString(ATTRIBUTE_ALGORITHM13) : OUString(ATTRIBUTE_ALGORITHM),
+ ATTRIBUTE_CDATA,
"http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p" );
- xHandler->startElement(isODF13 ? sEncryptionMethodElement13 : sEncryptionMethodElement, pNewAttrList);
- xHandler->endElement(isODF13 ? sEncryptionMethodElement13 : sEncryptionMethodElement);
+ xHandler->startElement(isODF13 ? OUString(ELEMENT_ENCRYPTIONMETHOD13) : OUString(ELEMENT_ENCRYPTIONMETHOD), pNewAttrList);
+ xHandler->endElement(isODF13 ? OUString(ELEMENT_ENCRYPTIONMETHOD13) : OUString(ELEMENT_ENCRYPTIONMETHOD));
xHandler->ignorableWhitespace ( sWhiteSpace );
// note: the mismatch here corresponds to ODF 1.3 cs01 schema
- xHandler->startElement(isODF13 ? sManifestKeyInfoElement13 : sKeyInfoElement, nullptr);
+ xHandler->startElement(isODF13 ? OUString(ELEMENT_MANIFEST13_KEYINFO) : OUString(ELEMENT_MANIFEST_KEYINFO), nullptr);
xHandler->ignorableWhitespace ( sWhiteSpace );
- xHandler->startElement(isODF13 ? sPgpDataElement13 : sPgpDataElement, nullptr);
+ xHandler->startElement(isODF13 ? OUString(ELEMENT_PGPDATA13) : OUString(ELEMENT_PGPDATA), nullptr);
xHandler->ignorableWhitespace ( sWhiteSpace );
- xHandler->startElement(isODF13 ? sPgpKeyIDElement13 : sPgpKeyIDElement, nullptr);
+ xHandler->startElement(isODF13 ? OUString(ELEMENT_PGPKEYID13) : OUString(ELEMENT_PGPKEYID), nullptr);
::comphelper::Base64::encode(aBuffer, aPgpKeyID);
xHandler->characters( aBuffer.makeStringAndClear() );
- xHandler->endElement(isODF13 ? sPgpKeyIDElement13 : sPgpKeyIDElement);
+ xHandler->endElement(isODF13 ? OUString(ELEMENT_PGPKEYID13) : OUString(ELEMENT_PGPKEYID));
xHandler->ignorableWhitespace ( sWhiteSpace );
// key packet is optional
if (aPgpKeyPacket.hasElements())
{
- xHandler->startElement(isODF13 ? sPGPKeyPacketElement13 : sPGPKeyPacketElement, nullptr);
+ xHandler->startElement(isODF13 ? OUString(ELEMENT_PGPKEYPACKET13) : OUString(ELEMENT_PGPKEYPACKET), nullptr);
::comphelper::Base64::encode(aBuffer, aPgpKeyPacket);
xHandler->characters( aBuffer.makeStringAndClear() );
- xHandler->endElement(isODF13 ? sPGPKeyPacketElement13 : sPGPKeyPacketElement);
+ xHandler->endElement(isODF13 ? OUString(ELEMENT_PGPKEYPACKET13) : OUString(ELEMENT_PGPKEYPACKET));
xHandler->ignorableWhitespace ( sWhiteSpace );
}
- xHandler->endElement(isODF13 ? sPgpDataElement13 : sPgpDataElement);
+ xHandler->endElement(isODF13 ? OUString(ELEMENT_PGPDATA13) : OUString(ELEMENT_PGPDATA));
xHandler->ignorableWhitespace ( sWhiteSpace );
- xHandler->endElement(isODF13 ? sManifestKeyInfoElement13 : sKeyInfoElement);
+ xHandler->endElement(isODF13 ? OUString(ELEMENT_MANIFEST13_KEYINFO) : OUString(ELEMENT_MANIFEST_KEYINFO));
xHandler->ignorableWhitespace ( sWhiteSpace );
- xHandler->startElement(isODF13 ? sCipherDataElement13 : sCipherDataElement, nullptr);
+ xHandler->startElement(isODF13 ? OUString(ELEMENT_CIPHERDATA13) : OUString(ELEMENT_CIPHERDATA), nullptr);
xHandler->ignorableWhitespace ( sWhiteSpace );
- xHandler->startElement(isODF13 ? sCipherValueElement13 : sCipherValueElement, nullptr);
+ xHandler->startElement(isODF13 ? OUString(ELEMENT_CIPHERVALUE13) : OUString(ELEMENT_CIPHERVALUE), nullptr);
::comphelper::Base64::encode(aBuffer, aCipherValue);
xHandler->characters( aBuffer.makeStringAndClear() );
- xHandler->endElement(isODF13 ? sCipherValueElement13 : sCipherValueElement);
+ xHandler->endElement(isODF13 ? OUString(ELEMENT_CIPHERVALUE13) : OUString(ELEMENT_CIPHERVALUE));
xHandler->ignorableWhitespace ( sWhiteSpace );
- xHandler->endElement(isODF13 ? sCipherDataElement13 : sCipherDataElement);
+ xHandler->endElement(isODF13 ? OUString(ELEMENT_CIPHERDATA13) : OUString(ELEMENT_CIPHERDATA));
xHandler->ignorableWhitespace ( sWhiteSpace );
- xHandler->endElement(isODF13 ? sEncryptedKeyElement13 : sEncryptedKeyElement);
+ xHandler->endElement(isODF13 ? OUString(ELEMENT_ENCRYPTEDKEY13) : OUString(ELEMENT_ENCRYPTEDKEY));
xHandler->ignorableWhitespace ( sWhiteSpace );
}
}
if (!isODF13)
{
- xHandler->endElement(sManifestKeyInfoElement);
+ xHandler->endElement(ELEMENT_MANIFEST_KEYINFO);
}
xHandler->ignorableWhitespace ( sWhiteSpace );
}
@@ -345,25 +304,25 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con
if (rValue.Name == sMediaTypeProperty )
{
rValue.Value >>= aString;
- pAttrList->AddAttribute ( sMediaTypeAttribute, sCdataAttribute, aString );
+ pAttrList->AddAttribute ( ATTRIBUTE_MEDIA_TYPE, ATTRIBUTE_CDATA, aString );
}
else if (rValue.Name == sVersionProperty )
{
rValue.Value >>= aString;
// the version is stored only if it is not empty
if ( bAcceptNonemptyVersion && !aString.isEmpty() )
- pAttrList->AddAttribute ( sVersionAttribute, sCdataAttribute, aString );
+ pAttrList->AddAttribute ( ATTRIBUTE_VERSION, ATTRIBUTE_CDATA, aString );
}
else if (rValue.Name == sFullPathProperty )
{
rValue.Value >>= aString;
- pAttrList->AddAttribute ( sFullPathAttribute, sCdataAttribute, aString );
+ pAttrList->AddAttribute ( ATTRIBUTE_FULL_PATH, ATTRIBUTE_CDATA, aString );
}
else if (rValue.Name == sSizeProperty )
{
sal_Int64 nSize = 0;
rValue.Value >>= nSize;
- pAttrList->AddAttribute ( sSizeAttribute, sCdataAttribute, OUString::number( nSize ) );
+ pAttrList->AddAttribute ( ATTRIBUTE_SIZE, ATTRIBUTE_CDATA, OUString::number( nSize ) );
}
else if (rValue.Name == sInitialisationVectorProperty )
pVector = &rValue.Value;
@@ -384,7 +343,7 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con
}
xHandler->ignorableWhitespace ( sWhiteSpace );
- xHandler->startElement( sFileEntryElement , pAttrList);
+ xHandler->startElement( ELEMENT_FILE_ENTRY , pAttrList);
if ( pVector && pSalt && pIterationCount && pDigest && pDigestAlg && pEncryptAlg && pStartKeyAlg && pDerivedKeySize )
{
// ==== Encryption Data
@@ -405,12 +364,12 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con
else
throw uno::RuntimeException( THROW_WHERE "Unexpected digest algorithm is provided!" );
- pNewAttrList->AddAttribute ( sChecksumTypeAttribute, sCdataAttribute, sChecksumType );
+ pNewAttrList->AddAttribute ( ATTRIBUTE_CHECKSUM_TYPE, ATTRIBUTE_CDATA, sChecksumType );
*pDigest >>= aSequence;
::comphelper::Base64::encode(aBuffer, aSequence);
- pNewAttrList->AddAttribute ( sChecksumAttribute, sCdataAttribute, aBuffer.makeStringAndClear() );
+ pNewAttrList->AddAttribute ( ATTRIBUTE_CHECKSUM, ATTRIBUTE_CDATA, aBuffer.makeStringAndClear() );
- xHandler->startElement( sEncryptionDataElement , pNewAttrList);
+ xHandler->startElement( ELEMENT_ENCRYPTION_DATA , pNewAttrList);
// ==== Algorithm
pNewAttrList = new ::comphelper::AttributeList;
@@ -436,16 +395,16 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con
else
throw uno::RuntimeException( THROW_WHERE "Unexpected encryption algorithm is provided!" );
- pNewAttrList->AddAttribute ( sAlgorithmNameAttribute, sCdataAttribute, sEncAlgName );
+ pNewAttrList->AddAttribute ( ATTRIBUTE_ALGORITHM_NAME, ATTRIBUTE_CDATA, sEncAlgName );
*pVector >>= aSequence;
::comphelper::Base64::encode(aBuffer, aSequence);
- pNewAttrList->AddAttribute ( sInitialisationVectorAttribute, sCdataAttribute, aBuffer.makeStringAndClear() );
+ pNewAttrList->AddAttribute ( ATTRIBUTE_INITIALISATION_VECTOR, ATTRIBUTE_CDATA, aBuffer.makeStringAndClear() );
xHandler->ignorableWhitespace ( sWhiteSpace );
- xHandler->startElement( sAlgorithmElement , pNewAttrList);
+ xHandler->startElement( ELEMENT_ALGORITHM , pNewAttrList);
xHandler->ignorableWhitespace ( sWhiteSpace );
- xHandler->endElement( sAlgorithmElement );
+ xHandler->endElement( ELEMENT_ALGORITHM );
if ( bStoreStartKeyGeneration )
{
@@ -471,13 +430,13 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con
else
throw uno::RuntimeException( THROW_WHERE "Unexpected start key algorithm is provided!" );
- pNewAttrList->AddAttribute ( sStartKeyGenerationNameAttribute, sCdataAttribute, sStartKeyAlg );
- pNewAttrList->AddAttribute ( sKeySizeAttribute, sCdataAttribute, sStartKeySize );
+ pNewAttrList->AddAttribute ( ATTRIBUTE_START_KEY_GENERATION_NAME, ATTRIBUTE_CDATA, sStartKeyAlg );
+ pNewAttrList->AddAttribute ( ATTRIBUTE_KEY_SIZE, ATTRIBUTE_CDATA, sStartKeySize );
xHandler->ignorableWhitespace ( sWhiteSpace );
- xHandler->startElement( sStartKeyGenerationElement , pNewAttrList);
+ xHandler->startElement( ELEMENT_START_KEY_GENERATION , pNewAttrList);
xHandler->ignorableWhitespace ( sWhiteSpace );
- xHandler->endElement( sStartKeyGenerationElement );
+ xHandler->endElement( ELEMENT_START_KEY_GENERATION );
}
// ==== Key Derivation
@@ -485,8 +444,8 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con
if (pKeyInfoProperty)
{
- pNewAttrList->AddAttribute(sKeyDerivationNameAttribute,
- sCdataAttribute,
+ pNewAttrList->AddAttribute(ATTRIBUTE_KEY_DERIVATION_NAME,
+ ATTRIBUTE_CDATA,
sPGP_Name);
// no start-key-generation needed, our session key has
// max size already
@@ -494,39 +453,39 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con
}
else
{
- pNewAttrList->AddAttribute(sKeyDerivationNameAttribute,
- sCdataAttribute,
+ pNewAttrList->AddAttribute(ATTRIBUTE_KEY_DERIVATION_NAME,
+ ATTRIBUTE_CDATA,
sPBKDF2_Name);
if (bStoreStartKeyGeneration)
{
aBuffer.append(nDerivedKeySize);
- pNewAttrList->AddAttribute(sKeySizeAttribute, sCdataAttribute, aBuffer.makeStringAndClear());
+ pNewAttrList->AddAttribute(ATTRIBUTE_KEY_SIZE, ATTRIBUTE_CDATA, aBuffer.makeStringAndClear());
}
sal_Int32 nCount = 0;
*pIterationCount >>= nCount;
aBuffer.append(nCount);
- pNewAttrList->AddAttribute(sIterationCountAttribute, sCdataAttribute, aBuffer.makeStringAndClear());
+ pNewAttrList->AddAttribute(ATTRIBUTE_ITERATION_COUNT, ATTRIBUTE_CDATA, aBuffer.makeStringAndClear());
*pSalt >>= aSequence;
::comphelper::Base64::encode(aBuffer, aSequence);
- pNewAttrList->AddAttribute(sSaltAttribute, sCdataAttribute, aBuffer.makeStringAndClear());
+ pNewAttrList->AddAttribute(ATTRIBUTE_SALT, ATTRIBUTE_CDATA, aBuffer.makeStringAndClear());
}
xHandler->ignorableWhitespace(sWhiteSpace);
- xHandler->startElement(sKeyDerivationElement, pNewAttrList);
+ xHandler->startElement(ELEMENT_KEY_DERIVATION, pNewAttrList);
xHandler->ignorableWhitespace(sWhiteSpace);
- xHandler->endElement(sKeyDerivationElement);
+ xHandler->endElement(ELEMENT_KEY_DERIVATION);
xHandler->ignorableWhitespace ( sWhiteSpace );
- xHandler->endElement( sEncryptionDataElement );
+ xHandler->endElement( ELEMENT_ENCRYPTION_DATA );
}
xHandler->ignorableWhitespace ( sWhiteSpace );
- xHandler->endElement( sFileEntryElement );
+ xHandler->endElement( ELEMENT_FILE_ENTRY );
}
xHandler->ignorableWhitespace ( sWhiteSpace );
- xHandler->endElement( sManifestElement );
+ xHandler->endElement( ELEMENT_MANIFEST );
xHandler->endDocument();
}
diff --git a/package/source/manifest/ManifestImport.cxx b/package/source/manifest/ManifestImport.cxx
index 0a1c4ad5bb1d..1d9392d9b8e8 100644
--- a/package/source/manifest/ManifestImport.cxx
+++ b/package/source/manifest/ManifestImport.cxx
@@ -32,48 +32,6 @@ using namespace com::sun::star::uno;
using namespace com::sun::star::beans;
using namespace com::sun::star;
-
-constexpr OUStringLiteral gsFileEntryElement ( u"" ELEMENT_FILE_ENTRY );
-constexpr OUStringLiteral gsEncryptionDataElement( u"" ELEMENT_ENCRYPTION_DATA );
-constexpr OUStringLiteral gsAlgorithmElement ( u"" ELEMENT_ALGORITHM );
-constexpr OUStringLiteral gsStartKeyAlgElement ( u"" ELEMENT_START_KEY_GENERATION );
-constexpr OUStringLiteral gsKeyDerivationElement( u"" ELEMENT_KEY_DERIVATION );
-
-constexpr OUStringLiteral gsMediaTypeAttribute ( u"" ATTRIBUTE_MEDIA_TYPE );
-constexpr OUStringLiteral gsVersionAttribute ( u"" ATTRIBUTE_VERSION );
-constexpr OUStringLiteral gsFullPathAttribute ( u"" ATTRIBUTE_FULL_PATH );
-constexpr OUStringLiteral gsSizeAttribute ( u"" ATTRIBUTE_SIZE );
-constexpr OUStringLiteral gsSaltAttribute ( u"" ATTRIBUTE_SALT );
-constexpr OUStringLiteral gsInitialisationVectorAttribute ( u"" ATTRIBUTE_INITIALISATION_VECTOR );
-constexpr OUStringLiteral gsIterationCountAttribute ( u"" ATTRIBUTE_ITERATION_COUNT );
-constexpr OUStringLiteral gsKeySizeAttribute ( u"" ATTRIBUTE_KEY_SIZE );
-constexpr OUStringLiteral gsAlgorithmNameAttribute ( u"" ATTRIBUTE_ALGORITHM_NAME );
-constexpr OUStringLiteral gsStartKeyAlgNameAttribute ( u"" ATTRIBUTE_START_KEY_GENERATION_NAME );
-constexpr OUStringLiteral gsKeyDerivationNameAttribute ( u"" ATTRIBUTE_KEY_DERIVATION_NAME );
-constexpr OUStringLiteral gsChecksumAttribute ( u"" ATTRIBUTE_CHECKSUM );
-constexpr OUStringLiteral gsChecksumTypeAttribute ( u"" ATTRIBUTE_CHECKSUM_TYPE );
-
-constexpr OUStringLiteral gsKeyInfoElement ( u"" ELEMENT_ENCRYPTED_KEYINFO );
-constexpr OUStringLiteral gsManifestKeyInfoElement ( u"" ELEMENT_MANIFEST_KEYINFO );
-constexpr OUStringLiteral gsEncryptedKeyElement ( u"" ELEMENT_ENCRYPTEDKEY );
-constexpr OUStringLiteral gsEncryptionMethodElement ( u"" ELEMENT_ENCRYPTIONMETHOD );
-constexpr OUStringLiteral gsPgpDataElement ( u"" ELEMENT_PGPDATA );
-constexpr OUStringLiteral gsPgpKeyIDElement ( u"" ELEMENT_PGPKEYID );
-constexpr OUStringLiteral gsPGPKeyPacketElement ( u"" ELEMENT_PGPKEYPACKET );
-constexpr OUStringLiteral gsAlgorithmAttribute ( u"" ATTRIBUTE_ALGORITHM );
-constexpr OUStringLiteral gsCipherDataElement ( u"" ELEMENT_CIPHERDATA );
-constexpr OUStringLiteral gsCipherValueElement ( u"" ELEMENT_CIPHERVALUE );
-
-constexpr OUStringLiteral gsManifestKeyInfoElement13 ( u"" ELEMENT_MANIFEST13_KEYINFO );
-constexpr OUStringLiteral gsEncryptedKeyElement13 ( u"" ELEMENT_ENCRYPTEDKEY13 );
-constexpr OUStringLiteral gsEncryptionMethodElement13 ( u"" ELEMENT_ENCRYPTIONMETHOD13 );
-constexpr OUStringLiteral gsPgpDataElement13 ( u"" ELEMENT_PGPDATA13 );
-constexpr OUStringLiteral gsPgpKeyIDElement13 ( u"" ELEMENT_PGPKEYID13 );
-constexpr OUStringLiteral gsPGPKeyPacketElement13 ( u"" ELEMENT_PGPKEYPACKET13 );
-constexpr OUStringLiteral gsAlgorithmAttribute13 ( u"" ATTRIBUTE_ALGORITHM13 );
-constexpr OUStringLiteral gsCipherDataElement13 ( u"" ELEMENT_CIPHERDATA13 );
-constexpr OUStringLiteral gsCipherValueElement13 ( u"" ELEMENT_CIPHERVALUE13 );
-
constexpr OUStringLiteral gsFullPathProperty ( u"FullPath" );
constexpr OUStringLiteral gsMediaTypeProperty ( u"MediaType" );
constexpr OUStringLiteral gsVersionProperty ( u"Version" );
@@ -87,24 +45,6 @@ constexpr OUStringLiteral gsEncryptionAlgProperty ( u"EncryptionAlgorithm
constexpr OUStringLiteral gsStartKeyAlgProperty ( u"StartKeyAlgorithm" );
constexpr OUStringLiteral gsDigestAlgProperty ( u"DigestAlgorithm" );
-constexpr OUStringLiteral gsSHA256_URL_ODF12 ( u"" SHA256_URL_ODF12 );
-constexpr OUStringLiteral gsSHA256_URL ( u"" SHA256_URL );
-constexpr OUStringLiteral gsSHA1_Name ( u"" SHA1_NAME );
-constexpr OUStringLiteral gsSHA1_URL ( u"" SHA1_URL );
-
-constexpr OUStringLiteral gsSHA256_1k_URL ( u"" SHA256_1K_URL );
-constexpr OUStringLiteral gsSHA1_1k_Name ( u"" SHA1_1K_NAME );
-constexpr OUStringLiteral gsSHA1_1k_URL ( u"" SHA1_1K_URL );
-
-constexpr OUStringLiteral gsBlowfish_Name ( u"" BLOWFISH_NAME );
-constexpr OUStringLiteral gsBlowfish_URL ( u"" BLOWFISH_URL );
-constexpr OUStringLiteral gsAES128_URL ( u"" AES128_URL );
-constexpr OUStringLiteral gsAES192_URL ( u"" AES192_URL );
-constexpr OUStringLiteral gsAES256_URL ( u"" AES256_URL );
-
-constexpr OUStringLiteral gsPBKDF2_Name ( u"" PBKDF2_NAME );
-constexpr OUStringLiteral gsPBKDF2_URL ( u"" PBKDF2_URL );
-
ManifestImport::ManifestImport( std::vector < Sequence < PropertyValue > > & rNewManVector )
: bIgnoreEncryptData ( false )
, bPgpEncryption ( false )
@@ -131,17 +71,17 @@ void ManifestImport::doFileEntry(StringHashMap &rConvertedAttribs)
aSequence.resize(PKG_SIZE_ENCR_MNFST);
aSequence[PKG_MNFST_FULLPATH].Name = gsFullPathProperty;
- aSequence[PKG_MNFST_FULLPATH].Value <<= rConvertedAttribs[gsFullPathAttribute];
+ aSequence[PKG_MNFST_FULLPATH].Value <<= rConvertedAttribs[ATTRIBUTE_FULL_PATH];
aSequence[PKG_MNFST_MEDIATYPE].Name = gsMediaTypeProperty;
- aSequence[PKG_MNFST_MEDIATYPE].Value <<= rConvertedAttribs[gsMediaTypeAttribute];
+ aSequence[PKG_MNFST_MEDIATYPE].Value <<= rConvertedAttribs[ATTRIBUTE_MEDIA_TYPE];
- OUString sVersion = rConvertedAttribs[gsVersionAttribute];
+ OUString sVersion = rConvertedAttribs[ATTRIBUTE_VERSION];
if ( sVersion.getLength() ) {
aSequence[PKG_MNFST_VERSION].Name = gsVersionProperty;
aSequence[PKG_MNFST_VERSION].Value <<= sVersion;
}
- OUString sSize = rConvertedAttribs[gsSizeAttribute];
+ OUString sSize = rConvertedAttribs[ATTRIBUTE_SIZE];
if ( sSize.getLength() ) {
sal_Int64 nSize = sSize.toInt64();
aSequence[PKG_MNFST_UCOMPSIZE].Name = gsSizeProperty;
@@ -213,21 +153,21 @@ void ManifestImport::doEncryptionData(StringHashMap &rConvertedAttribs)
// If this element exists, then this stream is encrypted and we need
// to import the initialisation vector, salt and iteration count used
nDerivedKeySize = 0;
- OUString aString = rConvertedAttribs[gsChecksumTypeAttribute];
+ OUString aString = rConvertedAttribs[ATTRIBUTE_CHECKSUM_TYPE];
if ( bIgnoreEncryptData )
return;
- if ( aString == gsSHA1_1k_Name || aString == gsSHA1_1k_URL ) {
+ if ( aString == SHA1_1K_NAME || aString == SHA1_1K_URL ) {
aSequence[PKG_MNFST_DIGESTALG].Name = gsDigestAlgProperty;
aSequence[PKG_MNFST_DIGESTALG].Value <<= xml::crypto::DigestID::SHA1_1K;
- } else if ( aString == gsSHA256_1k_URL ) {
+ } else if ( aString == SHA256_1K_URL ) {
aSequence[PKG_MNFST_DIGESTALG].Name = gsDigestAlgProperty;
aSequence[PKG_MNFST_DIGESTALG].Value <<= xml::crypto::DigestID::SHA256_1K;
} else
bIgnoreEncryptData = true;
if ( !bIgnoreEncryptData ) {
- aString = rConvertedAttribs[gsChecksumAttribute];
+ aString = rConvertedAttribs[ATTRIBUTE_CHECKSUM];
uno::Sequence < sal_Int8 > aDecodeBuffer;
::comphelper::Base64::decode(aDecodeBuffer, aString);
aSequence[PKG_MNFST_DIGEST].Name = gsDigestProperty;
@@ -240,21 +180,21 @@ void ManifestImport::doAlgorithm(StringHashMap &rConvertedAttribs)
if ( bIgnoreEncryptData )
return;
- OUString aString = rConvertedAttribs[gsAlgorithmNameAttribute];
- if ( aString == gsBlowfish_Name || aString == gsBlowfish_URL ) {
+ OUString aString = rConvertedAttribs[ATTRIBUTE_ALGORITHM_NAME];
+ if ( aString == BLOWFISH_NAME || aString == BLOWFISH_URL ) {
aSequence[PKG_MNFST_ENCALG].Name = gsEncryptionAlgProperty;
aSequence[PKG_MNFST_ENCALG].Value <<= xml::crypto::CipherID::BLOWFISH_CFB_8;
- } else if ( aString == gsAES256_URL ) {
+ } else if ( aString == AES256_URL ) {
aSequence[PKG_MNFST_ENCALG].Name = gsEncryptionAlgProperty;
aSequence[PKG_MNFST_ENCALG].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING;
OSL_ENSURE( !nDerivedKeySize || nDerivedKeySize == 32, "Unexpected derived key length!" );
nDerivedKeySize = 32;
- } else if ( aString == gsAES192_URL ) {
+ } else if ( aString == AES192_URL ) {
aSequence[PKG_MNFST_ENCALG].Name = gsEncryptionAlgProperty;
aSequence[PKG_MNFST_ENCALG].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING;
OSL_ENSURE( !nDerivedKeySize || nDerivedKeySize == 24, "Unexpected derived key length!" );
nDerivedKeySize = 24;
- } else if ( aString == gsAES128_URL ) {
+ } else if ( aString == AES128_URL ) {
aSequence[PKG_MNFST_ENCALG].Name = gsEncryptionAlgProperty;
aSequence[PKG_MNFST_ENCALG].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING;
OSL_ENSURE( !nDerivedKeySize || nDerivedKeySize == 16, "Unexpected derived key length!" );
@@ -263,7 +203,7 @@ void ManifestImport::doAlgorithm(StringHashMap &rConvertedAttribs)
bIgnoreEncryptData = true;
if ( !bIgnoreEncryptData ) {
- aString = rConvertedAttribs[gsInitialisationVectorAttribute];
+ aString = rConvertedAttribs[ATTRIBUTE_INITIALISATION_VECTOR];
uno::Sequence < sal_Int8 > aDecodeBuffer;
::comphelper::Base64::decode(aDecodeBuffer, aString);
aSequence[PKG_MNFST_INIVECTOR].Name = gsInitialisationVectorProperty;
@@ -276,19 +216,19 @@ void ManifestImport::doKeyDerivation(StringHashMap &rConvertedAttribs)
if ( bIgnoreEncryptData )
return;
- OUString aString = rConvertedAttribs[gsKeyDerivationNameAttribute];
- if ( aString == gsPBKDF2_Name || aString == gsPBKDF2_URL ) {
- aString = rConvertedAttribs[gsSaltAttribute];
+ OUString aString = rConvertedAttribs[ATTRIBUTE_KEY_DERIVATION_NAME];
+ if ( aString == PBKDF2_NAME || aString == PBKDF2_URL ) {
+ aString = rConvertedAttribs[ATTRIBUTE_SALT];
uno::Sequence < sal_Int8 > aDecodeBuffer;
::comphelper::Base64::decode(aDecodeBuffer, aString);
aSequence[PKG_MNFST_SALT].Name = gsSaltProperty;
aSequence[PKG_MNFST_SALT].Value <<= aDecodeBuffer;
- aString = rConvertedAttribs[gsIterationCountAttribute];
+ aString = rConvertedAttribs[ATTRIBUTE_ITERATION_COUNT];
aSequence[PKG_MNFST_ITERATION].Name = gsIterationCountProperty;
aSequence[PKG_MNFST_ITERATION].Value <<= aString.toInt32();
- aString = rConvertedAttribs[gsKeySizeAttribute];
+ aString = rConvertedAttribs[ATTRIBUTE_KEY_SIZE];
if ( aString.getLength() ) {
sal_Int32 nKey = aString.toInt32();
OSL_ENSURE( !nDerivedKeySize || nKey == nDerivedKeySize , "Provided derived key length differs from the expected one!" );
@@ -309,11 +249,11 @@ void ManifestImport::doKeyDerivation(StringHashMap &rConvertedAttribs)
void ManifestImport::doStartKeyAlg(StringHashMap &rConvertedAttribs)
{
- OUString aString = rConvertedAttribs[gsStartKeyAlgNameAttribute];
- if (aString == gsSHA256_URL || aString == gsSHA256_URL_ODF12) {
+ OUString aString = rConvertedAttribs[ATTRIBUTE_START_KEY_GENERATION_NAME];
+ if (aString == SHA256_URL || aString == SHA256_URL_ODF12) {
aSequence[PKG_MNFST_STARTALG].Name = gsStartKeyAlgProperty;
aSequence[PKG_MNFST_STARTALG].Value <<= xml::crypto::DigestID::SHA256;
- } else if ( aString == gsSHA1_Name || aString == gsSHA1_URL ) {
+ } else if ( aString == SHA1_NAME || aString == SHA1_URL ) {
aSequence[PKG_MNFST_STARTALG].Name = gsStartKeyAlgProperty;
aSequence[PKG_MNFST_STARTALG].Value <<= xml::crypto::DigestID::SHA1;
} else
@@ -336,11 +276,11 @@ void SAL_CALL ManifestImport::startElement( const OUString& aName, const uno::Re
break;
}
case 2: {
- if (aConvertedName == gsFileEntryElement) //manifest:file-entry
+ if (aConvertedName == ELEMENT_FILE_ENTRY) //manifest:file-entry
doFileEntry(aConvertedAttribs);
- else if (aConvertedName == gsManifestKeyInfoElement) //loext:keyinfo
+ else if (aConvertedName == ELEMENT_MANIFEST_KEYINFO) //loext:keyinfo
;
- else if (aConvertedName == gsEncryptedKeyElement13) //manifest:encrypted-key
+ else if (aConvertedName == ELEMENT_ENCRYPTEDKEY13) //manifest:encrypted-key
doEncryptedKey(aConvertedAttribs);
else
aStack.back().m_bValid = false;
@@ -352,15 +292,15 @@ void SAL_CALL ManifestImport::startElement( const OUString& aName, const uno::Re
if (!aIter->m_bValid)
aStack.back().m_bValid = false;
- else if (aConvertedName == gsEncryptionDataElement) //manifest:encryption-data
+ else if (aConvertedName == ELEMENT_ENCRYPTION_DATA) //manifest:encryption-data
doEncryptionData(aConvertedAttribs);
- else if (aConvertedName == gsEncryptedKeyElement) //loext:encrypted-key
+ else if (aConvertedName == ELEMENT_ENCRYPTEDKEY) //loext:encrypted-key
doEncryptedKey(aConvertedAttribs);
- else if (aConvertedName == gsEncryptionMethodElement13) //manifest:encryption-method
- doEncryptionMethod(aConvertedAttribs, gsAlgorithmAttribute13);
- else if (aConvertedName == gsManifestKeyInfoElement13) //manifest:keyinfo
+ else if (aConvertedName == ELEMENT_ENCRYPTIONMETHOD13) //manifest:encryption-method
+ doEncryptionMethod(aConvertedAttribs, ATTRIBUTE_ALGORITHM13);
+ else if (aConvertedName == ELEMENT_MANIFEST13_KEYINFO) //manifest:keyinfo
;
- else if (aConvertedName == gsCipherDataElement13) //manifest:CipherData
+ else if (aConvertedName == ELEMENT_CIPHERDATA13) //manifest:CipherData
;
else
aStack.back().m_bValid = false;
@@ -372,21 +312,21 @@ void SAL_CALL ManifestImport::startElement( const OUString& aName, const uno::Re
if (!aIter->m_bValid)
aStack.back().m_bValid = false;
- else if (aConvertedName == gsAlgorithmElement) //manifest:algorithm,
+ else if (aConvertedName == ELEMENT_ALGORITHM) //manifest:algorithm,
doAlgorithm(aConvertedAttribs);
- else if (aConvertedName == gsKeyDerivationElement) //manifest:key-derivation,
+ else if (aConvertedName == ELEMENT_KEY_DERIVATION) //manifest:key-derivation,
doKeyDerivation(aConvertedAttribs);
- else if (aConvertedName == gsStartKeyAlgElement) //manifest:start-key-generation
+ else if (aConvertedName == ELEMENT_START_KEY_GENERATION) //manifest:start-key-generation
doStartKeyAlg(aConvertedAttribs);
- else if (aConvertedName == gsEncryptionMethodElement) //loext:encryption-method
- doEncryptionMethod(aConvertedAttribs, gsAlgorithmAttribute);
- else if (aConvertedName == gsKeyInfoElement) //loext:KeyInfo
+ else if (aConvertedName == ELEMENT_ENCRYPTIONMETHOD) //loext:encryption-method
+ doEncryptionMethod(aConvertedAttribs, ATTRIBUTE_ALGORITHM);
+ else if (aConvertedName == ELEMENT_ENCRYPTED_KEYINFO) //loext:KeyInfo
;
- else if (aConvertedName == gsCipherDataElement) //loext:CipherData
+ else if (aConvertedName == ELEMENT_CIPHERDATA) //loext:CipherData
;
- else if (aConvertedName == gsPgpDataElement13) //manifest:PGPData
+ else if (aConvertedName == ELEMENT_PGPDATA13) //manifest:PGPData
;
- else if (aConvertedName == gsCipherValueElement13) //manifest:CipherValue
+ else if (aConvertedName == ELEMENT_CIPHERVALUE13) //manifest:CipherValue
// ciphervalue action happens on endElement
aCurrentCharacters = "";
else
@@ -399,15 +339,15 @@ void SAL_CALL ManifestImport::startElement( const OUString& aName, const uno::Re
if (!aIter->m_bValid)
aStack.back().m_bValid = false;
- else if (aConvertedName == gsPgpDataElement) //loext:PGPData
+ else if (aConvertedName == ELEMENT_PGPDATA) //loext:PGPData
;
- else if (aConvertedName == gsCipherValueElement) //loext:CipherValue
+ else if (aConvertedName == ELEMENT_CIPHERVALUE) //loext:CipherValue
// ciphervalue action happens on endElement
aCurrentCharacters = "";
- else if (aConvertedName == gsPgpKeyIDElement13) //manifest:PGPKeyID
+ else if (aConvertedName == ELEMENT_PGPKEYID13) //manifest:PGPKeyID
// ciphervalue action happens on endElement
aCurrentCharacters = "";
- else if (aConvertedName == gsPGPKeyPacketElement13) //manifest:PGPKeyPacket
+ else if (aConvertedName == ELEMENT_PGPKEYPACKET13) //manifest:PGPKeyPacket
// ciphervalue action happens on endElement
aCurrentCharacters = "";
else
@@ -420,10 +360,10 @@ void SAL_CALL ManifestImport::startElement( const OUString& aName, const uno::Re
if (!aIter->m_bValid)
aStack.back().m_bValid = false;
- else if (aConvertedName == gsPgpKeyIDElement) //loext:PGPKeyID
+ else if (aConvertedName == ELEMENT_PGPKEYID) //loext:PGPKeyID
// ciphervalue action happens on endElement
aCurrentCharacters = "";
- else if (aConvertedName == gsPGPKeyPacketElement) //loext:PGPKeyPacket
+ else if (aConvertedName == ELEMENT_PGPKEYPACKET) //loext:PGPKeyPacket
// ciphervalue action happens on endElement
aCurrentCharacters = "";
else
@@ -454,7 +394,7 @@ void SAL_CALL ManifestImport::endElement( const OUString& aName )
if ( aStack.empty() || aStack.rbegin()->m_aConvertedName != aConvertedName )
return;
- if ( aConvertedName == gsFileEntryElement && aStack.back().m_bValid ) {
+ if ( aConvertedName == ELEMENT_FILE_ENTRY && aStack.back().m_bValid ) {
// root folder gets KeyInfo entry if any, for PGP encryption
if (!bIgnoreEncryptData && !aKeys.empty() && aSequence[PKG_MNFST_FULLPATH].Value.get<OUString>() == "/" )
{
@@ -469,8 +409,8 @@ void SAL_CALL ManifestImport::endElement( const OUString& aName )
aSequence.clear();
}
- else if ( (aConvertedName == gsEncryptedKeyElement
- || aConvertedName == gsEncryptedKeyElement13)
+ else if ( (aConvertedName == ELEMENT_ENCRYPTIONMETHOD
+ || aConvertedName == ELEMENT_ENCRYPTEDKEY13)
&& aStack.back().m_bValid ) {
if ( !bIgnoreEncryptData )
{
@@ -483,27 +423,27 @@ void SAL_CALL ManifestImport::endElement( const OUString& aName )
// end element handling for elements with cdata
switch (nLevel) {
case 4: {
- if (aConvertedName == gsCipherValueElement13) //manifest:CipherValue
+ if (aConvertedName == ELEMENT_CIPHERVALUE13) //manifest:CipherValue
doEncryptedCipherValue();
else
aStack.back().m_bValid = false;
break;
}
case 5: {
- if (aConvertedName == gsCipherValueElement) //loext:CipherValue
+ if (aConvertedName == ELEMENT_CIPHERVALUE) //loext:CipherValue
doEncryptedCipherValue();
- else if (aConvertedName == gsPgpKeyIDElement13) //manifest:PGPKeyID
+ else if (aConvertedName == ELEMENT_PGPKEYID13) //manifest:PGPKeyID
doEncryptedKeyId();
- else if (aConvertedName == gsPGPKeyPacketElement13) //manifest:PGPKeyPacket
+ else if (aConvertedName == ELEMENT_PGPKEYPACKET13) //manifest:PGPKeyPacket
doEncryptedKeyPacket();
else
aStack.back().m_bValid = false;
break;
}
case 6: {
- if (aConvertedName == gsPgpKeyIDElement) //loext:PGPKeyID
+ if (aConvertedName == ELEMENT_PGPKEYID) //loext:PGPKeyID
doEncryptedKeyId();
- else if (aConvertedName == gsPGPKeyPacketElement) //loext:PGPKeyPacket
+ else if (aConvertedName == ELEMENT_PGPKEYPACKET) //loext:PGPKeyPacket
doEncryptedKeyPacket();
else
aStack.back().m_bValid = false;