DDraceNetwork Docs
authmanager.h
Go to the documentation of this file.
1#ifndef ENGINE_SERVER_AUTHMANAGER_H
2#define ENGINE_SERVER_AUTHMANAGER_H
3
4#include <vector>
5
6#include <base/hash.h>
7
8#define SALT_BYTES 8
9
11{
12private:
13 struct CKey
14 {
15 char m_aIdent[64];
17 unsigned char m_aSalt[SALT_BYTES];
19 };
20 std::vector<CKey> m_vKeys;
21
22 int m_aDefault[3];
24
25public:
26 typedef void (*FListCallback)(const char *pIdent, int Level, void *pUser);
27
29
30 void Init();
31 int AddKeyHash(const char *pIdent, MD5_DIGEST Hash, const unsigned char *pSalt, int AuthLevel);
32 int AddKey(const char *pIdent, const char *pPw, int AuthLevel);
33 void RemoveKey(int Slot);
34 int FindKey(const char *pIdent) const;
35 bool CheckKey(int Slot, const char *pPw) const;
36 int DefaultKey(int AuthLevel) const;
37 int KeyLevel(int Slot) const;
38 const char *KeyIdent(int Slot) const;
39 void UpdateKeyHash(int Slot, MD5_DIGEST Hash, const unsigned char *pSalt, int AuthLevel);
40 void UpdateKey(int Slot, const char *pPw, int AuthLevel);
41 void ListKeys(FListCallback pfnListCallbac, void *pUser);
42 void AddDefaultKey(int Level, const char *pPw);
43 bool IsGenerated() const;
44 int NumNonDefaultKeys() const;
45};
46
47#endif //ENGINE_SERVER_AUTHMANAGER_H
#define SALT_BYTES
Definition: authmanager.h:8
Definition: authmanager.h:11
int AddKey(const char *pIdent, const char *pPw, int AuthLevel)
Definition: authmanager.cpp:61
void ListKeys(FListCallback pfnListCallbac, void *pUser)
Definition: authmanager.cpp:145
const char * KeyIdent(int Slot) const
Definition: authmanager.cpp:116
bool IsGenerated() const
Definition: authmanager.cpp:163
int m_aDefault[3]
Definition: authmanager.h:22
int KeyLevel(int Slot) const
Definition: authmanager.cpp:109
void RemoveKey(int Slot)
Definition: authmanager.cpp:69
void UpdateKeyHash(int Slot, MD5_DIGEST Hash, const unsigned char *pSalt, int AuthLevel)
Definition: authmanager.cpp:123
void AddDefaultKey(int Level, const char *pPw)
Definition: authmanager.cpp:151
int DefaultKey(int AuthLevel) const
Definition: authmanager.cpp:102
CAuthManager()
Definition: authmanager.cpp:21
void Init()
Definition: authmanager.cpp:29
void UpdateKey(int Slot, const char *pPw, int AuthLevel)
Definition: authmanager.cpp:134
void(* FListCallback)(const char *pIdent, int Level, void *pUser)
Definition: authmanager.h:26
std::vector< CKey > m_vKeys
Definition: authmanager.h:20
int NumNonDefaultKeys() const
Definition: authmanager.cpp:168
bool m_Generated
Definition: authmanager.h:23
bool CheckKey(int Slot, const char *pPw) const
Definition: authmanager.cpp:95
int AddKeyHash(const char *pIdent, MD5_DIGEST Hash, const unsigned char *pSalt, int AuthLevel)
Definition: authmanager.cpp:46
int FindKey(const char *pIdent) const
Definition: authmanager.cpp:86
Definition: authmanager.h:14
unsigned char m_aSalt[8]
Definition: authmanager.h:17
int m_Level
Definition: authmanager.h:18
MD5_DIGEST m_Pw
Definition: authmanager.h:16
char m_aIdent[64]
Definition: authmanager.h:15
Definition: hash.h:20