summaryrefslogtreecommitdiff
path: root/lib/backupstore/BackupStoreFilenameClear.h
blob: b7cf555fd2f6554969b09a52b10abc55158fb90a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// --------------------------------------------------------------------------
//
// File
//		Name:    BackupStoreFilenameClear.h
//		Purpose: BackupStoreFilenames in the clear
//		Created: 2003/08/26
//
// --------------------------------------------------------------------------

#ifndef BACKUPSTOREFILENAMECLEAR__H
#define BACKUPSTOREFILENAMECLEAR__H

#include "BackupStoreFilename.h"

class CipherContext;

// --------------------------------------------------------------------------
//
// Class
//		Name:    BackupStoreFilenameClear
//		Purpose: BackupStoreFilenames, handling conversion from and to the in the clear version
//		Created: 2003/08/26
//
// --------------------------------------------------------------------------
class BackupStoreFilenameClear : public BackupStoreFilename
{
public:
	BackupStoreFilenameClear();
	BackupStoreFilenameClear(const std::string &rToEncode);
	BackupStoreFilenameClear(const BackupStoreFilenameClear &rToCopy);
	BackupStoreFilenameClear(const BackupStoreFilename &rToCopy);
	virtual ~BackupStoreFilenameClear();

	// Because we need to use a different allocator for this class to avoid
	// nasty things happening, can't return this as a reference. Which is a
	// pity. But probably not too bad.
#ifdef BACKUPSTOREFILEAME_MALLOC_ALLOC_BASE_TYPE
	const std::string GetClearFilename() const;
#else
	const std::string &GetClearFilename() const;
	const std::string &GetClearFilenameIfPossible(const std::string& alternative) const;
#endif
	void SetClearFilename(const std::string &rToEncode);

	// Setup for encryption of filenames
	static void SetBlowfishKey(const void *pKey, int KeyLength, const void *pIV, int IVLength);
	static void SetEncodingMethod(int Method);
	
protected:
	void MakeClearAvailable() const;
	virtual void EncodedFilenameChanged();
	void EncryptClear(const std::string &rToEncode, CipherContext &rCipherContext, int StoreAsEncoding);
	void DecryptEncoded(CipherContext &rCipherContext) const;

private:
	mutable BackupStoreFilename_base mClearFilename;
};

#endif // BACKUPSTOREFILENAMECLEAR__H