| 1 | // -------------------------------------------------------------------------- |
|---|
| 2 | // |
|---|
| 3 | // File |
|---|
| 4 | // Name: BackupStoreFilenameClear.h |
|---|
| 5 | // Purpose: BackupStoreFilenames in the clear |
|---|
| 6 | // Created: 2003/08/26 |
|---|
| 7 | // |
|---|
| 8 | // -------------------------------------------------------------------------- |
|---|
| 9 | |
|---|
| 10 | #ifndef BACKUPSTOREFILENAMECLEAR__H |
|---|
| 11 | #define BACKUPSTOREFILENAMECLEAR__H |
|---|
| 12 | |
|---|
| 13 | #include "BackupStoreFilename.h" |
|---|
| 14 | |
|---|
| 15 | class CipherContext; |
|---|
| 16 | |
|---|
| 17 | // -------------------------------------------------------------------------- |
|---|
| 18 | // |
|---|
| 19 | // Class |
|---|
| 20 | // Name: BackupStoreFilenameClear |
|---|
| 21 | // Purpose: BackupStoreFilenames, handling conversion from and to the in the clear version |
|---|
| 22 | // Created: 2003/08/26 |
|---|
| 23 | // |
|---|
| 24 | // -------------------------------------------------------------------------- |
|---|
| 25 | class BackupStoreFilenameClear : public BackupStoreFilename |
|---|
| 26 | { |
|---|
| 27 | public: |
|---|
| 28 | BackupStoreFilenameClear(); |
|---|
| 29 | BackupStoreFilenameClear(const std::string &rToEncode); |
|---|
| 30 | BackupStoreFilenameClear(const BackupStoreFilenameClear &rToCopy); |
|---|
| 31 | BackupStoreFilenameClear(const BackupStoreFilename &rToCopy); |
|---|
| 32 | virtual ~BackupStoreFilenameClear(); |
|---|
| 33 | |
|---|
| 34 | // Because we need to use a different allocator for this class to avoid |
|---|
| 35 | // nasty things happening, can't return this as a reference. Which is a |
|---|
| 36 | // pity. But probably not too bad. |
|---|
| 37 | #ifdef BACKUPSTOREFILEAME_MALLOC_ALLOC_BASE_TYPE |
|---|
| 38 | const std::string GetClearFilename() const; |
|---|
| 39 | #else |
|---|
| 40 | const std::string &GetClearFilename() const; |
|---|
| 41 | const std::string &GetClearFilenameIfPossible(const std::string& alternative) const; |
|---|
| 42 | #endif |
|---|
| 43 | void SetClearFilename(const std::string &rToEncode); |
|---|
| 44 | |
|---|
| 45 | // Setup for encryption of filenames |
|---|
| 46 | static void SetBlowfishKey(const void *pKey, int KeyLength, const void *pIV, int IVLength); |
|---|
| 47 | static void SetEncodingMethod(int Method); |
|---|
| 48 | |
|---|
| 49 | protected: |
|---|
| 50 | void MakeClearAvailable() const; |
|---|
| 51 | virtual void EncodedFilenameChanged(); |
|---|
| 52 | void EncryptClear(const std::string &rToEncode, CipherContext &rCipherContext, int StoreAsEncoding); |
|---|
| 53 | void DecryptEncoded(CipherContext &rCipherContext) const; |
|---|
| 54 | |
|---|
| 55 | private: |
|---|
| 56 | mutable BackupStoreFilename_base mClearFilename; |
|---|
| 57 | }; |
|---|
| 58 | |
|---|
| 59 | #endif // BACKUPSTOREFILENAMECLEAR__H |
|---|
| 60 | |
|---|
| 61 | |
|---|