Beispiel #1
0
        public authResponse processResponseToProxy(DataSet ds, string tui, string signature)
        {
            authResponse response = new authResponse();

            try
            {
                if (ds != null && ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    response.code    = ResponseConstants.OK.ToString();
                    response.message = ResponseConstants.Success;
                    if (tui == null || tui == "")
                    {
                        tui = Guid.NewGuid().ToString();
                    }
                    response.tui       = tui;
                    response.signature = signature;
                }
                else
                {
                    response.code    = ResponseConstants.NotOK.ToString();
                    response.message = "Login " + ResponseConstants.Fail;
                    response.tui     = tui;
                }
            }
            catch (Exception)
            {
                response.code    = ResponseConstants.NotOK.ToString();
                response.message = ResponseConstants.SomeErrorOccoured;
                response.tui     = tui;
            }
            return(response);
        }
Beispiel #2
0
        public authResponse VaidateRequest(authRequest reqObject)
        {
            authResponse response = new authResponse();
            string       message  = "";

            if (reqObject == null)
            {
                message = ResponseConstants.InvalidRequest;
            }
            else if (reqObject.name == null || reqObject.name == "")
            {
                message = "Name " + ResponseConstants.Mandatory;
            }
            else if (reqObject.password == null || reqObject.password == "")
            {
                message = "Password " + ResponseConstants.Mandatory;
            }
            response.message = message;
            response.tui     = reqObject.tui;
            if (message == "")
            {
                response.code = ResponseConstants.OK.ToString();
            }
            else
            {
                response.code = ResponseConstants.NotOK.ToString();
            }
            return(response);
        }
Beispiel #3
0
        public HttpResponseMessage AuthCheck([FromBody] authRequest reqObj)
        {
            #region variable
            string encCredentials = "";
            var    st             = new StackTrace();
            var    sf             = st.GetFrame(0);
            currentMethodName     = sf.GetMethod().Name;
            currentControllerName = this.GetType().Name;
            #endregion

            #region objects
            AuthHelper    helperObj = new AuthHelper();
            GeneralHelper GH        = new GeneralHelper();
            DataSet       ds;
            authResponse  response = new authResponse();
            #endregion

            try
            {
                //Log Request
                LogRequest(currentControllerName, currentMethodName, new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(reqObj), WorkFlowConstants.Login, reqObj.tui);
                //Validate Request
                response = helperObj.VaidateRequest(reqObj);
                if (response != null && response.code == ResponseConstants.OK.ToString())
                {
                    //Check Login
                    ds = GH.getAuthData(reqObj);
                    if (ds != null && ds.Tables != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0)
                    {
                        encCredentials = GH.getSignature(reqObj.name + "|" + reqObj.password + "|" + DateTime.Now.ToString() + "|" + ds.Tables[0].Rows[0]["UserId"].ToString());
                    }
                    //Response Processing
                    response = helperObj.processResponseToProxy(ds, reqObj.tui, encCredentials);
                }
                //Log Response
                LogResponse(currentControllerName, currentMethodName, new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(response), WorkFlowConstants.Login, response.tui);
            }
            catch (Exception ex)
            {
                try
                {
                    currentMethodName     = ex.Message.ToString().Split('|').Count() > 0 ? ex.Message.ToString().Split('|')[0] : currentMethodName;
                    currentControllerName = ex.Message.ToString().Split('|').Count() > 1 ? ex.Message.ToString().Split('|')[1] : this.GetType().Name;
                    LogError(currentControllerName, currentMethodName, ex.Message, reqObj.tui);
                }
                catch (Exception)
                {
                }

                response.code    = ResponseConstants.Exception.ToString();
                response.message = ResponseConstants.SomeErrorOccoured;
            }
            msg = Request.CreateResponse(HttpStatusCode.OK, response);
            return(msg);
        }