CMS 3D CMS Logo

Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
cond Namespace Reference

Namespaces

 auth
 
 payloadInspector
 
 persistency
 
 RelationalAuthenticationService
 
 serialization
 
 service
 
 time
 
 XMLAuthenticationService
 

Classes

struct  AuthorizationData
 
class  BaseKeyed
 
class  BasicPayload
 
class  Binary
 
class  BTransitionAnalyzer
 
class  CoralServiceFactory
 
class  CoralServiceManager
 
struct  CoralServiceWrapper
 
struct  CoralServiceWrapperBase
 
struct  CredentialData
 
class  CredentialStore
 
class  CSScopedSession
 
class  DataProxyWrapperBase
 
struct  DefaultInitializer
 
class  EmptyIOVSource
 
class  FileBasedEmptySource
 
class  FileReader
 
class  GenericSummary
 
class  GTEntry_t
 
struct  GTMetadata_t
 
struct  Iov_t
 
class  IOVDescription
 
class  IOVKeysDescription
 
class  IOVProvenance
 
class  IOVUserMetaData
 
class  KeyedElement
 
struct  LessFrame
 
struct  LogDBEntry_t
 
struct  PrincipalData
 
struct  RealTimeType
 
struct  RealTimeType< hash >
 
struct  RealTimeType< lumiid >
 
struct  RealTimeType< runnumber >
 
struct  RealTimeType< timestamp >
 
struct  RealTimeType< userid >
 
struct  RunInfo_t
 
class  SmallWORMDict
 
class  StreamerInfo
 
class  Summary
 
struct  Tag_t
 
struct  TagInfo_t
 
struct  TagMetadata_t
 
struct  TimeTypeSpecs
 
struct  TimeTypeTraits
 
class  UnregisteredRecordException
 
struct  UserLogInfo
 
class  Utilities
 
class  UtilitiesError
 

Typedefs

typedef cond::serialization::InputArchive CondInputArchive
 
typedef cond::serialization::OutputArchive CondOutputArchive
 
typedef edmplugin::PluginFactory< cond::CoralServiceWrapperBase *()> CoralServicePluginFactory
 
typedef persistency::Exception Exception
 
typedef std::string Hash
 
typedef edmplugin::PluginFactory< cond::DataProxyWrapperBase *()> ProxyFactory
 
typedef unsigned long long Time_t
 
typedef unsigned long long uint64_t
 
typedef std::pair< unsigned int, unsigned int > UnpackedTime
 
typedef std::pair< Time_t, Time_tValidityInterval
 

Enumerations

enum  SynchronizationType {
  SYNCH_ANY = 0, SYNCH_VALIDATION, SYNCH_OFFLINE, SYNCH_MC,
  SYNCH_RUNMC, SYNCH_HLT, SYNCH_EXPRESS, SYNCH_PROMPT,
  SYNCH_PCL
}
 
enum  TimeType {
  invalid = -1, runnumber = 0, timestamp, lumiid,
  hash, userid
}
 

Functions

template<typename T >
TcreatePayload (const std::string &payloadTypeName)
 
template<>
HcalCalibrationQIEDatacreatePayload< HcalCalibrationQIEData > (const std::string &payloadTypeName)
 
template<>
std::string * createPayload< std::string > (const std::string &payloadTypeName)
 
template<typename T >
std::unique_ptr< Tdefault_deserialize (const std::string &payloadType, const Binary &payloadData, const Binary &streamerInfoData)
 
template<typename T >
std::unique_ptr< Tdeserialize (const std::string &payloadType, const Binary &payloadData, const Binary &streamerInfoData)
 
template<>
std::unique_ptr< BaseKeyeddeserialize< BaseKeyed > (const std::string &payloadType, const Binary &payloadData, const Binary &streamerInfoData)
 
template<>
std::unique_ptr< condex::Efficiencydeserialize< condex::Efficiency > (const std::string &payloadType, const Binary &payloadData, const Binary &streamerInfoData)
 
template<>
std::unique_ptr< CSCReadoutMappingdeserialize< CSCReadoutMapping > (const std::string &payloadType, const Binary &payloadData, const Binary &streamerInfoData)
 
template<>
std::unique_ptr< CSCReadoutMappingForSliceTestdeserialize< CSCReadoutMappingForSliceTest > (const std::string &payloadType, const Binary &payloadData, const Binary &streamerInfoData)
 
template<>
std::unique_ptr< PerformancePayloaddeserialize< PerformancePayload > (const std::string &payloadType, const Binary &payloadData, const Binary &streamerInfoData)
 
const TimeTypeSpecsfindSpecs (std::string const &name)
 
int getch ()
 
std::pair< std::string, std::string > getDbCredentials (const std::string &connectionString, bool updateMode, const std::string &authPath)
 
cond::Time_t getLastLumiFromOMS (const std::string &omsServiceUrl)
 
cond::Time_t getLatestLumiFromFile (const std::string &fileName)
 
std::string getLoginName ()
 
bool getNextSequenceValue (const std::string &schemaVersion, coral::ISchema &schema, const std::string &sequenceName, int &value)
 
std::string getpass (const std::string &prompt, bool show_asterisk=true)
 
std::string getpassForUser (const std::string &userName)
 
unsigned long long hash64 (unsigned char *k, unsigned long long length, unsigned long long level)
 
const Time_t invalidTime (0)
 
const std::string invalidToken (" ")
 
Iov_t makeIov (cond::Time_t since, const Hash &payloadId)
 
void parseLineForNamedParams (const std::string &line, std::map< std::string, std::string > &params)
 
const char * pluginCategory ()
 
char randomChar ()
 
std::string schemaLabel (const std::string &serviceName, const std::string &userName)
 
std::string schemaLabelForCredentialStore (const std::string &connectionString)
 
bool selectAuthorization (const std::string &schemaVersion, coral::ISchema &schema, int principalId, const std::string &role, const std::string &connectionString, AuthorizationData &destination)
 
bool selectConnection (const std::string &schemaVersion, coral::ISchema &schema, const std::string &connectionLabel, CredentialData &destination)
 
bool selectPrincipal (const std::string &schemaVersion, coral::ISchema &schema, const std::string &principal, PrincipalData &destination)
 
template<typename T >
std::pair< Binary, Binaryserialize (const T &payload)
 
bool setPermissionData (const std::string &schemaVersion, coral::ISchema &schema, int principalId, const std::string &principalKey, const std::string &role, const std::string &connectionString, int connectionId, const std::string &connectionKey, std::stringstream &log)
 
SynchronizationType synchronizationTypeFromName (const std::string &name)
 
std::string synchronizationTypeNames (SynchronizationType type)
 
void throwException (const std::string &message, const std::string &methodName)
 
const Time_t TIMELIMIT (std::numeric_limits< Time_t >::max())
 
std::string const & timeTypeNames (int)
 
std::pair< int, std::string > updateConnectionData (const std::string &schemaVersion, coral::ISchema &schema, const std::string &adminKey, const std::string &connectionLabel, const std::string &userName, const std::string &password, bool forceUpdate, std::stringstream &log)
 
std::pair< int, std::string > updatePrincipalData (const std::string &schemaVersion, coral::ISchema &schema, const std::string &authenticationKey, const std::string &principalName, const std::string &adminKey, bool init, std::stringstream &log)
 

Variables

static constexpr unsigned int HASH_SIZE = 40
 
static std::pair< const char *, SynchronizationTypes_obsoleteSynchronizationTypeArray []
 
static std::pair< const char *, SynchronizationTypes_synchronizationTypeArray []
 
const unsigned int TIMETYPE_LIST_MAX = 5
 
const cond::TimeType timeTypeList [TIMETYPE_LIST_MAX] = {runnumber, timestamp, lumiid, hash, userid}
 
const TimeTypeSpecs timeTypeSpecs []
 
const cond::TimeType timeTypeValues [] = {runnumber, timestamp, lumiid, hash, userid}
 

Detailed Description

The wrapper is used to allow edm::PluginFactory to change its return type to unique_ptr from a raw pointer. The unique_ptr does not work for coral::Service, because its destructor is protected and ownership is managed by intrusive reference counting.

Serialization.h CondCore/CondDB/interface/Serialization.h Description: functions for serializing the payload objects.

Typedef Documentation

◆ CondInputArchive

Definition at line 61 of file Serialization.h.

◆ CondOutputArchive

Definition at line 62 of file Serialization.h.

◆ CoralServicePluginFactory

Definition at line 25 of file CoralServiceFactory.h.

◆ Exception

Definition at line 25 of file Exception.h.

◆ Hash

typedef std::string cond::Hash

Definition at line 43 of file Types.h.

◆ ProxyFactory

Definition at line 29 of file ProxyFactory.h.

◆ Time_t

typedef unsigned long long cond::Time_t

Definition at line 14 of file Time.h.

◆ uint64_t

typedef unsigned long long cond::uint64_t

Definition at line 13 of file Time.h.

