reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
userAdmin.cxx
Go to the documentation of this file.
1
2#include "rutil/ResipAssert.h"
3#include <iostream>
4
5#include "repro/UserDb.hxx"
6#include "repro/WebAdmin.hxx"
7#include "rutil/Data.hxx"
8#include "rutil/Logger.hxx"
9
10using namespace resip;
11using namespace repro;
12using namespace std;
13
14#define RESIPROCATE_SUBSYSTEM Subsystem::REPRO
15
16
17void
18add( char* pUsername, char* pRealm, char* pPasswd )
19{
20 UserDb db;
21
22 Data fullName = Data::Empty;
23 Data email = Data::Empty;
24
25 db.addUser( Data(pUsername),
26 Data(pRealm),
27 Data(pRealm),
28 Data(pPasswd),
29 fullName,
30 email );
31}
32
33
34void
35remove( char* pAor )
36{
37 UserDb db;
38
39 db.removeUser( Data(pAor) );
40}
41
42
43void
44web(int port)
45{
46 resip_assert(0);
47#if 0
48 UserDb db;
49
50 WebAdmin webAdmin( db, port );
51
52 while (1)
53 {
54 FdSet fdset;
55
56 webAdmin.buildFdSet(fdset);
57 fdset.selectMilliSeconds( 10*1000 );
58
59 webAdmin.process(fdset);
60 }
61#endif
62}
63
64
65void
67{
68 UserDb db;
69
70 Data key = db.getFirstKey();
71 while ( !key.empty() )
72 {
73 Data hash = db.getUserAuthInfo(key);
74
75 clog << "Key: " << key << endl;
76 clog << " passwordHash = " << hash << endl;
77
78 key = db.getNextKey();
79 }
80}
81
82
83void
85{
86 clog << "Command line options are" << endl
87 << " -list" << endl
88 << " -add user realm password" << endl
89 << " -remove aor" << endl
90 << " -web" << endl;
91}
92
93
94int
95main(int argc, char* argv[])
96{
99
100 for ( int i=1; i<argc; i++ )
101 {
102 if ( !strcmp(argv[i],"-list" ) )
103 {
104 list();
105 }
106 if ( !strcmp(argv[i],"-web" ) )
107 {
108 int port=5080;
109 web(port);
110 }
111 else if (!strcmp(argv[i],"-add"))
112 {
113 i++;
114 resip_assert( i<argc );
115 char* username = argv[i];
116
117 i++;
118 resip_assert( i<argc );
119 char* realm = argv[i];
120
121 i++;
122 resip_assert( i<argc );
123 char* passwd = argv[i];
124
125 add( username, realm, passwd );
126 }
127 else if (!strcmp(argv[i],"-remove"))
128 {
129 i++;
130 resip_assert( i<argc );
131 char* aor = argv[i];
132 remove( aor );
133 }
134 else
135 {
136 usage();
137 exit(1);
138 }
139 }
140
141 return 0;
142}
#define resip_assert(x)
This file needs to work for both C and C++ code.
void buildFdSet(resip::FdSet &fdset)
Definition HttpBase.cxx:149
void process(resip::FdSet &fdset)
Definition HttpBase.cxx:164
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
static const Data Empty
Constant that represents a zero-length data.
Definition Data.hxx:882
bool empty() const noexcept
Checks whether the Data is empty.
Definition Data.hxx:591
Object-oriented wrapper for your platform's file-descriptor set.
Definition Socket.hxx:162
int selectMilliSeconds(unsigned long ms)
Definition Socket.hxx:181
static void setLevel(Level level)
Set logging level for current thread.
Definition Log.cxx:423
static void initialize(Type type, Level level, const Data &appName, const char *logFileName=0, ExternalLogger *externalLogger=0, const Data &syslogFacility="LOG_DAEMON", MessageStructure messageStructure=Unstructured, const Data &instanceName="")
Definition Log.cxx:268
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;
int main(int argc, char *argv[])
Definition userAdmin.cxx:95
void add(char *pUsername, char *pRealm, char *pPasswd)
Definition userAdmin.cxx:18
void usage()
Definition userAdmin.cxx:84
void remove(char *pAor)
Definition userAdmin.cxx:35
void web(int port)
Definition userAdmin.cxx:44
void list()
Definition userAdmin.cxx:66