Exemplo n.º 1
0
        public void CreateAuthManager()
        {
            // Very Important: Before we start the monitoring thread
            // We need to keep the data in the new authserver up to date
            // We need to lock the m_SyncRequestQueue so that no synchronization request will be served in the mean time
            // Then we copy the data in an arbitrary existing AuthManager instance, 
            // This depends on the correct implementation of copy constructor of AuthManager and its data member
            // note that we do not lock the AuthManager instance we are going to copy
            // So that we are not going to exprience the deadlock
            // If the AuthManager is being modified by serving some requests, the new instance will be updated later
            
            // Sleep a little bit first before we start: for random number generator
            Thread.Sleep(5);

            lock (m_SyncRequestQueue)
            {
                int ID = m_AuthManagerList.Count;
                AuthManager am;
                if (ID == 0)
                {
                    am = new AuthManager();
                }
                else
                {
                    am = new AuthManager(m_AuthManagerList[0]);
                }
                AuthManagerMoniterThread ammt = new AuthManagerMoniterThread(ID, m_RequestQueue, am, m_ReturnRequestQueue, m_SyncRequestQueue);
                m_AuthManagerList.Add(am);
                m_AuthManagerMoniterThreadList.Add(ammt);

#if DEBUG
                Console.WriteLine("Create a AuthManager, ID: " + ID + " , Good Luck!");
#endif
                Thread td = new Thread(new ThreadStart(ammt.proc));
                m_MoniterThreadList.Add(td);
                td.Start();
            }
        }
Exemplo n.º 2
0
 // Call this function only with am locked
 private void ProcessSynchronizeRequest(AuthManager am, SynchronizeRequest syncreq)
 {
     Request req = syncreq.m_Request;
     string msg = "";
     switch (req.m_RequestType)
     {
         // If we created a new user, just call the Register function
         case RequestType.CreateUser:
             am.Register(req.m_Username, req.m_Password, out msg);
             break;
         // If we generate a token for a user, we need to create this token for other co-existing authservers
         case RequestType.Authenticate:
             am.AddSynchronizedToken(req.m_Token, req.m_Username, syncreq.m_ExpTime);
             break;
         default:
             break;
     }
 }
Exemplo n.º 3
0
 public AuthManagerMoniterThread(int ID, BlockingQueue<Request> bQ, AuthManager authManager, BlockingQueue<ReturnRequest> bQReturn, BlockingQueue<SynchronizeRequest> bQSync)
 {
     m_RequestQueue = bQ;
     m_AuthManager = authManager;
     m_ID = ID;
     m_ReturnRequestQueue = bQReturn;
     m_SyncRequestQueue = bQSync;
 }
Exemplo n.º 4
0
 public AuthImplement(AuthManager mgr) 
 {
     m_Mgr = mgr;     
 }
Exemplo n.º 5
0
 /// <summary>
 /// Constructor of the class
 /// </summary>
 public AuthCommService() 
 {
     AuthMgr = new AuthManager();
 }
Exemplo n.º 6
0
  //Copy Constructor
 public AuthManager(AuthManager am)
 {
     //m_File = new CredentialFile(am.m_File);
     //m_TokenMgr = new TokenManager(am.tokenMgr);
 }
Exemplo n.º 7
0
 public AuthValidate(AuthManager mgr) 
 {
     m_Mgr = mgr;     
 }
Exemplo n.º 8
0
        public AuthServer(AuthManager mgr) 
        {
 
        }