4 #include "CoralCommon/Cipher.h"
17 return readFromString(getUserName(), content);
22 reader.
read(keyFileName);
23 return readFromString(password,reader.
content());
29 if(pos==std::string::npos || pos==0){
30 std::stringstream
msg;
31 msg <<
"Provided Key is invalid.";
34 m_key = decodedContent.substr(0,pos);
35 m_dataSource = decodedContent.substr(pos+1);
41 std::stringstream
msg;
42 msg <<
"Invalid character ';' found in key string.";
50 std::string userName(
"");
51 struct passwd* userp = ::getpwuid(::getuid());
53 char* uName = userp->pw_name;
59 std::stringstream
msg;
60 msg <<
"Cannot determine login name.";
67 const std::string& dataSource,
const std::string& keyFileName){
69 std::stringstream
msg;
70 msg <<
"Provided password is empty.";
73 std::string content(
"");
76 std::stringstream
msg;
77 msg <<
"Invalid character ';' found in data file name string.";
83 keyFile.open(keyFileName.c_str());
86 std::stringstream
msg;
87 msg <<
"Cannot open the key file \""<<keyFileName<<
"\"";
90 keyFile << encodedContent;
static bool validateKey(const std::string &key)
bool readUserKeyString(const std::string &content)
bool readFromString(const std::string &password, const std::string &content)
bool read(const std::string &fileName)
bool decode(bool &, std::string const &)
static char DecodingKeySeparator(';')
static std::string getUserName()
static bool createFile(const std::string &password, const std::string &key, const std::string &dataSource, const std::string &keyFileName)
const std::string & content() const
static const std::string keyFile("/nfshome0/hcalsw/.ReadOMDSKey")
bool readFromFile(const std::string &password, const std::string &keyFileName)
bool readUserKey(const std::string &keyFileName)