1 #ifndef CORELIB___RESOURCE_INFO__HPP
2 #define CORELIB___RESOURCE_INFO__HPP
56 const string&
GetName(
void)
const {
return m_Name; }
59 const string&
GetValue(
void)
const {
return m_Value; }
62 void SetValue(
const string& new_value) { m_Value = new_value; }
75 operator bool(
void)
const {
return !x_IsEmpty(); }
97 bool x_IsEmpty(
void)
const {
return m_Name.empty(); }
100 string x_GetEncoded(
void)
const;
114 static string GetDefaultFileName(
void);
122 void SaveFile(
const string& new_name =
kEmptyStr);
127 const string& pwd)
const;
133 void DeleteResourceInfo(
const string& res_name,
151 void ParsePlainTextFile(
const string& filename);
156 string x_GetDataPassword(
const string& name_pwd,
157 const string& res_name)
const;
189 static string Encrypt(
const string& original_string);
204 static string Decrypt(
const string& encrypted_string);
207 static void Reload(
void);
217 static string Encrypt(
const string& original_string,
218 const string& password);
228 static string Decrypt(
const string& encrypted_string,
229 const string& password);
243 static string EncryptForDomain(
const string& original_string,
244 const string& domain);
257 static string DecryptForDomain(
const string& encrypted_string,
258 const string& domain);
267 static string GenerateKey(
const string&
seed);
278 static bool IsEncrypted(
const string& data);
281 static const char* GetVersion(
void);
314 static void sx_InitKeyMap(
void);
316 static string x_GetBinKeyChecksum(
const string&
key);
319 static string x_LoadKeys(
const string& filename,
TKeyMap* keys);
322 static string x_GetDomainKeys(
const string& domain,
TKeyMap* keys);
324 static string x_Encrypt(
const string& data,
const string&
key);
326 static string x_Decrypt(
const string& data,
const TKeyMap& keys);
329 static string x_AddSalt(
const string& data,
char version);
330 static string x_RemoveSalt(
const string& data,
char version);
351 switch ( GetErrCode() ) {
352 case eFileSave:
return "eFileSave";
353 case eParser:
return "eParser";
354 case eDecrypt:
return "eDecrypt";
378 switch ( GetErrCode() ) {
379 case eMissingKey:
return "eMissingKey";
380 case eBadPassword:
return "eBadPassword";
381 case eBadFormat:
return "eBadFormat";
382 case eBadDomain:
return "eBadDomain";
383 case eBadVersion:
return "eBadVersion";
Exception thrown by encryption classes.
virtual const char * GetErrCodeString(void) const override
NCBI_EXCEPTION_DEFAULT(CNcbiEncryptException, CException)
"NCBI keys file" – contains a set of encryption keys, one key per line.
static CSafeStatic< CNcbiEncrypt::TKeyMap > s_KeyMap
static CSafeStatic< string > s_DefaultKey
map< string, SEncryptionKeyInfo > TKeyMap
static volatile bool s_KeysInitialized
Exception thrown by resource info classes.
NCBI_EXCEPTION_DEFAULT(CNcbiResourceInfoException, CException)
virtual const char * GetErrCodeString(void) const override
Class for handling resource info files.
map< string, SResInfoCache > TCache
Class for storing encrypted resource information.
multimap< string, string > TExtraValuesMap
Types to access extra values.
CStringPairs< TExtraValuesMap > TExtraValues
void SetValue(const string &new_value)
Set new main value for the resource.
CNcbiResourceInfo(const CNcbiResourceInfo &)
bool x_IsEmpty(void) const
const string & GetName(void) const
Get resource name.
TExtraValues & GetExtraValues_NC(void)
Get non-const set of extra values associated with the resource.
const TExtraValues & GetExtraValues(void) const
Get read-only set of extra values associated with the resource.
CNcbiResourceInfo & operator=(const CNcbiResourceInfo &)
const string & GetValue(void) const
Get main value associated with the requested resource.
Helper class for object allocation/deallocation.
The NCBI C++ standard methods for dealing with std::string.
EDiagSev
Severity level for the posted diagnostics.
@ eDiag_Trace
Trace message.
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
#define EXCEPTION_VIRTUAL_BASE
Do not use virtual base classes in exception declaration at all, because in this case derived class s...
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define NCBI_XNCBI_EXPORT
const struct ncbi::grid::netcache::search::fields::KEY key
Static variables safety - create on demand, destroy on application termination.
Defines NCBI C++ exception handling.
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Defines Limits for the types used in NCBI C/C++ toolkit.
SEncryptionKeyInfo(const string &key, EDiagSev sev, const string &file, size_t line, char ver)
CRef< CNcbiResourceInfo > info