reSIProcate/repro  9694
Defines | Functions
userAdmin.cxx File Reference
#include <cassert>
#include <iostream>
#include "repro/UserDb.hxx"
#include "repro/WebAdmin.hxx"
#include "rutil/Data.hxx"
#include "rutil/Logger.hxx"
Include dependency graph for userAdmin.cxx:

Go to the source code of this file.

Defines

#define RESIPROCATE_SUBSYSTEM   Subsystem::REPRO

Functions

void add (char *pUsername, char *pRealm, char *pPasswd)
void remove (char *pAor)
void web (int port)
void list ()
void usage ()
int main (int argc, char *argv[])

Define Documentation

#define RESIPROCATE_SUBSYSTEM   Subsystem::REPRO

Definition at line 14 of file userAdmin.cxx.


Function Documentation

void add ( char *  pUsername,
char *  pRealm,
char *  pPasswd 
)

Definition at line 18 of file userAdmin.cxx.

{
   UserDb db;  

   Data fullName = Data::Empty;
   Data email = Data::Empty;
   
   db.addUser( Data(pUsername), 
               Data(pRealm), 
               Data(pRealm), 
               Data(pPasswd),
               fullName, 
               email );
}
void list ( )

Definition at line 66 of file userAdmin.cxx.

{
   UserDb db; 
   
   Data key = db.getFirstKey();
   while ( !key.empty() )
   {
      Data hash = db.getUserAuthInfo(key);
      
      clog << "Key: " << key << endl;
      clog << "  passwordHash = " << hash << endl;
      
      key = db.getNextKey();
   } 
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 95 of file userAdmin.cxx.

{
   Log::initialize(Log::Cerr, Log::Err, argv[0]);
   Log::setLevel(Log::Info);

   for ( int i=1; i<argc; i++ )
   {
      if ( !strcmp(argv[i],"-list" ) )
      {
         list();
      }
      if ( !strcmp(argv[i],"-web" ) )
      {
         int port=5080;
         web(port);
      }
      else if (!strcmp(argv[i],"-add"))
      {
         i++;
         assert( i<argc );
         char* username = argv[i];

         i++;
         assert( i<argc );
         char* realm = argv[i];

         i++;
         assert( i<argc );
         char* passwd = argv[i];

         add( username, realm, passwd );
      }  
      else if (!strcmp(argv[i],"-remove"))
      {
         i++;
         assert( i<argc );
         char* aor = argv[i];
         remove( aor );
      }  
      else
      {
         usage();
         exit(1);
      }
   }

   return 0;
}
void remove ( char *  pAor)

Definition at line 35 of file userAdmin.cxx.

{ 
   UserDb db;
   
   db.removeUser( Data(pAor) );
}
void usage ( )

Definition at line 84 of file userAdmin.cxx.

{
   clog << "Command line options are" << endl
        << "  -list" << endl
        << "  -add user realm password" << endl
        << "  -remove aor" << endl
        << "  -web" << endl;
}
void web ( int  port)

Definition at line 44 of file userAdmin.cxx.

{
   assert(0);
#if 0
   UserDb db;
   
   WebAdmin webAdmin( db, port );
   
   while (1)
   {
      FdSet fdset; 
     
      webAdmin.buildFdSet(fdset);
      fdset.selectMilliSeconds( 10*1000 );

      webAdmin.process(fdset);
   }
#endif
}