CMS 3D CMS Logo

Classes | Namespaces | Functions | Variables
CredentialStore.cc File Reference
#include "CondCore/CondDB/interface/CredentialStore.h"
#include "CondCore/CondDB/interface/Cipher.h"
#include "CondCore/CondDB/interface/Exception.h"
#include "CondCore/CondDB/interface/Auth.h"
#include "CoralBase/AttributeList.h"
#include "CoralBase/Attribute.h"
#include "CoralKernel/Context.h"
#include "CoralCommon/URIParser.h"
#include "RelationalAccess/AuthenticationCredentials.h"
#include "RelationalAccess/IBulkOperation.h"
#include "RelationalAccess/IConnection.h"
#include "RelationalAccess/ISession.h"
#include "RelationalAccess/IRelationalService.h"
#include "RelationalAccess/IRelationalDomain.h"
#include "RelationalAccess/ITransaction.h"
#include "RelationalAccess/ISchema.h"
#include "RelationalAccess/ITable.h"
#include "RelationalAccess/TableDescription.h"
#include "RelationalAccess/ITableDataEditor.h"
#include "RelationalAccess/IQuery.h"
#include "RelationalAccess/ICursor.h"
#include <sstream>
#include <fstream>
#include <boost/filesystem.hpp>

Go to the source code of this file.

Classes

struct  cond::AuthorizationData
 
struct  cond::CredentialData
 
class  cond::CSScopedSession
 
struct  cond::PrincipalData
 

Namespaces

 cond
 

Functions

void addSequence (coral::ISchema &schema, const std::string &name)
 
static const std::string ADMIN_KEY_COL ("CRED2")
 
static const std::string AUTH_ID_COL ("AUTH_ID")
 
static const std::string AUTH_KEY_COL ("CRED3")
 
static const std::string C_ID_COL ("C_ID")
 
static const std::string COND_AUTHENTICATION_TABLE ("COND_AUTHENTICATION")
 
static const std::string COND_AUTHORIZATION_TABLE ("COND_AUTHORIZATION")
 
static const std::string COND_CREDENTIAL_TABLE ("COND_CREDENTIAL")
 
static const std::string CONNECTION_ID_COL ("CONN_ID")
 
static const std::string CONNECTION_KEY_COL ("CRED7")
 
static const std::string CONNECTION_LABEL_COL ("CONN_LABEL")
 
const std::string DEFAULT_DATA_SOURCE ("Cond_Default_Authentication")
 
bool getNextSequenceValue (coral::ISchema &schema, const std::string &sequenceName, int &value)
 
static const std::string P_ID_COL ("P_ID")
 
static const std::string PASSWORD_COL ("CRED5")
 
static const std::string PRINCIPAL_ID_COL ("P_ID")
 
static const std::string PRINCIPAL_KEY_COL ("CRED1")
 
static const std::string PRINCIPAL_NAME_COL ("P_NAME")
 
static const std::string ROLE_COL ("C_ROLE")
 
static const std::string SCHEMA_COL ("C_SCHEMA")
 
std::string cond::schemaLabel (const std::string &serviceName, const std::string &userName)
 
std::string cond::schemaLabelForCredentialStore (const std::string &connectionString)
 
bool cond::selectAuthorization (coral::ISchema &schema, int principalId, const std::string &role, const std::string &connectionString, AuthorizationData &destination)
 
bool cond::selectConnection (coral::ISchema &schema, const std::string &connectionLabel, CredentialData &destination)
 
bool cond::selectPrincipal (coral::ISchema &schema, const std::string &principal, PrincipalData &destination)
 
static const std::string SEQUENCE_NAME_COL ("NAME")
 
static const std::string SEQUENCE_TABLE_NAME ("COND_CREDENTIAL_SEQUENCE")
 
static const std::string SEQUENCE_VALUE_COL ("VALUE")
 
static const std::string USERNAME_COL ("CRED4")
 
static const std::string VERIFICATION_COL ("CRED0")
 
static const std::string VERIFICATION_KEY_COL ("CRED6")
 

Variables

static const std::string serviceName = "CondAuthenticationService"
 

Function Documentation

void addSequence ( coral::ISchema &  schema,
const std::string &  name 
)

Definition at line 739 of file CredentialStore.cc.

