CatalogTableUSER Class Reference

#include <CatalogTables.h>

Collaboration diagram for CatalogTableUSER:

Collaboration graph
[legend]

Public Member Functions

 CatalogTableUSER (Database *db)
DbRetVal insert (const char *name, const char *pass)
DbRetVal authenticate (const char *name, const char *pass, bool &isAuthenticated, bool &isDba)
DbRetVal remove (const char *name)
DbRetVal changePass (const char *name, const char *pass)

Detailed Description

Definition at line 146 of file CatalogTables.h.


Constructor & Destructor Documentation

CatalogTableUSER::CatalogTableUSER ( Database db  )  [inline]

Definition at line 150 of file CatalogTables.h.

00150 { systemDatabase_  = db; }


Member Function Documentation

DbRetVal CatalogTableUSER::authenticate ( const char *  name,
const char *  pass,
bool &  isAuthenticated,
bool &  isDba 
)

Definition at line 485 of file CatalogTables.cxx.

References DBAUSER, os::encrypt(), Chunk::getIterator(), Database::getSystemDatabaseChunk(), ChunkIterator::nextElement(), OK, and UserTableId.

00487 {
00488     Chunk *tChunk = systemDatabase_->getSystemDatabaseChunk(UserTableId);
00489     ChunkIterator iter = tChunk->getIterator();
00490     void *data = NULL;
00491     while (NULL != (data = iter.nextElement()))
00492     {
00493         if (strcmp(((USER*)data)->userName_, name) == 0)
00494         {
00495             //verify the password
00496             char * enpass = os::encrypt(pass,"A0");
00497             if (0 == strcmp(enpass, ((USER*)data)->password_))
00498             {
00499                 isAuthenticated = true;
00500                 if (0 == strcmp(((USER*)data)->userName_, DBAUSER))
00501                     isDba = true; else isDba = false;
00502                 return OK;
00503             }
00504         }
00505     }
00506     isAuthenticated = false;
00507     return OK;
00508 }

Here is the call graph for this function:

DbRetVal CatalogTableUSER::changePass ( const char *  name,
const char *  pass 
)

Definition at line 528 of file CatalogTables.cxx.

References os::encrypt(), ErrNotExists, Chunk::getIterator(), Database::getSystemDatabaseChunk(), ChunkIterator::nextElement(), OK, printError, and UserTableId.

Referenced by UserManagerImpl::changePassword().

00529 {
00530     Chunk *tChunk = systemDatabase_->getSystemDatabaseChunk(UserTableId);
00531     ChunkIterator iter = tChunk->getIterator();
00532     void *data = NULL;
00533     while (NULL != (data = iter.nextElement()))
00534     {
00535         if (strcmp(((USER*)data)->userName_, name) == 0)
00536         {
00537             //change the password
00538             strcpy(((USER*)data)->password_, os::encrypt(pass, "A0"));
00539             return OK;
00540         }
00541     }
00542     printError(ErrNotExists,"User %s not exists in catalog table", name);
00543     return ErrNotExists;
00544 }

Here is the call graph for this function:

Here is the caller graph for this function:

DbRetVal CatalogTableUSER::insert ( const char *  name,
const char *  pass 
)

Definition at line 468 of file CatalogTables.cxx.

References Chunk::allocate(), os::encrypt(), Database::getSystemDatabaseChunk(), OK, USER::password_, printError, USER::userName_, and UserTableId.

Referenced by UserManagerImpl::createUser(), and SessionImpl::initSystemDatabase().

00469 {
00470     Chunk *tChunk = systemDatabase_->getSystemDatabaseChunk(UserTableId);
00471     DbRetVal rv = OK;
00472     USER *usrInfo = (USER*)tChunk->allocate(systemDatabase_, &rv);
00473     if (NULL == usrInfo)
00474     {
00475         printError(rv,
00476                    "Could not allocate for USER catalog table");
00477         return rv;
00478     }
00479     strcpy(usrInfo->userName_, name);
00480     strcpy(usrInfo->password_, os::encrypt(pass, "A0"));
00481     return OK;
00482 
00483 }

Here is the call graph for this function:

Here is the caller graph for this function:

DbRetVal CatalogTableUSER::remove ( const char *  name  ) 

Definition at line 510 of file CatalogTables.cxx.

References ErrNotExists, Chunk::free(), Chunk::getIterator(), Database::getSystemDatabaseChunk(), ChunkIterator::nextElement(), OK, printError, and UserTableId.

Referenced by UserManagerImpl::deleteUser().

00511 {
00512     Chunk *tChunk = systemDatabase_->getSystemDatabaseChunk(UserTableId);
00513     ChunkIterator iter = tChunk->getIterator();
00514     void *data = NULL;
00515     while ((data = iter.nextElement())!= NULL)
00516     {
00517         if (strcmp(((USER*)data)->userName_, name) == 0)
00518         {
00519             //remove this element
00520             tChunk->free(systemDatabase_, data);
00521             return OK;
00522         }
00523     }
00524     printError(ErrNotExists,"User %s not exists in catalog table", name);
00525     return ErrNotExists;
00526 }

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 22:44:19 2008 for csql by  doxygen 1.4.7