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.

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

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 }
static PFTauRenderPlugin instance
static constexpr const char *const COND_AUTH_PATH_PROPERTY
Definition: Auth.h:50
void setAuthenticationPath(const std::string &inputPath)
Sets the input file name.
CredentialStore m_db
The service providing the authentication data.

◆ ~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.

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

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 }
const std::string & keyPrincipalName()
std::string to_lower(const std::string &s)
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18
std::string setUpForConnectionString(const std::string &connectionString, const std::string &authPath)
bool selectForUser(coral_bridge::AuthenticationCredentialSet &destinationData)
tuple msg
Definition: mps_check.py:285
CredentialStore m_db
The service providing the authentication data.
const coral::IAuthenticationCredentials * get(const std::string &connectionString) const
const bool Debug

◆ 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.

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

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 }
const std::string & keyPrincipalName()
std::string to_lower(const std::string &s)
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18
std::string setUpForConnectionString(const std::string &connectionString, const std::string &authPath)
bool selectForUser(coral_bridge::AuthenticationCredentialSet &destinationData)
tuple msg
Definition: mps_check.py:285
CredentialStore m_db
The service providing the authentication data.
const coral::IAuthenticationCredentials * get(const std::string &connectionString) const
const bool Debug

◆ 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 }
const std::string & keyPrincipalName()
CredentialStore m_db
The service providing the authentication data.

◆ setAuthenticationPath()

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

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.