summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-05-28 11:43:09 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-06-02 08:28:19 +0100
commit4a7164429b727bd8fd6f183950e85e6225869364 (patch)
treeb96bc09cfe092cf51231ed83f0a446e4e4db3faf /package
parent6bd0f40d346a36d8b3d454fd0cf087d1ca126ee4 (diff)
count and order of receipt of properties doesn't matter
so stick imported properties into assigned slots and throw out empty ones when finished. Reuse existing ids for this between import and export. Shuffle FULLPATH to 0 as per import comment Change-Id: I516116c5327498ad043f6e2fb9bd257599ade2a2
Diffstat (limited to 'package')
-rw-r--r--package/inc/PackageConstants.hxx24
-rw-r--r--package/source/manifest/ManifestImport.cxx97
-rw-r--r--package/source/manifest/ManifestImport.hxx4
3 files changed, 67 insertions, 58 deletions
diff --git a/package/inc/PackageConstants.hxx b/package/inc/PackageConstants.hxx
index be82010175fc..7590acd951da 100644
--- a/package/inc/PackageConstants.hxx
+++ b/package/inc/PackageConstants.hxx
@@ -40,19 +40,19 @@ const sal_Int32 n_ConstDigestLength = 1024;
const sal_Int32 n_ConstDigestDecrypt = 1056; // 1024 + 32
// the constants related to the manifest.xml entries
-#define PKG_MNFST_MEDIATYPE 0
-#define PKG_MNFST_VERSION 1
-#define PKG_MNFST_FULLPATH 2
+#define PKG_MNFST_FULLPATH 0 //FullPath (Put full-path property first for MBA)
+#define PKG_MNFST_VERSION 1 //Version
+#define PKG_MNFST_MEDIATYPE 2 //MediaType
-#define PKG_MNFST_INIVECTOR 3
-#define PKG_MNFST_SALT 4
-#define PKG_MNFST_ITERATION 5
-#define PKG_MNFST_UCOMPSIZE 6
-#define PKG_MNFST_DIGEST 7
-#define PKG_MNFST_ENCALG 8
-#define PKG_MNFST_STARTALG 9
-#define PKG_MNFST_DIGESTALG 10
-#define PKG_MNFST_DERKEYSIZE 11
+#define PKG_MNFST_INIVECTOR 3 //InitialisationVector
+#define PKG_MNFST_SALT 4 //Salt
+#define PKG_MNFST_ITERATION 5 //IterationCount
+#define PKG_MNFST_UCOMPSIZE 6 //Size
+#define PKG_MNFST_DIGEST 7 //Digest
+#define PKG_MNFST_ENCALG 8 //EncryptionAlgorithm
+#define PKG_MNFST_STARTALG 9 //StartKeyAlgorithm
+#define PKG_MNFST_DIGESTALG 10 //DigestAlgorithm
+#define PKG_MNFST_DERKEYSIZE 11 //DerivedKeySize
#define PKG_SIZE_NOENCR_MNFST 3
#define PKG_SIZE_ENCR_MNFST 12
diff --git a/package/source/manifest/ManifestImport.cxx b/package/source/manifest/ManifestImport.cxx
index f8590fe42a25..ac6c3ef2590c 100644
--- a/package/source/manifest/ManifestImport.cxx
+++ b/package/source/manifest/ManifestImport.cxx
@@ -44,8 +44,7 @@ using ::rtl::OUString;
// ---------------------------------------------------
ManifestImport::ManifestImport( vector < Sequence < PropertyValue > > & rNewManVector )
-: nNumProperty ( 0 )
-, bIgnoreEncryptData ( sal_False )
+: bIgnoreEncryptData ( sal_False )
, nDerivedKeySize( 0 )
, rManVector ( rNewManVector )
@@ -126,28 +125,26 @@ void SAL_CALL ManifestImport::endDocument( )
void ManifestImport::doFileEntry(StringHashMap &rConvertedAttribs)
throw( uno::RuntimeException )
{
- aSequence.realloc ( PKG_SIZE_ENCR_MNFST );
+ aSequence.resize(PKG_SIZE_ENCR_MNFST);
- // Put full-path property first for MBA
- aSequence[nNumProperty].Name = sFullPathProperty;
- aSequence[nNumProperty++].Value <<= rConvertedAttribs[sFullPathAttribute];
- aSequence[nNumProperty].Name = sMediaTypeProperty;
- aSequence[nNumProperty++].Value <<= rConvertedAttribs[sMediaTypeAttribute];
+ aSequence[PKG_MNFST_FULLPATH].Name = sFullPathProperty;
+ aSequence[PKG_MNFST_FULLPATH].Value <<= rConvertedAttribs[sFullPathAttribute];
+ aSequence[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
+ aSequence[PKG_MNFST_MEDIATYPE].Value <<= rConvertedAttribs[sMediaTypeAttribute];
OUString sVersion = rConvertedAttribs[sVersionAttribute];
if ( sVersion.getLength() )
{
- aSequence[nNumProperty].Name = sVersionProperty;
- aSequence[nNumProperty++].Value <<= sVersion;
+ aSequence[PKG_MNFST_VERSION].Name = sVersionProperty;
+ aSequence[PKG_MNFST_VERSION].Value <<= sVersion;
}
OUString sSize = rConvertedAttribs[sSizeAttribute];
if ( sSize.getLength() )
{
- sal_Int32 nSize;
- nSize = sSize.toInt32();
- aSequence[nNumProperty].Name = sSizeProperty;
- aSequence[nNumProperty++].Value <<= nSize;
+ sal_Int32 nSize = sSize.toInt32();
+ aSequence[PKG_MNFST_UCOMPSIZE].Name = sSizeProperty;
+ aSequence[PKG_MNFST_UCOMPSIZE].Value <<= nSize;
}
}
@@ -162,13 +159,13 @@ void ManifestImport::doEncryptionData(StringHashMap &rConvertedAttribs)
{
if ( aString.equals( sSHA1_1k_Name ) || aString.equals( sSHA1_1k_URL ) )
{
- aSequence[nNumProperty].Name = sDigestAlgProperty;
- aSequence[nNumProperty++].Value <<= xml::crypto::DigestID::SHA1_1K;
+ aSequence[PKG_MNFST_DIGESTALG].Name = sDigestAlgProperty;
+ aSequence[PKG_MNFST_DIGESTALG].Value <<= xml::crypto::DigestID::SHA1_1K;
}
else if ( aString.equals( sSHA256_1k_URL ) )
{
- aSequence[nNumProperty].Name = sDigestAlgProperty;
- aSequence[nNumProperty++].Value <<= xml::crypto::DigestID::SHA256_1K;
+ aSequence[PKG_MNFST_DIGESTALG].Name = sDigestAlgProperty;
+ aSequence[PKG_MNFST_DIGESTALG].Value <<= xml::crypto::DigestID::SHA256_1K;
}
else
bIgnoreEncryptData = sal_True;
@@ -178,8 +175,8 @@ void ManifestImport::doEncryptionData(StringHashMap &rConvertedAttribs)
aString = rConvertedAttribs[sChecksumAttribute];
uno::Sequence < sal_Int8 > aDecodeBuffer;
::sax::Converter::decodeBase64(aDecodeBuffer, aString);
- aSequence[nNumProperty].Name = sDigestProperty;
- aSequence[nNumProperty++].Value <<= aDecodeBuffer;
+ aSequence[PKG_MNFST_DIGEST].Name = sDigestProperty;
+ aSequence[PKG_MNFST_DIGEST].Value <<= aDecodeBuffer;
}
}
}
@@ -192,27 +189,27 @@ void ManifestImport::doAlgorithm(StringHashMap &rConvertedAttribs)
OUString aString = rConvertedAttribs[sAlgorithmNameAttribute];
if ( aString.equals( sBlowfish_Name ) || aString.equals( sBlowfish_URL ) )
{
- aSequence[nNumProperty].Name = sEncryptionAlgProperty;
- aSequence[nNumProperty++].Value <<= xml::crypto::CipherID::BLOWFISH_CFB_8;
+ aSequence[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty;
+ aSequence[PKG_MNFST_ENCALG].Value <<= xml::crypto::CipherID::BLOWFISH_CFB_8;
}
else if ( aString.equals( sAES256_URL ) )
{
- aSequence[nNumProperty].Name = sEncryptionAlgProperty;
- aSequence[nNumProperty++].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING;
+ aSequence[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty;
+ 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.equals( sAES192_URL ) )
{
- aSequence[nNumProperty].Name = sEncryptionAlgProperty;
- aSequence[nNumProperty++].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING;
+ aSequence[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty;
+ 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.equals( sAES128_URL ) )
{
- aSequence[nNumProperty].Name = sEncryptionAlgProperty;
- aSequence[nNumProperty++].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING;
+ aSequence[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty;
+ aSequence[PKG_MNFST_ENCALG].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING;
OSL_ENSURE( !nDerivedKeySize || nDerivedKeySize == 16, "Unexpected derived key length!" );
nDerivedKeySize = 16;
}
@@ -224,8 +221,8 @@ void ManifestImport::doAlgorithm(StringHashMap &rConvertedAttribs)
aString = rConvertedAttribs[sInitialisationVectorAttribute];
uno::Sequence < sal_Int8 > aDecodeBuffer;
::sax::Converter::decodeBase64(aDecodeBuffer, aString);
- aSequence[nNumProperty].Name = sInitialisationVectorProperty;
- aSequence[nNumProperty++].Value <<= aDecodeBuffer;
+ aSequence[PKG_MNFST_INIVECTOR].Name = sInitialisationVectorProperty;
+ aSequence[PKG_MNFST_INIVECTOR].Value <<= aDecodeBuffer;
}
}
}
@@ -241,12 +238,12 @@ void ManifestImport::doKeyDerivation(StringHashMap &rConvertedAttribs)
aString = rConvertedAttribs[sSaltAttribute];
uno::Sequence < sal_Int8 > aDecodeBuffer;
::sax::Converter::decodeBase64(aDecodeBuffer, aString);
- aSequence[nNumProperty].Name = sSaltProperty;
- aSequence[nNumProperty++].Value <<= aDecodeBuffer;
+ aSequence[PKG_MNFST_SALT].Name = sSaltProperty;
+ aSequence[PKG_MNFST_SALT].Value <<= aDecodeBuffer;
aString = rConvertedAttribs[sIterationCountAttribute];
- aSequence[nNumProperty].Name = sIterationCountProperty;
- aSequence[nNumProperty++].Value <<= aString.toInt32();
+ aSequence[PKG_MNFST_ITERATION].Name = sIterationCountProperty;
+ aSequence[PKG_MNFST_ITERATION].Value <<= aString.toInt32();
aString = rConvertedAttribs[sKeySizeAttribute];
if ( aString.getLength() )
@@ -260,8 +257,8 @@ void ManifestImport::doKeyDerivation(StringHashMap &rConvertedAttribs)
else if ( nDerivedKeySize != 16 )
OSL_ENSURE( sal_False, "Default derived key length differs from the expected one!" );
- aSequence[nNumProperty].Name = sDerivedKeySizeProperty;
- aSequence[nNumProperty++].Value <<= nDerivedKeySize;
+ aSequence[PKG_MNFST_DERKEYSIZE].Name = sDerivedKeySizeProperty;
+ aSequence[PKG_MNFST_DERKEYSIZE].Value <<= nDerivedKeySize;
}
else
bIgnoreEncryptData = sal_True;
@@ -274,13 +271,13 @@ void ManifestImport::doStartKeyAlg(StringHashMap &rConvertedAttribs)
OUString aString = rConvertedAttribs[sStartKeyAlgNameAttribute];
if ( aString.equals( sSHA256_URL ) )
{
- aSequence[nNumProperty].Name = sStartKeyAlgProperty;
- aSequence[nNumProperty++].Value <<= xml::crypto::DigestID::SHA256;
+ aSequence[PKG_MNFST_STARTALG].Name = sStartKeyAlgProperty;
+ aSequence[PKG_MNFST_STARTALG].Value <<= xml::crypto::DigestID::SHA256;
}
else if ( aString.equals( sSHA1_Name ) || aString.equals( sSHA1_URL ) )
{
- aSequence[nNumProperty].Name = sStartKeyAlgProperty;
- aSequence[nNumProperty++].Value <<= xml::crypto::DigestID::SHA1;
+ aSequence[PKG_MNFST_STARTALG].Name = sStartKeyAlgProperty;
+ aSequence[PKG_MNFST_STARTALG].Value <<= xml::crypto::DigestID::SHA1;
}
else
bIgnoreEncryptData = sal_True;
@@ -349,6 +346,14 @@ void SAL_CALL ManifestImport::startElement( const OUString& aName, const uno::Re
}
}
+namespace
+{
+ bool isEmpty(const com::sun::star::beans::PropertyValue &rProp)
+ {
+ return rProp.Name.isEmpty();
+ }
+}
+
// ---------------------------------------------------
void SAL_CALL ManifestImport::endElement( const OUString& aName )
throw( xml::sax::SAXException, uno::RuntimeException )
@@ -356,12 +361,16 @@ void SAL_CALL ManifestImport::endElement( const OUString& aName )
::rtl::OUString aConvertedName = ConvertName( aName );
if ( !aStack.empty() && aStack.rbegin()->m_aConvertedName.equals( aConvertedName ) )
{
- if ( aConvertedName.equals( sFileEntryElement ) )
+ if ( aConvertedName.equals( sFileEntryElement ) && aStack.back().m_bValid )
{
- aSequence.realloc ( nNumProperty );
+ com::sun::star::beans::PropertyValue aEmpty;
+ aSequence.erase(std::remove_if(aSequence.begin(), aSequence.end(),
+ isEmpty), aSequence.end());
+
bIgnoreEncryptData = sal_False;
- rManVector.push_back ( aSequence );
- nNumProperty = 0;
+ rManVector.push_back ( aSequence.getAsConstList() );
+
+ aSequence.clear();
}
aStack.pop_back();
diff --git a/package/source/manifest/ManifestImport.hxx b/package/source/manifest/ManifestImport.hxx
index 5681f4598ed4..68afefd3f148 100644
--- a/package/source/manifest/ManifestImport.hxx
+++ b/package/source/manifest/ManifestImport.hxx
@@ -31,6 +31,7 @@
#include <cppuhelper/implbase1.hxx> // helper for implementations
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <comphelper/sequenceasvector.hxx>
#include <vector>
#include <HashMaps.hxx>
@@ -63,8 +64,7 @@ typedef ::std::vector< ManifestScopeEntry > ManifestStack;
class ManifestImport : public cppu::WeakImplHelper1 < com::sun::star::xml::sax::XDocumentHandler >
{
protected:
- com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > aSequence;
- sal_Int16 nNumProperty;
+ comphelper::SequenceAsVector< com::sun::star::beans::PropertyValue > aSequence;
ManifestStack aStack;
sal_Bool bIgnoreEncryptData;
sal_Int32 nDerivedKeySize;