Пример #1
0
        public DataSet getAuthData(authRequest authObj)
        {
            DataSet   ds = new DataSet();
            paramFile PF = new paramFile(ParamsPath);

            try
            {
                string        dbCon     = PF.getDatabaseConnectionString(DBConstants.MainDB);
                DataOperation DO        = new DataOperation(dbCon);
                sp_AuthCheck  authCheck = new sp_AuthCheck();
                authCheck.uName  = authObj.name;
                authCheck.pwd    = authObj.password;
                authCheck.action = "select";
                DO.BeginTRansaction();
                ds = DO.iteratePropertyObjectsSP(authCheck, "sp_AuthCheck");
                DO.EndTRansaction();
            }
            catch (Exception ex)
            {
                var       st = new StackTrace();
                var       sf = st.GetFrame(0);
                string    currentMethodName = sf.GetMethod().Name;
                Exception customex          = new Exception(currentMethodName + " | " + this.GetType().Name + " | " + ex.Message + " : " + ex.StackTrace);
                throw customex;
            }
            return(ds);
        }
Пример #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);
        }
Пример #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);
        }
Пример #4
0
        public string GetToken(string login, string password)
        {
            AuthSoap.AuthInterface d           = new AuthInterfaceClient();
            AuthSoap.authRequest   authRequest = new authRequest();
            authRequest.login    = login;
            authRequest.password = password;
            string token = String.Empty;

            try
            {
                AuthSoap.authResponse authResponse = d.auth(authRequest);
                return(authResponse.@return);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Пример #5
0
        public void step_01()
        {
            Logger.PrintHeadTest("[SOAP] Метод аутентификации [auth]");
            Logger.PrintStepName("Step 1");
            Logger.PrintAction("подключению к сервису", "");
            AuthSoap.AuthInterface d           = new AuthInterfaceClient();
            AuthSoap.authRequest   authRequest = new authRequest();
            authRequest.login    = login;
            authRequest.password = password;
            string token = String.Empty;

            try
            {
                AuthSoap.authResponse authResponse = d.auth(authRequest);
                token = ths.GetToken(login, password);
                Logger.PrintAction("Токен получен", token);
            }
            catch (Exception ex)
            {
                Assertion("Ошибка получения токена: " + ex.Message, Assert.Fail);
            }
        }