/// <summary> /// Seting custome status code in service response header /// </summary> /// <param name="code">An enumeration representing custome status code.</param> //protected void SetServiceResponseHeaders(CustomHttpStatusCode code) //{ // OutgoingWebResponseContext response = WebOperationContext.Current.OutgoingResponse; // response.StatusCode = (System.Net.HttpStatusCode)code; // if (NeeoDictionaries.HttpStatusCodeDescriptionDictionary.ContainsKey((int)code)) // response.StatusDescription = NeeoDictionaries.HttpStatusCodeDescriptionDictionary[(int)code]; //} #endregion #region User Verification /// <summary> /// Verify user account information based on user's information hash. /// </summary> /// <param name="uID">string containing the user id.</param> /// <param name="hash">string containing the user's information hash.</param> /// <returns>Returns true if hash codes are same else returns false.</returns> public bool VerifyUser(string uID, string hash) { uID = (uID != null) ? uID.Trim() : uID; #region log user request and response /*********************************************** * To log user request and response ***********************************************/ if (_logRequestResponse) { LogManager.CurrentInstance.InfoLogger.LogInfo( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, " ===> " + "Request ===> userID : " + uID + ", hash : " + hash, System.Reflection.MethodBase.GetCurrentMethod().Name); } #endregion // #region Verify User //var request = OperationContext.Current.IncomingMessageProperties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty; //string keyFromClient = request.Headers["key"]; //if (NeeoUtility.AuthenticateUserRequest(uID, keyFromClient)) //{ // #endregion try { if (!(NeeoUtility.IsNullOrEmpty(uID) && NeeoUtility.IsNullOrEmpty(hash))) { NeeoUser user = new NeeoUser(uID.Trim()); return(user.VerifyUser(hash)); } return(false); } catch (ApplicationException appExp) { LogManager.CurrentInstance.ErrorLogger.LogError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, " ===> " + "Request ===> userID : " + uID + ", hash : " + hash + " ===> " + appExp.Message, System.Reflection.MethodBase.GetCurrentMethod().Name); if (appExp.Message == CustomHttpStatusCode.InvalidUser.ToString("D")) { return(false); } NeeoUtility.SetServiceResponseHeaders((CustomHttpStatusCode)(Convert.ToInt32(appExp.Message))); return(false); } catch (Exception exp) { LogManager.CurrentInstance.ErrorLogger.LogError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, " ===> " + "Request ===> userID : " + uID + ", hash : " + hash + " ===> " + exp.Message, exp, System.Reflection.MethodBase.GetCurrentMethod().Name); NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.ServerInternalError); return(false); } // } //else //{ // NeeoUtility.SetServiceResponseHeaders((CustomHttpStatusCode)HttpStatusCode.Unauthorized); // return false; //} }