예제 #1
0
            private void ProcessRequest(Request req, out ReturnRequest retreq, out SynchronizeRequest syncreq)
            {
                AuthImplement authimplement = new AuthImplement(m_AuthManager);
                string token = "";
                DateTime exptime = DateTime.Now;
                bool result = false;
                AuthResult authret = new AuthResult();

                switch (req.m_RequestType) {
                    case RequestType.Authenticate:
                        authret = authimplement.Authenticate(req.m_Username, req.m_Password, out token);
                        authimplement.Validate(token, out exptime);
                        req.m_Token = token;
                        break;
                    case RequestType.CreateUser:
                        authret = authimplement.CreateUser(req.m_Username, req.m_Password, token);
                        break;
                    case RequestType.IsAdmin:
                        break;
                    case RequestType.Validate:
                        result = authimplement.Validate(req.m_Token, out exptime);
                        break;
                }
                
                // Make the ReturnRequest and SynchronizeRequest object
                retreq = new ReturnRequest(authret, token, exptime, result, req.m_Signature);
                syncreq = new SynchronizeRequest(req, m_ID, exptime);
            }
예제 #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;
     }
 }