CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
cond::RelationalAuthenticationService::RelationalAuthenticationService Class Reference

#include <RelationalAuthenticationService.h>

Inheritance diagram for cond::RelationalAuthenticationService::RelationalAuthenticationService:
cond::persistency::IDbAuthentication

Public Member Functions

const coral::IAuthenticationCredentials & credentials (const std::string &connectionString) const override
 
const coral::IAuthenticationCredentials & credentials (const std::string &connectionString, const std::string &role) const override
 
std::string principalName () override
 
 RelationalAuthenticationService (const std::string &name)
 Standard Constructor. More...
 
void setAuthenticationPath (const std::string &inputPath)
 Sets the input file name. More...
 
 ~RelationalAuthenticationService () override
 Standard Destructor. More...
 
- Public Member Functions inherited from cond::persistency::IDbAuthentication
virtual ~IDbAuthentication ()
 

Private Attributes

std::string m_authenticationPath
 The input file with the data. More...
 
coral_bridge::AuthenticationCredentialSet m_cache
 
coral::Property::CallbackID m_callbackID
 
CredentialStore m_db
 The service providing the authentication data. More...
 

Detailed Description

Definition at line 27 of file RelationalAuthenticationService.h.

Constructor & Destructor Documentation

◆ RelationalAuthenticationService()

cond::RelationalAuthenticationService::RelationalAuthenticationService::RelationalAuthenticationService ( const std::string &  name)
explicit

Standard Constructor.

Definition at line 21 of file RelationalAuthenticationService.cc.

23  : coral::Service(key), m_authenticationPath(""), m_db(), m_cache(), m_callbackID(0) {
24  boost::function1<void, std::string> cb(
26  this,
27  std::placeholders::_1));
28 
29  coral::Property* pm = dynamic_cast<coral::Property*>(
30  coral::Context::instance().PropertyManager().property(auth::COND_AUTH_PATH_PROPERTY));
31  if (pm) {
32  setAuthenticationPath(pm->get());
33  m_callbackID = pm->registerCallback(cb);
34  }
35 }

References cond::auth::COND_AUTH_PATH_PROPERTY, instance, m_callbackID, and setAuthenticationPath().

◆ ~RelationalAuthenticationService()

cond::RelationalAuthenticationService::RelationalAuthenticationService::~RelationalAuthenticationService ( )
override

Standard Destructor.

Definition at line 37 of file RelationalAuthenticationService.cc.

37 {}

Member Function Documentation

◆ credentials() [1/2]

const coral::IAuthenticationCredentials & cond::RelationalAuthenticationService::RelationalAuthenticationService::credentials ( const std::string &  connectionString) const
override

Returns a reference to the credentials object for a given connection string. If the connection string is not known to the service an UnknownConnectionException is thrown.

Definition at line 46 of file RelationalAuthenticationService.cc.

47  {
48  std::string connectionString = to_lower(connectionStr);
49  const coral::IAuthenticationCredentials* creds = m_cache.get(connectionString);
50  if (!creds) {
52  coral::MessageStream log("cond::RelationalAuthenticationService::credentials");
53  log << coral::Debug << "Connecting to the credential repository in \"" << credsStoreConn << "\" with principal \""
54  << m_db.keyPrincipalName() << "\"." << coral::MessageStream::endmsg;
56  }
57  creds = m_cache.get(connectionString);
58  if (!creds) {
59  std::string msg("Connection to \"");
60  msg += connectionString + "\"";
61  msg += " with role \"COND_DEFAULT_ROLE\" is not available for ";
63  cond::throwException(msg, "cond::RelationalAuthenticationService::RelationalAuthenticationService::credentials");
64  }
65  return *creds;
66 }

References l1RCTOmdsFedVectorProducer_cfi::connectionString, Debug, dqm-mbProfile::log, mps_check::msg, AlCaHLTBitMon_QueryRunRegistry::string, cond::throwException(), and to_lower().

◆ credentials() [2/2]

const coral::IAuthenticationCredentials & cond::RelationalAuthenticationService::RelationalAuthenticationService::credentials ( const std::string &  connectionString,
const std::string &  role 
) const
override

Returns a reference to the credentials object for a given connection string. If the connection string is not known to the service an UnknownConnectionException is thrown. If the role is not known to the service an UnknownRoleException is thrown.

Definition at line 69 of file RelationalAuthenticationService.cc.

70  {
71  std::string connectionString = to_lower(connectionStr);
72  const coral::IAuthenticationCredentials* creds = m_cache.get(connectionString, role);
73  if (!creds) {
75  coral::MessageStream log("cond::RelationalAuthenticationService::credentials");
76  log << coral::Debug << "Connecting to the credential repository in \"" << credsStoreConn << "\" with principal \""
77  << m_db.keyPrincipalName() << "\"." << coral::MessageStream::endmsg;
79  }
80  creds = m_cache.get(connectionString, role);
81  if (!creds) {
82  std::string msg("Connection to \"");
83  msg += connectionString + "\"";
84  msg += " with role \"" + role + "\" is not available for ";
86  cond::throwException(msg, "cond::RelationalAuthenticationService::RelationalAuthenticationService::credentials");
87  }
88  return *creds;
89 }