◆ UnpackedTime

typedef std::pair<unsigned int, unsigned int> cond::UnpackedTime

Definition at line 15 of file Time.h.

◆ ValidityInterval

typedef std::pair<Time_t, Time_t> cond::ValidityInterval

Definition at line 17 of file Time.h.

Enumeration Type Documentation

◆ SynchronizationType

Enumerator
SYNCH_ANY 
SYNCH_VALIDATION 
SYNCH_OFFLINE 
SYNCH_MC 
SYNCH_RUNMC 
SYNCH_HLT 
SYNCH_EXPRESS 
SYNCH_PROMPT 
SYNCH_PCL 

Definition at line 27 of file Types.h.

27  {
28  SYNCH_ANY = 0,
31  SYNCH_MC,
33  SYNCH_HLT,
36  SYNCH_PCL

◆ TimeType

Enumerator
invalid 
runnumber 
timestamp 
lumiid 
hash 
userid 

Definition at line 19 of file Time.h.

Function Documentation

◆ createPayload()

template<typename T >
T* cond::createPayload ( const std::string &  payloadTypeName)

Definition at line 31 of file Serialization.h.

31  {
32  std::string userTypeName = demangledName(typeid(T));
33  if (userTypeName != payloadTypeName)
35  std::string("Type mismatch, user type: \"" + userTypeName + "\", target type: \"") + payloadTypeName + "\"",
36  "createPayload");
37  return new T;
38  }

References AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

◆ createPayload< HcalCalibrationQIEData >()

template<>
HcalCalibrationQIEData* cond::createPayload< HcalCalibrationQIEData > ( const std::string &  payloadTypeName)

Definition at line 37 of file plugin.cc.

37  {
38  if (payloadTypeName == "HcalCalibrationQIEData")
39  return new HcalCalibrationQIEData(nullptr);
40  throwException(std::string("Type mismatch, target object is type \"") + payloadTypeName + "\"", "createPayload");
41  }

References AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

◆ createPayload< std::string >()

template<>
std::string* cond::createPayload< std::string > ( const std::string &  payloadTypeName)
inline

Definition at line 41 of file Serialization.h.

41  {
42  std::string userTypeName = demangledName(typeid(std::string));
43  if (payloadTypeName != userTypeName && payloadTypeName != "std::string")
44  throwException(std::string("Type mismatch, user type: \"std::string\", target type: \"") + payloadTypeName + "\"",
45  "createPayload");
46  return new std::string;
47  }

References AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

◆ default_deserialize()

template<typename T >
std::unique_ptr<T> cond::default_deserialize ( const std::string &  payloadType,
const Binary payloadData,
const Binary streamerInfoData 
)

Definition at line 86 of file Serialization.h.

88  {
89  std::unique_ptr<T> payload;
90  std::stringbuf sstreamerInfoBuf;
91  sstreamerInfoBuf.pubsetbuf(static_cast<char*>(const_cast<void*>(streamerInfoData.data())), streamerInfoData.size());
92  std::string streamerInfo = sstreamerInfoBuf.str();
93  try {
94  std::stringbuf sdataBuf;
95  sdataBuf.pubsetbuf(static_cast<char*>(const_cast<void*>(payloadData.data())), payloadData.size());
96  std::istream dataBuffer(&sdataBuf);
97  CondInputArchive ia(dataBuffer);
98  payload.reset(createPayload<T>(payloadType));
99  ia >> (*payload);
100  } catch (const std::exception& e) {
101  std::string errorMsg("De-serialization failed: ");
102  std::string em(e.what());
103  if (em == "unsupported version") {
104  errorMsg += "the current boost version (" + StreamerInfo::techVersion() +
105  ") is unable to read the payload. Data might have been serialized with an incompatible version.";
106  } else if (em == "input stream error") {
107  errorMsg += "data size does not fit with the current class layout. The Class " + payloadType +
108  " might have been changed with respect to the layout used in the upload.";
109  } else {
110  errorMsg += em;
111  }
112  if (!streamerInfo.empty())
113  errorMsg += " Payload serialization info: " + streamerInfo;
114  throwException(errorMsg, "default_deserialize");
115  }
116  return payload;
117  }

References cond::Binary::data(), MillePedeFileConverter_cfg::e, cppFunctionSkipper::exception, jets_cff::payload, HLT_FULL_cff::payloadType, cond::Binary::size(), AlCaHLTBitMon_QueryRunRegistry::string, cond::StreamerInfo::techVersion(), and throwException().

◆ deserialize()

template<typename T >
std::unique_ptr<T> cond::deserialize ( const std::string &  payloadType,
const Binary payloadData,
const Binary streamerInfoData 
)

Definition at line 121 of file Serialization.h.

123  {
124  return default_deserialize<T>(payloadType, payloadData, streamerInfoData);
125  }

References HLT_FULL_cff::payloadType.

◆ deserialize< BaseKeyed >()

template<>
std::unique_ptr< BaseKeyed > cond::deserialize< BaseKeyed > ( const std::string &  payloadType,
const Binary payloadData,
const Binary streamerInfoData 
)

Definition at line 39 of file plugin.cc.

41  {
42  DESERIALIZE_BASE_CASE(BaseKeyed);
45 
46  // here we come if none of the deserializations above match the payload type:
47  throwException(std::string("Type mismatch, target object is type \"") + payloadType + "\"", "deserialize<>");
48  }

References DESERIALIZE_BASE_CASE, DESERIALIZE_POLIMORPHIC_CASE, HLT_FULL_cff::payloadType, AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

◆ deserialize< condex::Efficiency >()

template<>
std::unique_ptr<condex::Efficiency> cond::deserialize< condex::Efficiency > ( const std::string &  payloadType,
const Binary payloadData,
const Binary streamerInfoData 
)

Definition at line 25 of file plugin.cc.

27  {
28  // DESERIALIZE_BASE_CASE( condex::Efficiency ); abstract
31 
32  // here we come if none of the deserializations above match the payload type:
33  throwException(std::string("Type mismatch, target object is type \"") + payloadType + "\"", "deserialize<>");
34  }

References DESERIALIZE_POLIMORPHIC_CASE, HLT_FULL_cff::payloadType, AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

◆ deserialize< CSCReadoutMapping >()

template<>
std::unique_ptr<CSCReadoutMapping> cond::deserialize< CSCReadoutMapping > ( const std::string &  payloadType,
const Binary payloadData,
const Binary streamerInfoData 
)

Definition at line 65 of file plugin.cc.

67  {
68  // DESERIALIZE_BASE_CASE( CSCReadoutMapping ); abstract
70  // here we come if none of the deserializations above match the payload type:
71  throwException(std::string("Type mismatch, target object is type \"") + payloadType + "\"", "deserialize<>");
72  }

References DESERIALIZE_POLIMORPHIC_CASE, HLT_FULL_cff::payloadType, AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

◆ deserialize< CSCReadoutMappingForSliceTest >()

template<>
std::unique_ptr<CSCReadoutMappingForSliceTest> cond::deserialize< CSCReadoutMappingForSliceTest > ( const std::string &  payloadType,
const Binary payloadData,
const Binary streamerInfoData 
)

Definition at line 74 of file plugin.cc.

75  {
76  // DESERIALIZE_BASE_CASE( CSCReadoutMappingForSliceTest ); abstract
78  // here we come if none of the deserializations above match the payload type:
79  throwException(std::string("Type mismatch, target object is type \"") + payloadType + "\"", "deserialize<>");
80  }

References DESERIALIZE_POLIMORPHIC_CASE, HLT_FULL_cff::payloadType, AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

◆ deserialize< PerformancePayload >()

template<>
std::unique_ptr<PerformancePayload> cond::deserialize< PerformancePayload > ( const std::string &  payloadType,
const Binary payloadData,
const Binary streamerInfoData 
)

Definition at line 18 of file PerformanceRecordPlugin.cc.

20  {
21  // DESERIALIZE_BASE_CASE( PerformancePayload ); abstract
25  // here we come if none of the deserializations above match the payload type:
26  throwException(std::string("Type mismatch, target object is type \"") + payloadType + "\"", "createPayload");
27  }

References DESERIALIZE_POLIMORPHIC_CASE, HLT_FULL_cff::payloadType, AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

◆ findSpecs()

const TimeTypeSpecs & cond::findSpecs ( std::string const &  name)

Definition at line 23 of file Time.cc.

23  {
24  size_t i = 0;
25  for (; i < TIMETYPE_LIST_MAX; i++)
26  if (name == timeTypeSpecs[i].name)
27  return timeTypeSpecs[i];
28  throw cms::Exception("invalid timetype: " + name);
29  return timeTypeSpecs[0]; // compiler happy
30  }

References Exception, mps_fire::i, Skims_PA_cff::name, TIMETYPE_LIST_MAX, and timeTypeSpecs.

Referenced by cond::time::timeTypeFromName().

◆ getch()

int cond::getch ( )