References SEQUENCE_NAME_COL(), SEQUENCE_TABLE_NAME(), SEQUENCE_VALUE_COL(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by cond::CredentialStore::createSchema().

739  {
740  // Create the entry in the table
741  coral::AttributeList insertData;
742  insertData.extend<std::string>( SEQUENCE_NAME_COL );
743  insertData.extend<int>(SEQUENCE_VALUE_COL);
744  coral::AttributeList::iterator iAttribute = insertData.begin();
745  iAttribute->data< std::string >() = name;
746  ++iAttribute;
747  iAttribute->data< int >() = -1;
748  schema.tableHandle( SEQUENCE_TABLE_NAME ).dataEditor().insertRow( insertData );
749 }
static const std::string SEQUENCE_VALUE_COL("VALUE")
static const std::string SEQUENCE_TABLE_NAME("COND_CREDENTIAL_SEQUENCE")
static const std::string SEQUENCE_NAME_COL("NAME")
static const std::string ADMIN_KEY_COL ( "CRED2"  )
static
static const std::string AUTH_ID_COL ( "AUTH_ID"  )
static
static const std::string AUTH_KEY_COL ( "CRED3"  )
static
static const std::string C_ID_COL ( "C_ID"  )
static
static const std::string COND_AUTHENTICATION_TABLE ( "COND_AUTHENTICATION"  )
static
static const std::string COND_AUTHORIZATION_TABLE ( "COND_AUTHORIZATION"  )
static
static const std::string COND_CREDENTIAL_TABLE ( "COND_CREDENTIAL"  )
static
static const std::string CONNECTION_ID_COL ( "CONN_ID"  )
static
static const std::string CONNECTION_KEY_COL ( "CRED7"  )
static
static const std::string CONNECTION_LABEL_COL ( "CONN_LABEL"  )
static
const std::string DEFAULT_DATA_SOURCE ( "Cond_Default_Authentication"  )
bool getNextSequenceValue ( coral::ISchema &  schema,
const std::string &  sequenceName,
int &  value 
)

Definition at line 356 of file CredentialStore.cc.

References das::query(), SEQUENCE_NAME_COL(), SEQUENCE_TABLE_NAME(), SEQUENCE_VALUE_COL(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by cond::CredentialStore::addUser(), cond::CredentialStore::installAdmin(), cond::CredentialStore::setPermission(), cond::CredentialStore::updateConnection(), and cond::CredentialStore::updatePrincipal().

356  {
357  bool ret = false;
358  std::auto_ptr< coral::IQuery > query( schema.tableHandle( SEQUENCE_TABLE_NAME ).newQuery() );
359  query->limitReturnedRows( 1, 0 );
360  query->addToOutputList( SEQUENCE_VALUE_COL );
361  query->defineOutputType( SEQUENCE_VALUE_COL, coral::AttributeSpecification::typeNameForType<int>() );
362  query->setForUpdate();
363  std::string whereClause( SEQUENCE_NAME_COL + " = :" + SEQUENCE_NAME_COL );
364  coral::AttributeList rowData;
365  rowData.extend<std::string>( SEQUENCE_NAME_COL );
366  rowData.begin()->data< std::string >() = sequenceName;
367  query->setCondition( whereClause, rowData );
368  coral::ICursor& cursor = query->execute();
369  if ( cursor.next() ) {
370  value = cursor.currentRow().begin()->data<int>()+1;
371  ret = true;
372  } else {
373  return false;
374  }
375  // update...
376  coral::AttributeList updateData;
377  updateData.extend<std::string>( SEQUENCE_NAME_COL );
378  updateData.extend<int>( SEQUENCE_VALUE_COL );
379  std::string setClause( SEQUENCE_VALUE_COL + " = :" + SEQUENCE_VALUE_COL );
380  std::string whClause( SEQUENCE_NAME_COL + " = :" + SEQUENCE_NAME_COL );
381  coral::AttributeList::iterator iAttribute = updateData.begin();
382  iAttribute->data< std::string >() = sequenceName;
383  ++iAttribute;
384  iAttribute->data< int >() = value;
385  schema.tableHandle( SEQUENCE_TABLE_NAME ).dataEditor().updateRows( setClause,whClause,updateData );
386  return ret;
387 }
static const std::string SEQUENCE_VALUE_COL("VALUE")
static const std::string SEQUENCE_TABLE_NAME("COND_CREDENTIAL_SEQUENCE")
def query(query_str, verbose=False)
Definition: das.py:5
Definition: query.py:1
static const std::string SEQUENCE_NAME_COL("NAME")
Definition: value.py:1
static const std::string P_ID_COL ( "P_ID"  )
static
static const std::string PASSWORD_COL ( "CRED5"  )
static
static const std::string PRINCIPAL_ID_COL ( "P_ID"  )
static
static const std::string PRINCIPAL_KEY_COL ( "CRED1"  )
static
static const std::string PRINCIPAL_NAME_COL ( "P_NAME"  )
static
static const std::string ROLE_COL ( "C_ROLE"  )
static
static const std::string SCHEMA_COL ( "C_SCHEMA"  )
static
static const std::string SEQUENCE_NAME_COL ( "NAME"  )
static
static const std::string SEQUENCE_TABLE_NAME ( "COND_CREDENTIAL_SEQUENCE"  )
static
static const std::string SEQUENCE_VALUE_COL ( "VALUE"  )
static
static const std::string USERNAME_COL ( "CRED4"  )
static
static const std::string VERIFICATION_COL ( "CRED0"  )
static
static const std::string VERIFICATION_KEY_COL ( "CRED6"  )
static

Variable Documentation

const std::string serviceName = "CondAuthenticationService"
static