|
|
#include <DecodingKey.h>
Definition at line 31 of file DecodingKey.h.
◆ DecodingKey()
cond::auth::DecodingKey::DecodingKey |
( |
| ) |
|
|
inline |
◆ ~DecodingKey()
virtual cond::auth::DecodingKey::~DecodingKey |
( |
| ) |
|
|
inlinevirtual |
◆ addDefaultService()
void cond::auth::DecodingKey::addDefaultService |
( |
const std::string & |
connectionString | ) |
|
◆ addService()
void cond::auth::DecodingKey::addService |
( |
const std::string & |
serviceName, |
|
|
const std::string & |
connectionString, |
|
|
const std::string & |
userName, |
|
|
const std::string & |
password |
|
) |
| |
◆ createFromInputFile()
size_t cond::auth::DecodingKey::createFromInputFile |
( |
const std::string & |
inputFileName, |
|
|
size_t |
generatedKeySize = 0 |
|
) |
| |
Definition at line 195 of file DecodingKey.cc.
208 std::map<std::string, std::string>
params;
213 if (
line.size() > 3) {
225 ServiceCredentials creds;
References CONNECTIONPREFIX(), cond::auth::ServiceCredentials::connectionString, relval_steps::gen(), dtResolutionTest_cfi::inputFile, InefficientDoubleROC::inputFileName, KEYPREFIX(), mps_splice::line, mps_check::msg, NAMEPREFIX(), OWNERPREFIX(), CalibrationSummaryClient_cfi::params, cond::parseLineForNamedParams(), cond::auth::ServiceCredentials::password, PASSWORDPREFIX(), serviceName, SERVICEPREFIX(), AlCaHLTBitMon_QueryRunRegistry::string, cond::throwException(), cond::auth::ServiceCredentials::userName, USERPREFIX(), and VERSIONPREFIX().
◆ flush()
void cond::auth::DecodingKey::flush |
( |
| ) |
|
Definition at line 261 of file DecodingKey.cc.
278 for (std::map<std::string, ServiceCredentials>::const_iterator iD =
m_services.begin(); iD !=
m_services.end();
286 Cipher cipher(
m_pwd);
288 size_t outSize = cipher.encrypt(
content.str(),
out);
289 outFile.write(reinterpret_cast<char*>(
out), outSize);
293 msg +=
"Provided Key File \"" +
m_fileName +
"\n is invalid.";
References Skims_PA_cff::content, cond::auth::Cipher::encrypt(), ItemSeparator, KEY_HEADER(), KEYPREFIX(), LineSeparator, mps_check::msg, NAMEPREFIX(), MillePedeFileConverter_cfg::out, L1TdeCSCTF_cfi::outFile, OWNERPREFIX(), SERVICEPREFIX(), AlCaHLTBitMon_QueryRunRegistry::string, cond::throwException(), and VERSIONPREFIX().
◆ init()
size_t cond::auth::DecodingKey::init |
( |
const std::string & |
keyFileName, |
|
|
const std::string & |
password, |
|
|
bool |
readMode = true |
|
) |
| |
Definition at line 113 of file DecodingKey.cc.
114 if (keyFileName.empty()) {
130 size_t fsize =
keyFile.tellg();
131 unsigned char* buff = (
unsigned char*)malloc(fsize);
132 keyFile.seekg(0, std::ios::beg);
133 keyFile.read(reinterpret_cast<char*>(buff), fsize);
134 Cipher cipher(
m_pwd);
146 if (
line.size() > 3) {
156 std::stringstream serviceStr(
line.substr(2));
157 std::vector<std::string> sdata;
158 while (serviceStr.good()) {
162 std::map<std::string, ServiceCredentials>::iterator iS =
163 m_services.insert(std::make_pair(sdata[0], ServiceCredentials())).first;
164 iS->second.connectionString = sdata[1];
165 iS->second.userName = sdata[2];
166 iS->second.password = sdata[3];
183 std::string msg =
"Provided key is invalid for user=" + currentUser;
References Skims_PA_cff::content, cond::auth::Cipher::decrypt(), cond::getLoginName(), recoMuon::in, ItemSeparator, KEY_HEADER(), keyFile(), KEYPREFIX(), mps_splice::line, LineSeparator, mps_check::msg, NAMEPREFIX(), OWNERPREFIX(), EcalCondDBWriter_cfi::password, SERVICEPREFIX(), str, AlCaHLTBitMon_QueryRunRegistry::string, cond::throwException(), and VERSIONPREFIX().
◆ isNominal()
bool cond::auth::DecodingKey::isNominal |
( |
| ) |
const |
|
inline |
◆ list()
void cond::auth::DecodingKey::list |
( |
std::ostream & |
out | ) |
|
◆ ownerName()
const std::string & cond::auth::DecodingKey::ownerName |
( |
| ) |
const |
|
inline |
◆ principalKey()
const std::string & cond::auth::DecodingKey::principalKey |
( |
| ) |
const |
|
inline |
◆ principalName()
const std::string & cond::auth::DecodingKey::principalName |
( |
| ) |
const |
|
inline |
◆ services()
◆ templateFile()
std::string cond::auth::DecodingKey::templateFile |
( |
| ) |
|
|
static |
Definition at line 97 of file DecodingKey.cc.
100 s <<
NAMEPREFIX <<
"<principal_name>" << std::endl;
101 s <<
OWNERPREFIX <<
"<owner_name, optional>" << std::endl;
102 s <<
KEYPREFIX <<
"<key, leave empty if generated>" << std::endl;
105 <<
"<user0_name>;" <<
PASSWORDPREFIX <<
"<password0>;" << std::endl;
107 <<
"<user1_name>;" <<
PASSWORDPREFIX <<
"<password1>;" << std::endl;
109 <<
"<user2_name>;" <<
PASSWORDPREFIX <<
"<password2>;" << std::endl;
References CONNECTIONPREFIX(), KEYPREFIX(), NAMEPREFIX(), OWNERPREFIX(), PASSWORDPREFIX(), alignCSCRings::s, SERVICEPREFIX(), USERPREFIX(), and VERSIONPREFIX().
◆ version()
const std::string & cond::auth::DecodingKey::version |
( |
| ) |
const |
|
inline |
◆ DEFAULT_KEY_SIZE
constexpr size_t cond::auth::DecodingKey::DEFAULT_KEY_SIZE = 100 |
|
staticconstexpr |
◆ FILE_NAME
constexpr const char* const cond::auth::DecodingKey::FILE_NAME = "db.key" |
|
staticconstexpr |
◆ FILE_PATH
constexpr const char* const cond::auth::DecodingKey::FILE_PATH = ".cms_cond/db.key" |
|
staticconstexpr |
◆ KEY_FMT_VERSION
constexpr const char* const cond::auth::DecodingKey::KEY_FMT_VERSION = "2.0" |
|
staticconstexpr |
◆ m_fileName
std::string cond::auth::DecodingKey::m_fileName |
|
private |
◆ m_mode
bool cond::auth::DecodingKey::m_mode |
|
private |
◆ m_owner
std::string cond::auth::DecodingKey::m_owner |
|
private |
◆ m_principalKey
std::string cond::auth::DecodingKey::m_principalKey |
|
private |
◆ m_principalName
std::string cond::auth::DecodingKey::m_principalName |
|
private |
◆ m_pwd
std::string cond::auth::DecodingKey::m_pwd |
|
private |
◆ m_services
◆ m_version
std::string cond::auth::DecodingKey::m_version |
|
private |
constexpr char ItemSeparator
static const std::string OWNERPREFIX("O=")
std::string m_principalName
static const std::string PASSWORDPREFIX("P=")
std::string getLoginName()
static const std::string CONNECTIONPREFIX("C=")
static const std::string serviceName
static const std::string NAMEPREFIX("N=")
static constexpr const char *const KEY_FMT_VERSION
static const std::string keyFile("/nfshome0/hcalsw/.ReadOMDSKey")
static const std::string KEYPREFIX("K=")
void parseLineForNamedParams(const std::string &line, std::map< std::string, std::string > ¶ms)
std::string m_principalKey
static const std::string USERPREFIX("U=")
static const std::string VERSIONPREFIX("V=")
static const std::string SERVICEPREFIX("S=")
def gen(fragment, howMuch)
Production test section ####.
static const std::string DEFAULT_SERVICE("Cond_Default_Service")
static const std::string KEY_HEADER("Cond_Authentication_Key")
void addService(const std::string &serviceName, const std::string &connectionString, const std::string &userName, const std::string &password)
constexpr char LineSeparator
std::map< std::string, ServiceCredentials > m_services
void throwException(const std::string &message, const std::string &methodName)