Definition at line 19 of file Utilities.cc.

19  {
20  int ch;
21  struct termios t_old, t_new;
22 
23  tcgetattr(STDIN_FILENO, &t_old);
24  t_new = t_old;
25  t_new.c_lflag &= ~(ICANON | ECHO);
26  tcsetattr(STDIN_FILENO, TCSANOW, &t_new);
27 
28  ch = getchar();
29 
30  tcsetattr(STDIN_FILENO, TCSANOW, &t_old);
31  return ch;
32  }

Referenced by getpass().

◆ getDbCredentials()

std::pair<std::string, std::string> cond::getDbCredentials ( const std::string &  connectionString,
bool  updateMode,
const std::string &  authPath 
)

Definition at line 8 of file CondDBPyBind11Wrappers.cc.

10  {
11  std::string ap = authPath;
12  if (ap.empty()) {
13  ap = std::string(std::getenv(cond::auth::COND_AUTH_PATH));
14  }
15  auto ret = std::make_pair(std::string(""), std::string(""));
16  if (!ap.empty()) {
17  CredentialStore credDb;
18  credDb.setUpForConnectionString(connectionString, ap);
20  if (updateMode)
22  ret = credDb.getUserCredentials(connectionString, role);
23  }
24  return ret;
25  }

References lumi_dqm_sourceclient-live_cfg::authPath, cond::auth::COND_AUTH_PATH, cond::auth::COND_READER_ROLE, cond::auth::COND_WRITER_ROLE, l1RCTOmdsFedVectorProducer_cfi::connectionString, cond::CredentialStore::getUserCredentials(), runTheMatrix::ret, cond::CredentialStore::setUpForConnectionString(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by PYBIND11_MODULE().

◆ getLastLumiFromOMS()

cond::Time_t cond::getLastLumiFromOMS ( const std::string &  omsServiceUrl)

Definition at line 58 of file OnlineDBOutputService.cc.

58  {
59  cond::Time_t lastLumiProcessed = cond::time::MIN_VAL;
60  std::string info("");
62  throw Exception("Can't get data from OMS Service.");
63  std::istringstream sinfo(info);
64  std::string srun;
65  if (!std::getline(sinfo, srun, ',')) {
66  throw Exception("Can't get run runmber info from OMS Service.");
67  }
68  std::string slumi;
69  if (!std::getline(sinfo, slumi, ',')) {
70  throw Exception("Can't get lumi id from OMS Service.");
71  }
72  unsigned int run = boost::lexical_cast<unsigned int>(srun);
73  unsigned int lumi = boost::lexical_cast<unsigned int>(slumi);
74  lastLumiProcessed = cond::time::lumiTime(run, lumi);
75  return lastLumiProcessed;
76  }

References getInfoFromService(), info(), cond::time::lumiTime(), cond::time::MIN_VAL(), beam_dqm_sourceclient-live_cfg::omsServiceUrl, writedatasetfile::run, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by cond::service::OnlineDBOutputService::getLastLumiProcessed().

◆ getLatestLumiFromFile()

cond::Time_t cond::getLatestLumiFromFile ( const std::string &  fileName)

Definition at line 47 of file OnlineDBOutputService.cc.

47  {
48  cond::Time_t lastLumiProcessed = cond::time::MIN_VAL;
49  std::ifstream lastLumiFile(fileName);
50  if (lastLumiFile) {
51  lastLumiFile >> lastLumiProcessed;
52  } else {
53  throw Exception(std::string("Can't access lastLumi file ") + fileName);
54  }
55  return lastLumiProcessed;
56  }

References MillePedeFileConverter_cfg::fileName, beam_dqm_sourceclient-live_cfg::lastLumiFile, cond::time::MIN_VAL(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by cond::service::OnlineDBOutputService::getLastLumiProcessed().

◆ getLoginName()

std::string cond::getLoginName ( )

Definition at line 42 of file DecodingKey.cc.

42  {
43  std::string loginName("");
44  struct passwd* userp = ::getpwuid(::getuid());
45  if (userp) {
46  char* uName = userp->pw_name;
47  if (uName) {
48  loginName += uName;
49  }
50  }
51  if (loginName.empty()) {
52  std::string msg("Cannot determine login name.");
53  throwException(msg, "DecodingKey::getLoginName");
54  }
55  return loginName;
56  }

References mps_check::msg, AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

Referenced by cond::auth::DecodingKey::init().

◆ getNextSequenceValue()

bool cond::getNextSequenceValue ( const std::string &  schemaVersion,
coral::ISchema &  schema,
const std::string &  sequenceName,
int &  value 
)

Definition at line 329 of file CredentialStore.cc.

332  {
333  bool ret = false;
334  std::unique_ptr<coral::IQuery> query(schema.tableHandle(tname(SEQUENCE_TABLE, schemaVersion)).newQuery());
335  query->limitReturnedRows(1, 0);
336  query->addToOutputList(SEQUENCE_VALUE_COL);
337  query->defineOutputType(SEQUENCE_VALUE_COL, coral::AttributeSpecification::typeNameForType<int>());
338  query->setForUpdate();
339  std::string whereClause(SEQUENCE_NAME_COL + " = :" + SEQUENCE_NAME_COL);
340  coral::AttributeList rowData;
341  rowData.extend<std::string>(SEQUENCE_NAME_COL);
342  rowData.begin()->data<std::string>() = sequenceName;
343  query->setCondition(whereClause, rowData);
344  coral::ICursor& cursor = query->execute();
345  if (cursor.next()) {
346  value = cursor.currentRow().begin()->data<int>() + 1;
347  ret = true;
348  } else {
349  return false;
350  }
351  // update...
352  coral::AttributeList updateData;
353  updateData.extend<std::string>(SEQUENCE_NAME_COL);
354  updateData.extend<int>(SEQUENCE_VALUE_COL);
355  std::string setClause(SEQUENCE_VALUE_COL + " = :" + SEQUENCE_VALUE_COL);
356  std::string whClause(SEQUENCE_NAME_COL + " = :" + SEQUENCE_NAME_COL);
357  coral::AttributeList::iterator iAttribute = updateData.begin();
358  iAttribute->data<std::string>() = sequenceName;
359  ++iAttribute;
360  iAttribute->data<int>() = value;
361  schema.tableHandle(tname(SEQUENCE_TABLE, schemaVersion)).dataEditor().updateRows(setClause, whClause, updateData);
362  return ret;
363  }

References contentValuesFiles::query, runTheMatrix::ret, SEQUENCE_NAME_COL(), SEQUENCE_TABLE(), SEQUENCE_VALUE_COL(), TrackCollections2monitor_cff::sequenceName, AlCaHLTBitMon_QueryRunRegistry::string, and tname().

Referenced by setPermissionData(), updateConnectionData(), and updatePrincipalData().

◆ getpass()

std::string cond::getpass ( const std::string &  prompt,
bool  show_asterisk = true 
)

Definition at line 34 of file Utilities.cc.

34  {
35  const char BACKSPACE = 127;
36  const char RETURN = 10;
37 
39  unsigned char ch = 0;
40 
41  std::cout << prompt;
42 
43  while ((ch = getch()) != RETURN) {
44  if (ch == BACKSPACE) {
45  if (password.length() != 0) {
46  if (show_asterisk)
47  std::cout << "\b \b";
48  password.resize(password.length() - 1);
49  }
50  } else {
51  password += ch;
52  if (show_asterisk)
53  std::cout << '*';
54  }
55  }
56  std::cout << std::endl;
57  return password;
58  }

References gather_cfg::cout, getch(), EcalCondDBWriter_cfi::password, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getpassForUser().

◆ getpassForUser()

std::string cond::getpassForUser ( const std::string &  userName)

Definition at line 60 of file Utilities.cc.

60  {
61  std::string prompt("Enter password for user ");
62  prompt += userName;
63  prompt += ": ";
64  return getpass(prompt, true);
65  }

References getpass(), AlCaHLTBitMon_QueryRunRegistry::string, and EcalCondDBWriter_cfi::userName.

◆ hash64()

ub8 cond::hash64 ( unsigned char *  k,
unsigned long long  length,
unsigned long long  level 
)

Definition at line 68 of file hash64.cc.

72  {
73  ub8 a, b, c, len;
74 
75  /* Set up the internal state */
76  len = length;
77  a = b = level; /* the previous hash value */
78  c = 0x9e3779b97f4a7c13LL; /* the golden ratio; an arbitrary value */
79 
80  /*---------------------------------------- handle most of the key */
81  if (((unsigned long)k) & 7) {
82  while (len >= 24) {
83  a += (k[0] + ((ub8)k[1] << 8) + ((ub8)k[2] << 16) + ((ub8)k[3] << 24) + ((ub8)k[4] << 32) + ((ub8)k[5] << 40) +
84  ((ub8)k[6] << 48) + ((ub8)k[7] << 56));
85  b += (k[8] + ((ub8)k[9] << 8) + ((ub8)k[10] << 16) + ((ub8)k[11] << 24) + ((ub8)k[12] << 32) +
86  ((ub8)k[13] << 40) + ((ub8)k[14] << 48) + ((ub8)k[15] << 56));
87  c += (k[16] + ((ub8)k[17] << 8) + ((ub8)k[18] << 16) + ((ub8)k[19] << 24) + ((ub8)k[20] << 32) +
88  ((ub8)k[21] << 40) + ((ub8)k[22] << 48) + ((ub8)k[23] << 56));
89  mix64(a, b, c);
90  k += 24;
91  len -= 24;
92  }
93  } else {
94  while (len >= 24) /* aligned */
95  {
96  a += *(ub8 *)(k + 0);
97  b += *(ub8 *)(k + 8);
98  c += *(ub8 *)(k + 16);
99  mix64(a, b, c);
100  k += 24;
101  len -= 24;
102  }
103  }
104 
105  /*------------------------------------- handle the last 23 bytes */
106  c += length;
107  switch (len) /* all the case statements fall through */
108  {
109  case 23:
110  c += ((ub8)k[22] << 56);
111  [[fallthrough]];
112  case 22:
113  c += ((ub8)k[21] << 48);
114  [[fallthrough]];
115  case 21:
116  c += ((ub8)k[20] << 40);
117  [[fallthrough]];
118  case 20:
119  c += ((ub8)k[19] << 32);
120  [[fallthrough]];
121  case 19:
122  c += ((ub8)k[18] << 24);
123  [[fallthrough]];
124  case 18:
125  c += ((ub8)k[17] << 16);
126  [[fallthrough]];
127  case 17:
128  c += ((ub8)k[16] << 8);
129  [[fallthrough]];
130  /* the first byte of c is reserved for the length */
131  case 16:
132  b += ((ub8)k[15] << 56);
133  [[fallthrough]];
134  case 15:
135  b += ((ub8)k[14] << 48);
136  [[fallthrough]];
137  case 14:
138  b += ((ub8)k[13] << 40);
139  [[fallthrough]];
140  case 13:
141  b += ((ub8)k[12] << 32);
142  [[fallthrough]];
143  case 12:
144  b += ((ub8)k[11] << 24);
145  [[fallthrough]];
146  case 11:
147  b += ((ub8)k[10] << 16);
148  [[fallthrough]];
149  case 10:
150  b += ((ub8)k[9] << 8);
151  [[fallthrough]];
152  case 9:
153  b += ((ub8)k[8]);
154  [[fallthrough]];
155  case 8:
156  a += ((ub8)k[7] << 56);
157  [[fallthrough]];
158  case 7:
159  a += ((ub8)k[6] << 48);
160  [[fallthrough]];
161  case 6:
162  a += ((ub8)k[5] << 40);
163  [[fallthrough]];
164  case 5:
165  a += ((ub8)k[4] << 32);
166  [[fallthrough]];
167  case 4:
168  a += ((ub8)k[3] << 24);
169  [[fallthrough]];
170  case 3:
171  a += ((ub8)k[2] << 16);
172  [[fallthrough]];
173  case 2:
174  a += ((ub8)k[1] << 8);
175  [[fallthrough]];
176  case 1:
177  a += ((ub8)k[0]);
178  /* case 0: nothing left to add */
179  }
180  mix64(a, b, c);
181  /*-------------------------------------------- report the result */
182  return c;
183  }

References a, b, c, dqmdumpme::k, personalPlayback::level, L1DTConfigBti_cff::LL, and mix64.

Referenced by cond::KeyedElement::convert().

◆ invalidTime()

const Time_t cond::invalidTime ( )

◆ invalidToken()

const std::string cond::invalidToken ( " "  )

◆ makeIov()

Iov_t cond::makeIov ( cond::Time_t  since,
const Hash payloadId 
)

Definition at line 20 of file CondDBPyWrappers.cc.

20  {
21  Iov_t ret;
22  ret.since = since;
23  ret.payloadId = payloadId;
24  return ret;
25  }

References runTheMatrix::ret, and writeEcalDQMStatus::since.

Referenced by BOOST_PYTHON_MODULE().

◆ parseLineForNamedParams()

void cond::parseLineForNamedParams ( const std::string &  line,
std::map< std::string, std::string > &  params 
)

Definition at line 58 of file DecodingKey.cc.

58  {
59  std::stringstream str(line);
60  std::string paramName("");
61  std::string paramValue("");
62  while (str.good()) {
63  std::string item("");
64  getline(str, item, ItemSeparator);
65  if (item.size() > 3) {
66  paramName = item.substr(0, 2);
67  paramValue = item.substr(2);
68  params.insert(std::make_pair(paramName, paramValue));
69  }
70  }
71  }

References B2GTnPMonitor_cfi::item, ItemSeparator, mps_splice::line, CalibrationSummaryClient_cfi::params, str, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by cond::auth::DecodingKey::createFromInputFile().

◆ pluginCategory()

const char * cond::pluginCategory ( )

Definition at line 64 of file ProxyFactory.cc.

64 { return "CondProxyFactory"; }

◆ randomChar()

char cond::randomChar ( )

Definition at line 37 of file DecodingKey.cc.

37  {
38  int irand = ::rand() % (::strlen(b64str));
39  return b64str[irand];
40  }

References b64str.

Referenced by cond::auth::KeyGenerator::make().

◆ schemaLabel()

std::string cond::schemaLabel ( const std::string &  serviceName,
const std::string &  userName 
)

◆ schemaLabelForCredentialStore()

std::string cond::schemaLabelForCredentialStore ( const std::string &  connectionString)

Definition at line 176 of file CredentialStore.cc.

176  {
177  coral::URIParser parser;
178  parser.setURI(connectionString);
179  std::string serviceName = parser.hostName();
180  std::string schemaName = parser.databaseOrSchemaName();
181  return schemaLabel(serviceName, schemaName);
182  }

References l1RCTOmdsFedVectorProducer_cfi::connectionString, writedatasetfile::parser, schemaLabel(), serviceName, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ selectAuthorization()

bool cond::selectAuthorization ( const std::string &  schemaVersion,
coral::ISchema &  schema,
int  principalId,
const std::string &  role,
const std::string &  connectionString,
AuthorizationData destination 
)

Definition at line 290 of file CredentialStore.cc.

295  {
296  std::unique_ptr<coral::IQuery> query(schema.tableHandle(tname(AUTHORIZATION_TABLE, schemaVersion)).newQuery());
297  coral::AttributeList readBuff;
298  readBuff.extend<int>(AUTH_ID_COL);
299  readBuff.extend<int>(C_ID_COL);
300  readBuff.extend<std::string>(AUTH_KEY_COL);
301  coral::AttributeList whereData;
302  whereData.extend<int>(P_ID_COL);
303  whereData.extend<std::string>(ROLE_COL);
304  whereData.extend<std::string>(SCHEMA_COL);
305  whereData[P_ID_COL].data<int>() = principalId;
306  whereData[ROLE_COL].data<std::string>() = role;
307  whereData[SCHEMA_COL].data<std::string>() = connectionString;
308  std::stringstream whereClause;
309  whereClause << P_ID_COL << " = :" << P_ID_COL;
310  whereClause << " AND " << ROLE_COL << " = :" << ROLE_COL;
311  whereClause << " AND " << SCHEMA_COL << " = :" << SCHEMA_COL;
312  query->defineOutput(readBuff);
313  query->addToOutputList(AUTH_ID_COL);
314  query->addToOutputList(C_ID_COL);
315  query->addToOutputList(AUTH_KEY_COL);
316  query->setCondition(whereClause.str(), whereData);
317  coral::ICursor& cursor = query->execute();
318  bool found = false;
319  if (cursor.next()) {
320  const coral::AttributeList& row = cursor.currentRow();
321  destination.id = row[AUTH_ID_COL].data<int>();
322  destination.connectionId = row[C_ID_COL].data<int>();
323  destination.key = row[AUTH_KEY_COL].data<std::string>();
324  found = true;
325  }
326  return found;
327  }

References AUTH_ID_COL(), AUTH_KEY_COL(), AUTHORIZATION_TABLE(), C_ID_COL(), l1RCTOmdsFedVectorProducer_cfi::connectionString, HLTMuonOfflineAnalyzer_cff::destination, newFWLiteAna::found, P_ID_COL(), contentValuesFiles::query, ROLE_COL(), SCHEMA_COL(), AlCaHLTBitMon_QueryRunRegistry::string, and tname().

Referenced by setPermissionData().

◆ selectConnection()

bool cond::selectConnection ( const std::string &  schemaVersion,
coral::ISchema &  schema,
const std::string &  connectionLabel,
CredentialData destination 
)

Definition at line 247 of file CredentialStore.cc.

250  {
251  std::unique_ptr<coral::IQuery> query(schema.tableHandle(tname(CREDENTIAL_TABLE, schemaVersion)).newQuery());
252  coral::AttributeList readBuff;
253  readBuff.extend<int>(CONNECTION_ID_COL);
254  readBuff.extend<std::string>(USERNAME_COL);
255  readBuff.extend<std::string>(PASSWORD_COL);
256  readBuff.extend<std::string>(VERIFICATION_KEY_COL);
257  readBuff.extend<std::string>(CONNECTION_KEY_COL);
258  coral::AttributeList whereData;
259  whereData.extend<std::string>(CONNECTION_LABEL_COL);
260  whereData[CONNECTION_LABEL_COL].data<std::string>() = connectionLabel;
261  std::string whereClause = CONNECTION_LABEL_COL + " = :" + CONNECTION_LABEL_COL;
262  query->defineOutput(readBuff);
263  query->addToOutputList(CONNECTION_ID_COL);
264  query->addToOutputList(USERNAME_COL);
265  query->addToOutputList(PASSWORD_COL);
266  query->addToOutputList(VERIFICATION_KEY_COL);
267  query->addToOutputList(CONNECTION_KEY_COL);
268  query->setCondition(whereClause, whereData);
269  coral::ICursor& cursor = query->execute();
270  bool found = false;
271  if (cursor.next()) {
272  const coral::AttributeList& row = cursor.currentRow();
273  destination.id = row[CONNECTION_ID_COL].data<int>();
274  destination.userName = row[USERNAME_COL].data<std::string>();
275  destination.password = row[PASSWORD_COL].data<std::string>();
276  destination.verificationKey = row[VERIFICATION_KEY_COL].data<std::string>();
277  destination.connectionKey = row[CONNECTION_KEY_COL].data<std::string>();
278  found = true;
279  }
280  return found;
281  }

References CONNECTION_ID_COL(), CONNECTION_KEY_COL(), CONNECTION_LABEL_COL(), CREDENTIAL_TABLE(), HLTMuonOfflineAnalyzer_cff::destination, newFWLiteAna::found, PASSWORD_COL(), contentValuesFiles::query, AlCaHLTBitMon_QueryRunRegistry::string, tname(), USERNAME_COL(), and VERIFICATION_KEY_COL().

Referenced by cond::CredentialStore::removeConnection(), cond::CredentialStore::setPermission(), updateConnectionData(), and cond::CredentialStore::updatePrincipal().

◆ selectPrincipal()

bool cond::selectPrincipal ( const std::string &  schemaVersion,
coral::ISchema &  schema,
const std::string &  principal,
PrincipalData destination 
)

Definition at line 205 of file CredentialStore.cc.

208  {
209  std::unique_ptr<coral::IQuery> query(schema.tableHandle(tname(AUTHENTICATION_TABLE, schemaVersion)).newQuery());
210  coral::AttributeList readBuff;
211  readBuff.extend<int>(PRINCIPAL_ID_COL);
212  readBuff.extend<std::string>(VERIFICATION_COL);
213  readBuff.extend<std::string>(PRINCIPAL_KEY_COL);
214  readBuff.extend<std::string>(ADMIN_KEY_COL);
215  coral::AttributeList whereData;
216  whereData.extend<std::string>(PRINCIPAL_NAME_COL);
217  whereData[PRINCIPAL_NAME_COL].data<std::string>() = principal;
218  std::string whereClause = PRINCIPAL_NAME_COL + " = :" + PRINCIPAL_NAME_COL;
219  query->defineOutput(readBuff);
220  query->addToOutputList(PRINCIPAL_ID_COL);
221  query->addToOutputList(VERIFICATION_COL);
222  query->addToOutputList(PRINCIPAL_KEY_COL);
223  query->addToOutputList(ADMIN_KEY_COL);
224  query->setCondition(whereClause, whereData);
225  coral::ICursor& cursor = query->execute();
226  bool found = false;
227  if (cursor.next()) {
228  found = true;
229  const coral::AttributeList& row = cursor.currentRow();
230  destination.id = row[PRINCIPAL_ID_COL].data<int>();
231  destination.verifKey = row[VERIFICATION_COL].data<std::string>();
232  destination.principalKey = row[PRINCIPAL_KEY_COL].data<std::string>();
233  destination.adminKey = row[ADMIN_KEY_COL].data<std::string>();
234  }
235  return found;
236  }

References ADMIN_KEY_COL(), AUTHENTICATION_TABLE(), HLTMuonOfflineAnalyzer_cff::destination, newFWLiteAna::found, PRINCIPAL_ID_COL(), PRINCIPAL_KEY_COL(), PRINCIPAL_NAME_COL(), contentValuesFiles::query, AlCaHLTBitMon_QueryRunRegistry::string, tname(), and VERIFICATION_COL().

Referenced by cond::CredentialStore::importForPrincipal(), cond::CredentialStore::removePrincipal(), cond::CredentialStore::resetAdmin(), cond::CredentialStore::setPermission(), cond::CredentialStore::startSession(), cond::CredentialStore::unsetPermission(), and updatePrincipalData().

◆ serialize()

template<typename T >
std::pair<Binary, Binary> cond::serialize ( const T payload)

Definition at line 66 of file Serialization.h.

66  {
67  std::pair<Binary, Binary> ret;
68  std::string streamerInfo(StreamerInfo::jsonString());
69  try {
70  // save data to buffers
71  std::ostringstream dataBuffer;
72  CondOutputArchive oa(dataBuffer);
73  oa << payload;
74  //TODO: avoid (2!!) copies
75  ret.first.copy(dataBuffer.str());
76  ret.second.copy(streamerInfo);
77  } catch (const std::exception& e) {
78  std::string em(e.what());
79  throwException("Serialization failed: " + em + ". Serialization info:" + streamerInfo, "serialize");
80  }
81  return ret;
82  }

References MillePedeFileConverter_cfg::e, cppFunctionSkipper::exception, cond::StreamerInfo::jsonString(), jets_cff::payload, runTheMatrix::ret, AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

Referenced by cond::persistency::Session::storePayload< std::string >(), cond::persistency::Session::storePayload(), and RawEventFileWriterForBU::writeJsds().

◆ setPermissionData()

bool cond::setPermissionData ( const std::string &  schemaVersion,
coral::ISchema &  schema,
int  principalId,
const std::string &  principalKey,
const std::string &  role,
const std::string &  connectionString,
int  connectionId,
const std::string &  connectionKey,
std::stringstream &  log 
)

Definition at line 428 of file CredentialStore.cc.

436  {
437  if (cond::auth::ROLES.find(role) == cond::auth::ROLES.end()) {
438  throwException(std::string("Role ") + role + " does not exists.", "CredentialStore::setPermission");
439  }
440  auth::Cipher cipher(principalKey);
441  std::string encryptedConnectionKey = cipher.b64encrypt(connectionKey);
442  AuthorizationData authData;
443  bool found = selectAuthorization(schemaVersion, schema, principalId, role, connectionString, authData);
444 
445  std::string authorization_table_name = tname(AUTHORIZATION_TABLE, schemaVersion);
446  coral::ITableDataEditor& editor = schema.tableHandle(authorization_table_name).dataEditor();
447  if (found) {
448  log << "Updating permission for principal id " << principalId << " to access resource " << connectionString
449  << " with role " << role << std::endl;
450  coral::AttributeList updateData;
451  updateData.extend<int>(AUTH_ID_COL);
452  updateData.extend<int>(C_ID_COL);
453  updateData.extend<std::string>(AUTH_KEY_COL);
454  updateData[AUTH_ID_COL].data<int>() = authData.id;
455  updateData[C_ID_COL].data<int>() = connectionId;
456  updateData[AUTH_KEY_COL].data<std::string>() = encryptedConnectionKey;
457  std::string setCl = C_ID_COL + " = :" + C_ID_COL + ", " + AUTH_KEY_COL + " = :" + AUTH_KEY_COL;
458  std::string whereCl = AUTH_ID_COL + " = :" + AUTH_ID_COL;
459  editor.updateRows(setCl, whereCl, updateData);
460  } else {
461  int next = -1;
462  if (!getNextSequenceValue(schemaVersion, schema, authorization_table_name, next))
463  throwException("Can't find " + authorization_table_name + " sequence.", "CredentialStore::setPermission");
464  log << "Setting permission for principal id " << principalId << " to access resource " << connectionString
465  << " with role " << role << std::endl;
466  coral::AttributeList insertData;
467  insertData.extend<int>(AUTH_ID_COL);
468  insertData.extend<int>(P_ID_COL);
469  insertData.extend<std::string>(ROLE_COL);
470  insertData.extend<std::string>(SCHEMA_COL);
471  insertData.extend<std::string>(AUTH_KEY_COL);
472  insertData.extend<int>(C_ID_COL);
473  insertData[AUTH_ID_COL].data<int>() = next;
474  insertData[P_ID_COL].data<int>() = principalId;
475  insertData[ROLE_COL].data<std::string>() = role;
476  insertData[SCHEMA_COL].data<std::string>() = connectionString;
477  insertData[AUTH_KEY_COL].data<std::string>() = encryptedConnectionKey;
478  insertData[C_ID_COL].data<int>() = connectionId;
479  editor.insertRow(insertData);
480  }
481  return true;
482  }

References AUTH_ID_COL(), AUTH_KEY_COL(), AUTHORIZATION_TABLE(), cond::auth::Cipher::b64encrypt(), C_ID_COL(), l1RCTOmdsFedVectorProducer_cfi::connectionString, mps_fire::end, spr::find(), newFWLiteAna::found, getNextSequenceValue(), cond::AuthorizationData::id, dqm-mbProfile::log, GetRecoTauVFromDQM_MC_cff::next, P_ID_COL(), ROLE_COL(), cond::auth::ROLES, SCHEMA_COL(), selectAuthorization(), AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::throwException(), and tname().

Referenced by cond::CredentialStore::createSchema(), cond::CredentialStore::importForPrincipal(), cond::CredentialStore::resetAdmin(), cond::CredentialStore::setPermission(), and cond::CredentialStore::updatePrincipal().

◆ synchronizationTypeFromName()

SynchronizationType cond::synchronizationTypeFromName ( const std::string &  name)

Definition at line 47 of file Types.cc.

47  {
48  for (auto const &i : s_synchronizationTypeArray)
49  if (name == i.first)
50  return i.second;
51  for (auto const &i : s_obsoleteSynchronizationTypeArray)
52  if (name == i.first)
53  return i.second;
54  throwException("SynchronizationType \"" + name + "\" is unknown.", "synchronizationTypeFromName");
55  }

References mps_fire::i, Skims_PA_cff::name, s_obsoleteSynchronizationTypeArray, s_synchronizationTypeArray, and throwException().

Referenced by cond::persistency::GetFromRow< cond::SynchronizationType >::operator()().

◆ synchronizationTypeNames()

std::string cond::synchronizationTypeNames ( SynchronizationType  type)

◆ throwException()

void cond::throwException ( const std::string &  message,
const std::string &  methodName 
)

Definition at line 18 of file Exception.cc.

18  {
19  throw Exception(message, methodName);
20  }

Referenced by cond::service::PoolDBOutputService::appendSinceTime(), cond::auth::Cipher::b64decrypt(), cond::service::PoolDBOutputService::closeIOV(), cond::auth::DecodingKey::createFromInputFile(), cond::service::PoolDBOutputService::createNewIOV(), createPayload(), createPayload< HcalCalibrationQIEData >(), createPayload< std::string >(), cond::CredentialStore::createSchema(), cond::RelationalAuthenticationService::RelationalAuthenticationService::credentials(), cond::Binary::data(), default_deserialize(), deserialize< BaseKeyed >(), deserialize< condex::Efficiency >(), deserialize< CSCReadoutMapping >(), deserialize< CSCReadoutMappingForSliceTest >(), deserialize< PerformancePayload >(), cond::service::PoolDBOutputService::eraseSinceTime(), cond::auth::DecodingKey::flush(), cond::service::PoolDBOutputService::forceInit(), cond::persistency::getConnectionParams(), getLoginName(), cond::payloadInspector::PlotBase::getTag(), cond::service::PoolDBOutputService::getTagInfo(), cond::CredentialStore::importForPrincipal(), cond::persistency::importPayload(), cond::auth::DecodingKey::init(), cond::persistency::IOVEditor::load(), cond::persistency::KeyList::loadFromDB(), cond::service::PoolDBOutputService::lookUpRecord(), cond::CredentialStore::removeConnection(), cond::CredentialStore::removePrincipal(), cond::CredentialStore::resetAdmin(), serialize(), cond::persistency::KeyList::setKeys(), cond::CredentialStore::setPermission(), cond::CredentialStore::setUpForService(), cond::Binary::size(), synchronizationTypeFromName(), cond::CredentialStore::unsetPermission(), cond::CredentialStore::updatePrincipal(), and cond::service::PoolDBOutputService::writeOne().

◆ TIMELIMIT()

const Time_t cond::TIMELIMIT ( std::numeric_limits< Time_t ::max())

◆ timeTypeNames()

std::string const & cond::timeTypeNames ( int  i)

Definition at line 11 of file Time.cc.

11  {
12  static const std::string local[] = {"runnumber", "timestamp", "lumiid", "hash", "userid"};
13  return local[i];
14  }

References mps_fire::i, DTRecHitClients_cfi::local, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by CondDBESSource::setIntervalFor(), and cond::TimeTypeTraits< type >::specs().

◆ updateConnectionData()

std::pair<int, std::string> cond::updateConnectionData ( const std::string &  schemaVersion,
coral::ISchema &  schema,
const std::string &  adminKey,
const std::string &  connectionLabel,
const std::string &  userName,
const std::string &  password,
bool  forceUpdate,
std::stringstream &  log 
)

Definition at line 484 of file CredentialStore.cc.

491  {
492  CredentialData credsData;
493  bool found = selectConnection(schemaVersion, schema, connectionLabel, credsData);
494  int connId = credsData.id;
495 
496  auth::Cipher adminCipher(adminKey);
497  std::string connectionKey("");
498  std::string credential_table_name = tname(CREDENTIAL_TABLE, schemaVersion);
499  coral::ITableDataEditor& editor = schema.tableHandle(credential_table_name).dataEditor();
500  if (found) {
501  connectionKey = adminCipher.b64decrypt(credsData.connectionKey);
502  auth::Cipher cipher(connectionKey);
503  std::string verificationKey = cipher.b64decrypt(credsData.verificationKey);
504  if (verificationKey != connectionLabel) {
505  throwException("Decoding of connection key failed.", "CredentialStore::updateConnection");
506  }
507  if (forceUpdate) {
508  std::string encryptedUserName = cipher.b64encrypt(userName);
509  std::string encryptedPassword = cipher.b64encrypt(password);
510  log << "Forcing update of connection " << connectionLabel << std::endl;
511  coral::AttributeList updateData;
512  updateData.extend<int>(CONNECTION_ID_COL);
513  updateData.extend<std::string>(USERNAME_COL);
514  updateData.extend<std::string>(PASSWORD_COL);
515  updateData[CONNECTION_ID_COL].data<int>() = connId;
516  updateData[USERNAME_COL].data<std::string>() = encryptedUserName;
517  updateData[PASSWORD_COL].data<std::string>() = encryptedPassword;
518  std::stringstream setCl;
519  setCl << USERNAME_COL << " = :" << USERNAME_COL;
520  setCl << ", " << PASSWORD_COL << " = :" << PASSWORD_COL;
521  std::string whereCl = CONNECTION_ID_COL + " = :" + CONNECTION_ID_COL;
522  editor.updateRows(setCl.str(), whereCl, updateData);
523  }
524  } else {
525  auth::KeyGenerator gen;
526  connectionKey = gen.make(auth::COND_DB_KEY_SIZE);
527  auth::Cipher cipher(connectionKey);
528  std::string encryptedUserName = cipher.b64encrypt(userName);
529  std::string encryptedPassword = cipher.b64encrypt(password);
530  std::string encryptedLabel = cipher.b64encrypt(connectionLabel);
531 
532  if (!getNextSequenceValue(schemaVersion, schema, credential_table_name, connId))
533  throwException("Can't find " + credential_table_name + " sequence.", "CredentialStore::updateConnection");
534  log << "Creating new connection " << connectionLabel << std::endl;
535  coral::AttributeList insertData;
536  insertData.extend<int>(CONNECTION_ID_COL);
537  insertData.extend<std::string>(CONNECTION_LABEL_COL);
538  insertData.extend<std::string>(USERNAME_COL);
539  insertData.extend<std::string>(PASSWORD_COL);
540  insertData.extend<std::string>(VERIFICATION_KEY_COL);
541  insertData.extend<std::string>(CONNECTION_KEY_COL);
542  insertData[CONNECTION_ID_COL].data<int>() = connId;
543  insertData[CONNECTION_LABEL_COL].data<std::string>() = connectionLabel;
544  insertData[USERNAME_COL].data<std::string>() = encryptedUserName;
545  insertData[PASSWORD_COL].data<std::string>() = encryptedPassword;
546  insertData[VERIFICATION_KEY_COL].data<std::string>() = encryptedLabel;
547  insertData[CONNECTION_KEY_COL].data<std::string>() = adminCipher.b64encrypt(connectionKey);
548  ;
549  editor.insertRow(insertData);
550  }
551  return std::make_pair(connId, connectionKey);
552  }

References cond::auth::Cipher::b64decrypt(), cond::auth::Cipher::b64encrypt(), cond::auth::COND_DB_KEY_SIZE, CONNECTION_ID_COL(), CONNECTION_KEY_COL(), CONNECTION_LABEL_COL(), cond::CredentialData::connectionKey, CREDENTIAL_TABLE(), newFWLiteAna::found, relval_steps::gen(), getNextSequenceValue(), cond::CredentialData::id, dqm-mbProfile::log, EcalCondDBWriter_cfi::password, PASSWORD_COL(), selectConnection(), AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::throwException(), tname(), EcalCondDBWriter_cfi::userName, USERNAME_COL(), VERIFICATION_KEY_COL(), and cond::CredentialData::verificationKey.

Referenced by cond::CredentialStore::createSchema(), cond::CredentialStore::importForPrincipal(), cond::CredentialStore::resetAdmin(), and cond::CredentialStore::updateConnection().

◆ updatePrincipalData()

std::pair<int, std::string> cond::updatePrincipalData ( const std::string &  schemaVersion,
coral::ISchema &  schema,
const std::string &  authenticationKey,
const std::string &  principalName,
const std::string &  adminKey,
bool  init,
std::stringstream &  log 
)
Parameters
init= false *

Definition at line 365 of file CredentialStore.cc.

371  {
372  PrincipalData princData;
373  bool found = selectPrincipal(schemaVersion, schema, principalName, princData);
374 
375  auth::Cipher cipher0(authenticationKey);
376  auth::Cipher cipher1(adminKey);
377 
378  std::string verifStr = cipher0.b64encrypt(principalName);
379  std::string principalKey("");
380  int principalId = princData.id;
381 
382  std::string authentication_table_name = tname(AUTHENTICATION_TABLE, schemaVersion);
383 
384  coral::ITableDataEditor& editor = schema.tableHandle(authentication_table_name).dataEditor();
385  if (found) {
386  log << "Updating existing principal " << principalName << " (id: " << principalId << " )" << std::endl;
387  principalKey = cipher1.b64decrypt(princData.adminKey);
388  coral::AttributeList updateData;
389  updateData.extend<int>(PRINCIPAL_ID_COL);
390  updateData.extend<std::string>(VERIFICATION_COL);
391  updateData.extend<std::string>(PRINCIPAL_KEY_COL);
392  updateData.extend<std::string>(ADMIN_KEY_COL);
393  updateData[PRINCIPAL_ID_COL].data<int>() = principalId;
394  updateData[VERIFICATION_COL].data<std::string>() = verifStr;
395  updateData[PRINCIPAL_KEY_COL].data<std::string>() = cipher0.b64encrypt(principalKey);
396  updateData[ADMIN_KEY_COL].data<std::string>() = cipher1.b64encrypt(principalKey);
397  std::stringstream setClause;
398  setClause << VERIFICATION_COL << " = :" << VERIFICATION_COL << ", ";
399  setClause << PRINCIPAL_KEY_COL << " = :" << PRINCIPAL_KEY_COL << ", ";
400  setClause << ADMIN_KEY_COL << " = :" << ADMIN_KEY_COL;
401  std::string whereClause = PRINCIPAL_ID_COL + " = :" + PRINCIPAL_ID_COL;
402  editor.updateRows(setClause.str(), whereClause, updateData);
403  } else {
404  if (init) {
405  principalKey = adminKey;
406  } else {
407  auth::KeyGenerator gen;
408  principalKey = gen.make(auth::COND_DB_KEY_SIZE);
409  }
410  coral::ITableDataEditor& editor0 = schema.tableHandle(authentication_table_name).dataEditor();
411 
412  if (!getNextSequenceValue(schemaVersion, schema, authentication_table_name, principalId))
413  throwException("Can't find " + authentication_table_name + " sequence.", "CredentialStore::updatePrincipal");
414  log << "Creating new principal " << principalName << " (id: " << principalId << " )" << std::endl;
415  coral::AttributeList authData;
416  editor0.rowBuffer(authData);
417  authData[PRINCIPAL_ID_COL].data<int>() = principalId;
418  authData[PRINCIPAL_NAME_COL].data<std::string>() = principalName;
419  authData[VERIFICATION_COL].data<std::string>() = verifStr;
420  authData[PRINCIPAL_KEY_COL].data<std::string>() = cipher0.b64encrypt(principalKey);
421  authData[ADMIN_KEY_COL].data<std::string>() = cipher1.b64encrypt(principalKey);
422  editor0.insertRow(authData);
423  }
424 
425  return std::make_pair(principalId, principalKey);
426  }

References ADMIN_KEY_COL(), cond::PrincipalData::adminKey, AUTHENTICATION_TABLE(), cond::auth::Cipher::b64decrypt(), cond::auth::Cipher::b64encrypt(), cond::auth::COND_DB_KEY_SIZE, newFWLiteAna::found, relval_steps::gen(), getNextSequenceValue(), cond::PrincipalData::id, dqm-mbProfile::log, PRINCIPAL_ID_COL(), PRINCIPAL_KEY_COL(), PRINCIPAL_NAME_COL(), selectPrincipal(), AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::throwException(), tname(), and VERIFICATION_COL().

Referenced by cond::CredentialStore::createSchema(), cond::CredentialStore::resetAdmin(), and cond::CredentialStore::updatePrincipal().

Variable Documentation

◆ HASH_SIZE

constexpr unsigned int cond::HASH_SIZE = 40
staticconstexpr

Definition at line 44 of file Types.h.

◆ s_obsoleteSynchronizationTypeArray

std::pair<const char *, SynchronizationType> cond::s_obsoleteSynchronizationTypeArray[]
static
Initial value:
= {
std::make_pair("Offline", SYNCH_OFFLINE),
std::make_pair("HLT", SYNCH_HLT),
std::make_pair("Prompt", SYNCH_PROMPT),
std::make_pair("Pcl", SYNCH_PCL)}

Definition at line 40 of file Types.cc.

Referenced by synchronizationTypeFromName().

◆ s_synchronizationTypeArray

std::pair<const char *, SynchronizationType> cond::s_synchronizationTypeArray[]
static
Initial value:
= {
std::make_pair("any", SYNCH_ANY),
std::make_pair("validation", SYNCH_VALIDATION),
std::make_pair("offline", SYNCH_OFFLINE),
std::make_pair("mc", SYNCH_MC),
std::make_pair("runmc", SYNCH_RUNMC),
std::make_pair("hlt", SYNCH_HLT),
std::make_pair("express", SYNCH_EXPRESS),
std::make_pair("prompt", SYNCH_PROMPT),
std::make_pair("pcl", SYNCH_PCL)}

Definition at line 29 of file Types.cc.

Referenced by synchronizationTypeFromName(), and synchronizationTypeNames().

◆ TIMETYPE_LIST_MAX

const unsigned int cond::TIMETYPE_LIST_MAX = 5

Definition at line 20 of file Time.h.

Referenced by findSpecs().

◆ timeTypeList

const cond::TimeType cond::timeTypeList = {runnumber, timestamp, lumiid, hash, userid}

Definition at line 7 of file Time.cc.

◆ timeTypeSpecs

const TimeTypeSpecs cond::timeTypeSpecs

◆ timeTypeValues

const cond::TimeType cond::timeTypeValues = {runnumber, timestamp, lumiid, hash, userid}

Definition at line 9 of file Time.cc.

personalPlayback.level
level
Definition: personalPlayback.py:22
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:542
PerformancePayloadFromTFormula
Definition: PerformancePayloadFromTFormula.h:17
getInfoFromService
bool getInfoFromService(const std::string &urlString, std::string &info)
Definition: OnlineDBOutputService.cc:12
lumi_dqm_sourceclient-live_cfg.authPath
authPath
Definition: lumi_dqm_sourceclient-live_cfg.py:33
ROLE_COL
static const std::string ROLE_COL("C_ROLE")
condex::Efficiency
Definition: Efficiency.h:19
cond::auth::COND_READER_ROLE
static constexpr const char *const COND_READER_ROLE
Definition: Auth.h:18
SCHEMA_COL
static const std::string SCHEMA_COL("C_SCHEMA")
cond::time::MIN_VAL
const Time_t MIN_VAL(0)
AUTHORIZATION_TABLE
static const std::string AUTHORIZATION_TABLE("AUTHORIZATION")
cond::lumiid
Definition: Time.h:19
mps_fire.i
i
Definition: mps_fire.py:428
AUTHENTICATION_TABLE
static const std::string AUTHENTICATION_TABLE("AUTHENTICATION")
C_ID_COL
static const std::string C_ID_COL("C_ID")
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
cond::hash
Definition: Time.h:19
cond::TIMETYPE_LIST_MAX
const unsigned int TIMETYPE_LIST_MAX
Definition: Time.h:20
ItemSeparator
constexpr char ItemSeparator
Definition: DecodingKey.cc:14
AUTH_KEY_COL
static const std::string AUTH_KEY_COL("CRED3")
PRINCIPAL_NAME_COL
static const std::string PRINCIPAL_NAME_COL("P_NAME")
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HistogramManager_cfi.specs
specs
Definition: HistogramManager_cfi.py:83
CONNECTION_LABEL_COL
static const std::string CONNECTION_LABEL_COL("CONN_LABEL")
cond::SYNCH_HLT
Definition: Types.h:33
beam_dqm_sourceclient-live_cfg.lastLumiFile
lastLumiFile
Definition: beam_dqm_sourceclient-live_cfg.py:405
VERIFICATION_KEY_COL
static const std::string VERIFICATION_KEY_COL("CRED6")
cond::CondOutputArchive
cond::serialization::OutputArchive CondOutputArchive
Definition: Serialization.h:62
writedatasetfile.parser
parser
Definition: writedatasetfile.py:7
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
mps_check.msg
tuple msg
Definition: mps_check.py:285
SEQUENCE_TABLE
static const std::string SEQUENCE_TABLE("CREDENTIAL_SEQUENCE")
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
CTPPSpixelLocalTrackReconstructionInfo::invalid
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
cond::getNextSequenceValue
bool getNextSequenceValue(const std::string &schemaVersion, coral::ISchema &schema, const std::string &sequenceName, int &value)
Definition: CredentialStore.cc:329
cond::SYNCH_VALIDATION
Definition: Types.h:29
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
serviceName
static const std::string serviceName
Definition: CredentialStore.cc:31
ADMIN_KEY_COL
static const std::string ADMIN_KEY_COL("CRED2")
to_lower
std::string to_lower(const std::string &s)
Definition: CredentialStore.cc:157
EcalCondDBWriter_cfi.userName
userName
Definition: EcalCondDBWriter_cfi.py:61
cond::auth::COND_WRITER_ROLE
static constexpr const char *const COND_WRITER_ROLE
Definition: Auth.h:17
CONNECTION_KEY_COL
static const std::string CONNECTION_KEY_COL("CRED7")
cond::SYNCH_EXPRESS
Definition: Types.h:34
cond::timestamp
Definition: Time.h:19
cond::userid
Definition: Time.h:19
EcalCondDBWriter_cfi.password
password
Definition: EcalCondDBWriter_cfi.py:62
PerformancePayloadFromTable
Definition: PerformancePayloadFromTable.h:15
cond::timeTypeSpecs
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:16
cond::SynchronizationType
SynchronizationType
Definition: Types.h:27
query
Definition: query.py:1
SEQUENCE_NAME_COL
static const std::string SEQUENCE_NAME_COL("NAME")
mps_fire.end
end
Definition: mps_fire.py:242
cond::SYNCH_PROMPT
Definition: Types.h:35
USERNAME_COL
static const std::string USERNAME_COL("CRED4")
str
#define str(s)
Definition: TestProcessor.cc:52
cond::selectPrincipal
bool selectPrincipal(const std::string &schemaVersion, coral::ISchema &schema, const std::string &principal, PrincipalData &destination)
Definition: CredentialStore.cc:205
writeEcalDQMStatus.since
since
Definition: writeEcalDQMStatus.py:53
DESERIALIZE_POLIMORPHIC_CASE
#define DESERIALIZE_POLIMORPHIC_CASE(BASETYPENAME, DERIVEDTYPENAME)
Definition: Serialization.h:134
jets_cff.payload
payload
Definition: jets_cff.py:32
dqmdumpme.k
k
Definition: dqmdumpme.py:60
gen
Definition: PythiaDecays.h:13
PASSWORD_COL
static const std::string PASSWORD_COL("CRED5")
PerformancePayload
Definition: PerformancePayload.h:14
b
double b
Definition: hdecay.h:118
DESERIALIZE_BASE_CASE
#define DESERIALIZE_BASE_CASE(BASETYPENAME)
Definition: Serialization.h:129
CONNECTION_ID_COL
static const std::string CONNECTION_ID_COL("CONN_ID")
cond::SYNCH_OFFLINE
Definition: Types.h:30
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
TrackCollections2monitor_cff.sequenceName
sequenceName
Definition: TrackCollections2monitor_cff.py:6
a
double a
Definition: hdecay.h:119
cond::s_synchronizationTypeArray
static std::pair< const char *, SynchronizationType > s_synchronizationTypeArray[]
Definition: Types.cc:29
cond::SYNCH_ANY
Definition: Types.h:28
cond::selectConnection
bool selectConnection(const std::string &schemaVersion, coral::ISchema &schema, const std::string &connectionLabel, CredentialData &destination)
Definition: CredentialStore.cc:247
cond::runnumber
Definition: Time.h:19
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
condex::ParametricEfficiencyInEta
Definition: Efficiency.h:50
cond::getch
int getch()
Definition: Utilities.cc:19
P_ID_COL
static const std::string P_ID_COL("P_ID")
value
Definition: value.py:1
condex::ParametricEfficiencyInPt
Definition: Efficiency.h:31
cond::time::TimeType
cond::TimeType TimeType
Definition: Time.h:30
CSCReadoutMappingForSliceTest
Definition: CSCReadoutMappingForSliceTest.h:13
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
cond::time::lumiTime
Time_t lumiTime(unsigned int run, unsigned int lumiId)
Definition: Time.cc:54
tname
std::string tname(const std::string &tableName, const std::string &schemaVersion)
Definition: CredentialStore.cc:150
CREDENTIAL_TABLE
static const std::string CREDENTIAL_TABLE("CREDENTIAL")
PerformancePayloadFromBinnedTFormula
Definition: PerformancePayloadFromBinnedTFormula.h:17
VERIFICATION_COL
static const std::string VERIFICATION_COL("CRED0")
cond::getpass
std::string getpass(const std::string &prompt, bool show_asterisk=true)
Definition: Utilities.cc:34
HLTMuonOfflineAnalyzer_cff.destination
destination
Definition: HLTMuonOfflineAnalyzer_cff.py:50
L1DTConfigBti_cff.LL
LL
Definition: L1DTConfigBti_cff.py:25
cond::auth::COND_AUTH_PATH
static constexpr const char *const COND_AUTH_PATH
Definition: Auth.h:11
HcalCalibrationQIEData
Definition: HcalCalibrationQIEData.h:22
cond::selectAuthorization
bool selectAuthorization(const std::string &schemaVersion, coral::ISchema &schema, int principalId, const std::string &role, const std::string &connectionString, AuthorizationData &destination)
Definition: CredentialStore.cc:290
HLT_FULL_cff.payloadType
payloadType
Definition: HLT_FULL_cff.py:9452
writedatasetfile.run
run
Definition: writedatasetfile.py:27
init
Definition: init.py:1
T
long double T
Definition: Basic3DVectorLD.h:48
AUTH_ID_COL
static const std::string AUTH_ID_COL("AUTH_ID")
cond::SYNCH_RUNMC
Definition: Types.h:32
Exception
Definition: hltDiff.cc:245
PRINCIPAL_KEY_COL
static const std::string PRINCIPAL_KEY_COL("CRED1")
PRINCIPAL_ID_COL
static const std::string PRINCIPAL_ID_COL("P_ID")
cond::CondInputArchive
cond::serialization::InputArchive CondInputArchive
Definition: Serialization.h:61
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
beam_dqm_sourceclient-live_cfg.omsServiceUrl
omsServiceUrl
Definition: beam_dqm_sourceclient-live_cfg.py:378
relval_steps.gen
def gen(fragment, howMuch)
Production test section ####.
Definition: relval_steps.py:504
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
cond::persistency::throwException
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12
cond::schemaLabel
std::string schemaLabel(const std::string &serviceName, const std::string &userName)
Definition: CredentialStore.cc:167
cond::SYNCH_MC
Definition: Types.h:31
contentValuesFiles.query
query
Definition: contentValuesFiles.py:38
CSCReadoutMappingFromFile
Definition: CSCReadoutMappingFromFile.h:15
CSCReadoutMapping
Definition: CSCReadoutMapping.h:26
DTRecHitClients_cfi.local
local
Definition: DTRecHitClients_cfi.py:10
b64str
static const char * b64str
Definition: DecodingKey.cc:18
cond::s_obsoleteSynchronizationTypeArray
static std::pair< const char *, SynchronizationType > s_obsoleteSynchronizationTypeArray[]
Definition: Types.cc:40
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
condex::ConfI
Definition: Conf.h:14
cond::auth::ROLES
static const std::set< std::string > ROLES
Definition: Auth.h:21
l1RCTOmdsFedVectorProducer_cfi.connectionString
connectionString
Definition: l1RCTOmdsFedVectorProducer_cfi.py:4
mps_splice.line
line
Definition: mps_splice.py:76
lumi
Definition: LumiSectionData.h:20
SEQUENCE_VALUE_COL
static const std::string SEQUENCE_VALUE_COL("VALUE")
mix64
#define mix64(a, b, c)
Definition: hash64.cc:22
ub8
unsigned long long ub8
Definition: hash64.cc:62
cond::SYNCH_PCL
Definition: Types.h:36
cond::auth::COND_DB_KEY_SIZE
static constexpr unsigned int COND_DB_KEY_SIZE
Definition: Auth.h:31
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37