References l1RCTOmdsFedVectorProducer_cfi::connectionString, Debug, dqm-mbProfile::log, mps_check::msg, AlCaHLTBitMon_QueryRunRegistry::string, cond::throwException(), and to_lower().

◆ principalName()

std::string cond::RelationalAuthenticationService::RelationalAuthenticationService::principalName ( )
overridevirtual

Implements cond::persistency::IDbAuthentication.

Definition at line 91 of file RelationalAuthenticationService.cc.

91  {
92  return m_db.keyPrincipalName();
93 }

◆ setAuthenticationPath()

void cond::RelationalAuthenticationService::RelationalAuthenticationService::setAuthenticationPath ( const std::string &  inputPath)

Sets the input file name.

Definition at line 39 of file RelationalAuthenticationService.cc.

40  {
42  m_cache.reset();
43 }

References SiStripCommissioningSource_FromEDM_cfg::inputPath.

Referenced by RelationalAuthenticationService().

Member Data Documentation

◆ m_authenticationPath

std::string cond::RelationalAuthenticationService::RelationalAuthenticationService::m_authenticationPath
private

The input file with the data.

Definition at line 59 of file RelationalAuthenticationService.h.

◆ m_cache

coral_bridge::AuthenticationCredentialSet cond::RelationalAuthenticationService::RelationalAuthenticationService::m_cache
mutableprivate

Definition at line 64 of file RelationalAuthenticationService.h.

◆ m_callbackID

coral::Property::CallbackID cond::RelationalAuthenticationService::RelationalAuthenticationService::m_callbackID
private

Definition at line 66 of file RelationalAuthenticationService.h.

Referenced by RelationalAuthenticationService().

◆ m_db

CredentialStore cond::RelationalAuthenticationService::RelationalAuthenticationService::m_db
mutableprivate

The service providing the authentication data.

Definition at line 62 of file RelationalAuthenticationService.h.

cond::RelationalAuthenticationService::RelationalAuthenticationService::m_authenticationPath
std::string m_authenticationPath
The input file with the data.
Definition: RelationalAuthenticationService.h:59
cond::CredentialStore::keyPrincipalName
const std::string & keyPrincipalName()
Definition: CredentialStore.cc:1584
cond::RelationalAuthenticationService::RelationalAuthenticationService::setAuthenticationPath
void setAuthenticationPath(const std::string &inputPath)
Sets the input file name.
Definition: RelationalAuthenticationService.cc:39
mps_check.msg
tuple msg
Definition: mps_check.py:285
coral_bridge::AuthenticationCredentialSet::get
const coral::IAuthenticationCredentials * get(const std::string &connectionString) const
Definition: CredentialStore.cc:97
cond::CredentialStore::selectForUser
bool selectForUser(coral_bridge::AuthenticationCredentialSet &destinationData)
Definition: CredentialStore.cc:1230
cond::RelationalAuthenticationService::RelationalAuthenticationService::m_callbackID
coral::Property::CallbackID m_callbackID
Definition: RelationalAuthenticationService.h:66
Debug
const bool Debug
Definition: CosmicMuonParameters.h:12
cond::CredentialStore::setUpForConnectionString
std::string setUpForConnectionString(const std::string &connectionString, const std::string &authPath)
Definition: CredentialStore.cc:791
coral_bridge::AuthenticationCredentialSet::reset
void reset()
Definition: CredentialStore.cc:37
cond::RelationalAuthenticationService::RelationalAuthenticationService::m_cache
coral_bridge::AuthenticationCredentialSet m_cache
Definition: RelationalAuthenticationService.h:64
to_lower
std::string to_lower(const std::string &s)
Definition: CredentialStore.h:23
cond::RelationalAuthenticationService::RelationalAuthenticationService::m_db
CredentialStore m_db
The service providing the authentication data.
Definition: RelationalAuthenticationService.h:62
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
instance
static PFTauRenderPlugin instance
Definition: PFTauRenderPlugin.cc:70
SiStripCommissioningSource_FromEDM_cfg.inputPath
inputPath
Definition: SiStripCommissioningSource_FromEDM_cfg.py:8
cond::auth::COND_AUTH_PATH_PROPERTY
static constexpr const char *const COND_AUTH_PATH_PROPERTY
Definition: Auth.h:50
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
l1RCTOmdsFedVectorProducer_cfi.connectionString
connectionString
Definition: l1RCTOmdsFedVectorProducer_cfi.py:4
crabWrapper.key
key
Definition: crabWrapper.py:19
cond::throwException
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18