Ejemplo n.º 1
0
        public void DuplicateNames()
        {
            HttpCookieCollection col     = new HttpCookieCollection();
            HttpCookie           cookie1 = new HttpCookie("cookie", "value1");
            HttpCookie           cookie2 = new HttpCookie("cookie", "value2");

            col.Add(cookie1);
            col.Add(cookie2);

            Assert.AreEqual("value1", col["cookie"].Value, "add should use first used cookie");

            col.Set(cookie2);
            Assert.AreEqual("value2", col["cookie"].Value, "set should use last used cookie");

            col.Clear();
            col.Add(cookie1);
            col.Add(cookie2);

            // Bug #553150
            HttpCookie tmp = col.Get(0);

            Assert.AreEqual("cookie", tmp.Name, "#A1");
            Assert.AreEqual("value1", tmp.Value, "#A1-1");

            tmp = col.Get(1);
            Assert.AreEqual("cookie", tmp.Name, "#A2");
            Assert.AreEqual("value2", tmp.Value, "#A2-1");
        }
Ejemplo n.º 2
0
        private DataLayerModel GetDataLayer(HttpCookieCollection cookies)
        {
            var cookieName  = ConfigurationManager.AppSettings["Datalayer:CookieName"];
            var sessionName = ConfigurationManager.AppSettings["Datalayer:SessionName"];

            var tagObject = new DataLayerModel();

            if (cookies.Get(cookieName) != null)
            {
                if (Session[sessionName] != null)
                {
                    var sessionTag = Session[sessionName] as DataLayerModel;
                    var cookieTag  = JsonConvert.DeserializeObject <DataLayerModel>(cookies.Get(cookieName).Value);
                    tagObject = cookieTag.Equals(sessionTag) ? sessionTag : cookieTag;
                }
                else
                {
                    tagObject            = JsonConvert.DeserializeObject <DataLayerModel>(cookies.Get(cookieName).Value);
                    Session[sessionName] = tagObject;
                }
            }
            else
            {
                if (Session[sessionName] != null)
                {
                    tagObject = Session[sessionName] as DataLayerModel;
                }
            }

            return(tagObject);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            HttpCookieCollection objHttpCookieCollection = Request.Cookies;
            HttpCookie           objHttpCookie2          = objHttpCookieCollection.Get("MatCookie5639sb");

            string strMtaID = Crypto.DeCrypto(objHttpCookie2.Values["MatrimonialID"]);

            HttpCookieCollection objHttpCookieCollection2 = Request.Cookies;
            HttpCookie           objHttpCookie            = objHttpCookieCollection.Get("ebanker");

            sbyte PlanID = sbyte.Parse(Crypto.DeCrypto(objHttpCookie.Values["PLanID"]));

            if (Crypto.DeCrypto(objHttpCookie2.Values["UserType"]).ToLower() != "paidmember")
            {
                MatrimonialProfileManager.InsertPaidMember(strMtaID, PlanID);
            }
            else
            {
                MatrimonialMemberShip.RenewPaidMembership(strMtaID, PlanID);
            }
            Response.Redirect("~/Member/Membership.aspx");
        }
        catch (Exception)
        { }
    }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取配置文件cookies集合中指定索引的值
        /// </summary>
        /// <typeparam name="T">返回值类型参数</typeparam>
        /// <param name="key">索引键</param>
        /// <param name="parseValue">将指定索引键的值转化为返回类型的值的委托方法</param>
        /// <param name="defaultValue">默认值</param>
        /// <returns></returns>
        private static T getValue <T>(string key, Func <string, T, bool> parseValue, T?defaultValue) where T : struct
        {
            string value = cookies.Get(key).Value;

            if (value != null)
            {
                T parsedValue = default(T);

                if (parseValue(value, parsedValue))
                {
                    return(parsedValue);
                }
                else
                {
                    throw new ApplicationException(string.Format("Setting '{0}' was not a valid {1}", key, typeof(T).FullName));
                }
            }

            if (!defaultValue.HasValue)
            {
                throw new ApplicationException("Cookie集合中找不到key为" + key + "的子节点,且没有指定默认值");
            }
            else
            {
                return(defaultValue.Value);
            }
        }
Ejemplo n.º 5
0
        public void ShouldSetCookieForBanner()
        {
            var response = _cookieService.ShowCookieForBanner(_httpContext.Object);

            var cookie = _cookieCollection.Get(_testCookieName);

            _cookieCollection.Get(_testCookieName).Should().NotBeNull();

            response.Should().BeTrue();

            cookie.Expires.Should().BeAfter(DateTime.UtcNow.AddDays(30).AddMinutes(-1), because: "Expire date needs to be 30 days from now");
            cookie.Expires.Should().BeBefore(DateTime.UtcNow.AddDays(30).AddMinutes(1), because: "Expire date needs to be 30 days from now");
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Checks windows authentication or verifies the access token presented.
        /// </summary>
        /// <param name="httpContext"></param>
        /// <returns></returns>
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            HttpCookieCollection cookies        = httpContext.Request.Cookies;
            HttpCookie           authCookie     = cookies.Get("Authorization");
            HttpCookie           userMailCookie = cookies.Get("UserMail");

            if (authCookie != null && userMailCookie != null)
            {
                //validation of cookie from google to be done
                return(true);
            }

            return(false);
        }
Ejemplo n.º 7
0
        internal static HttpCookie RemoveRememberCookie(HttpCookieCollection cookies)
        {
            var cookie = cookies.Get(LOGIN_COOKIE);

            cookie.Expires = DateTime.Today.AddDays(-1);
            return(cookie);
        }
    public void Bind(MemberMessage message)
    {
        // making visibility true
        this.Visible = true;
        // Setting Index
        L_No.Text = message.Index.ToString();
        // Setting Date
        L_Date.Text = message.Date;
        // Setting From/To
        HL_MessageFrom_To.Text = message.From_To;
        // Setting Messages
        L_Message.Text = message.Message;
        // is the mail readed
        if (message.MessageReaded)
        {
            Img_Status.ImageUrl = "~/Resources/mesread.gif";
            Img_Status.ToolTip  = "Readed Message";
        }

        try
        {
            HttpCookieCollection objHttpCookieCollection = Request.Cookies;
            HttpCookie           objHttpCookie           = objHttpCookieCollection.Get("MatCookie5639sb");
            //<<<ForTesting>>>>
            if (Crypto.DeCrypto(objHttpCookie.Values["UserType"]) == "PaidMember")
            {
                HL_Replay.Visible = true;
                HL_Replay.Attributes.Add("onclick", "newWindow('SendMessages.aspx?id=" + message.From_To + "','SendMessage','500','250')");
            }
        }
        catch (Exception)
        { }
    }
Ejemplo n.º 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookieCollection objHttpCookieCollection = Request.Cookies;
        HttpCookie           objHttpCookie           = objHttpCookieCollection.Get("MatCookie5639sb");

        string strMtaID = Crypto.DeCrypto(objHttpCookie.Values["MatrimonialID"]);

        L_MatID.Text = strMtaID;
        MembershipDetails objMembeship = new MembershipDetails(strMtaID);

        L_Name.Text = objMembeship.Name;
        if (objMembeship.ISPaidMember)
        {
            L_membership.Text         = "Paid member";
            boolPaidMember            = true;
            HL_Renew_Upgrade.Text     = "Renew Membership";
            HL_Renew_Upgrade.ImageUrl = "~/Resources/Renewicon.gif";
        }
        else
        {
            L_membership.Text         = "Free member";
            boolPaidMember            = false;
            HL_Renew_Upgrade.Text     = "Upgrade Membership";
            HL_Renew_Upgrade.ImageUrl = "~/Resources/upgradenow.gif";
        }
        L_CreatedOn.Text      = objMembeship.CreatedOn;
        L_CLiks.Text          = objMembeship.Cliks.ToString();
        L_PaidMemberFrom.Text = objMembeship.PaidMemberForm;
        L_PaidMemberUpTo.Text = objMembeship.PaidMemberupto;
        L_Plan.Text           = objMembeship.Plan;
        objMembeship          = null;
    }
Ejemplo n.º 10
0
// saving horoscope password


    protected void IMB_Horoscope_save_Click(object sender, ImageClickEventArgs e)
    {
        if (RB_H_yes.Checked)
        {
            //loading information from Cookie

            HttpCookieCollection objHttpCookieCollection = Request.Cookies;
            HttpCookie           objHttpCookie           = objHttpCookieCollection.Get("MatCookie5639sb");
            if (MatrimonialAlbumManager.SetAlbumPassword(Crypto.DeCrypto(objHttpCookie.Values["ApplicationID"]), TB_Photo_Password.Text, MatrimonialAlbumManager.ImageType.Horoscope))
            {
                // If Sucess
                L_H_Updated.Visible = true;
            }
            else // some error occured
            {
                L_H_Updated.Visible = true;
                L_H_Updated.Text    = "Error in Updation, Sorry Plase try again";
            }
        }
        else if (RB_H_No.Checked) //remove Password
        {
            HttpCookieCollection objHttpCookieCollection = Request.Cookies;
            HttpCookie           objHttpCookie           = objHttpCookieCollection.Get("MatCookie5639sb");
            if (MatrimonialAlbumManager.RemoveAlbumPassword(Crypto.DeCrypto(objHttpCookie.Values["ApplicationID"]), MatrimonialAlbumManager.ImageType.Horoscope))
            {
                // If Sucess
                L_H_Updated.Visible = true;
            }
            else // some error occured
            {
                L_H_Updated.Visible = true;
                L_H_Updated.Text    = "Error in Updation, Sorry Plase try again";
            }
        }
    }
Ejemplo n.º 11
0
    /// <summary>
    /// To A2 is passed ThisApp.Name
    /// </summary>
    /// <param name="Page"></param>
    /// <param name="nameOfCookie"></param>
    /// <returns></returns>
    public static HttpCookie GetExistsOrNew(HttpRequest request, string nameOfCookie)
    {
        HttpCookieCollection collection = null;

        if (request == null)
        {
            collection = HttpContext.Current.Request.Cookies;
        }
        else
        {
            collection = request.Cookies;
        }

        HttpCookie cookie = collection[nameOfCookie];

        if (cookie == null)
        {
            cookie = collection.Get(nameOfCookie);
        }
        if (cookie == null)
        {
            cookie = new HttpCookie(nameOfCookie);
            foreach (string item in collection.AllKeys)
            {
                cookie.Values[item] = collection[item].Value;
            }
        }
        return(cookie);
    }
Ejemplo n.º 12
0
        public static HttpCookie GetCookie(string cookieName)
        {
            HttpCookieCollection cookies  = HttpContext.Current.Request.Cookies;
            HttpCookie           myCookie = cookies.Get(cookieName);

            return(myCookie);
        }
Ejemplo n.º 13
0
        //Return something better than tuple?
        internal static Tuple <HttpCookie, string> GetVerificationTokenContent(HttpCookieCollection cookies = null, string valueId = "VerificationToken", string cookieName = null)
        {
            cookieName = cookieName ?? AntiForgeryConfig.CookieName;//Use the default cookie name, do we want to set it against the root path or keep using our own path? (two cookie)
            var oldCookieToken = default(string);

            if (cookies != null)
            {
                if (cookies.AllKeys.Contains(cookieName))
                {
                    var oldCookie = cookies.Get(cookieName);//why does this create a cookie if it doesn't exist...
                    if (oldCookie != null)
                    {
                        oldCookieToken = oldCookie.Value;
                    }
                }
            }

            var tokens = GetTokens(oldCookieToken);
            var cookie = tokens.Item1 != null && tokens.Item1 != oldCookieToken ? new HttpCookie(cookieName, tokens.Item1)
            {
                HttpOnly = true, Secure = false
            } : default(HttpCookie);                                                                                                                                                 //TODO: Set cookie secure if we are always on secure, need to get that from a setting or something.
            var content = String.Format("<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>&#3232;_&#3232;</title></head><input type=\"hidden\" id=\"{0}\" value=\"{1}\"></html>", valueId, tokens.Item2);

            return(Tuple.Create(cookie, content));
        }
Ejemplo n.º 14
0
        public static List <CartViewModel> GetCartFromCookie(HttpCookieCollection cookies)
        {
            var cookie = cookies.Get(CART);
            var result = cookie == null ? new List <CartViewModel>() : DTDCookieToViewModel(cookie);

            return(result);
        }
Ejemplo n.º 15
0
        public static void SetSubCookie(string strCookieDomainName, string strGroupName, string strKey, string strValue, bool isHttpOnly)
        {
            HttpCookieCollection cookies = HttpContext.Current.Response.Cookies;
            HttpCookie           httpCookie;

            if (cookies[strGroupName] == null)
            {
                httpCookie = new HttpCookie(strGroupName);
                if (!string.IsNullOrEmpty(strCookieDomainName))
                {
                    httpCookie.Domain = strCookieDomainName;
                }
                httpCookie.Path     = "/";
                httpCookie.HttpOnly = isHttpOnly;
                httpCookie.Values.Set(strKey, strValue);
                cookies.Set(httpCookie);
                return;
            }
            httpCookie = cookies.Get(strGroupName);
            if (!string.IsNullOrEmpty(strCookieDomainName))
            {
                httpCookie.Domain = strCookieDomainName;
            }
            httpCookie.Path     = "/";
            httpCookie.HttpOnly = isHttpOnly;
            httpCookie.Values.Set(strKey, strValue);
            cookies.Set(httpCookie);
        }
    public void Delete()
    {
        if (this.CB_Delete.Checked)
        {
            HttpCookieCollection objHttpCookieCollection = Request.Cookies;
            HttpCookie           objHttpCookie           = objHttpCookieCollection.Get("MatCookie5639sb");

            string strMatID = Crypto.DeCrypto(objHttpCookie.Values["MatrimonialID"]);

            switch (HF_Type.Value.ToLower())
            {
            case "photo":
                InternalMessage.DeletePasswordRequest(L_RequestFrom_To.Text, strMatID, true);
                break;

            case "horoscope":
                InternalMessage.DeletePasswordRequest(L_RequestFrom_To.Text, strMatID, false);
                break;

            default:
                InternalMessage.DeletePasswordRequest(L_RequestFrom_To.Text, strMatID, true);
                break;
            }
        }
    }
Ejemplo n.º 17
0
        /*
         * Add service id  to cookies
         */
        public static HttpCookie removeService(string svcId, HttpCookieCollection cookieCollection)
        {
            HttpCookie cookie = cookieCollection.Get("cart_cookie");

            if (cookie == null)
            {
                cookie = new HttpCookie("cart_cookie");
            }

            ArrayList services;
            var       jsonSerialiser = new JavaScriptSerializer();

            if (cookie.Values["cart_services"] != null && cookie.Values["cart_services"].Length > 0)
            {
                string servicesString = cookie.Values["cart_services"];
                services = (ArrayList)jsonSerialiser.Deserialize(servicesString, typeof(ArrayList));
                services.Remove(svcId);
            }
            else
            {
                services = new ArrayList();
            }

            string cookieString = jsonSerialiser.Serialize(services);

            cookie.Values["cart_services"] = cookieString;
            cookie.Expires.AddDays(10);

            return(cookie);
        }
Ejemplo n.º 18
0
        public static Dictionary <string, string> getCartTotal(HttpCookieCollection cookieCollection)
        {
            Dictionary <string, string> cartTotal = new Dictionary <string, string>();
            HttpCookie cookie = cookieCollection.Get("cart_cookie");

            Decimal servicesCost = 0, cost;
            int     servicesCount = 0;

            if (cookie != null)
            {
                var       jsonSerialiser = new JavaScriptSerializer();
                ArrayList servicesIds    = (ArrayList)jsonSerialiser.Deserialize(cookie.Values["cart_services"], typeof(ArrayList));
                foreach (string serviceId in servicesIds)
                {
                    Dictionary <string, string> serviceInfo = DataLayer.getServiceInfo(serviceId);
                    if (serviceInfo.Count == 0)
                    {
                        continue;
                    }
                    Decimal.TryParse(serviceInfo["service_cost"], out cost);
                    servicesCost += cost;
                    servicesCount++;
                }
                cartTotal.Add("svc_num", servicesCount.ToString());
                cartTotal.Add("svc_cost", servicesCost.ToString() + "$");
            }
            else
            {
                cartTotal.Add("svc_num", "0");
                cartTotal.Add("svc_cost", "0$");
            }

            return(cartTotal);
        }
Ejemplo n.º 19
0
        public static AuthToken Generate(HttpCookieCollection cookies)
        {
            const string cookieName = "teamkeep-token";

            var tokenCookie = cookies.Get(cookieName);

            if (tokenCookie == null)
            {
                return(null);
            }

            var token      = tokenCookie.Value;
            var tokenParts = token.Split('_');

            if (tokenParts.Length < 3)
            {
                return(null);
            }

            return(new AuthToken
            {
                UserId = Convert.ToInt32(tokenParts[0]),
                TimeStamp = Convert.ToInt64(tokenParts[1]),
                Key = tokenParts[2]
            });
        }
Ejemplo n.º 20
0
    protected void IMG_AddLink_Click(object sender, ImageClickEventArgs e)
    {
        //Add BookMark Into List
        //Getting User Informations
        HttpCookieCollection objHttpCookieCollection = Request.Cookies;
        HttpCookie           objHttpCookie           = objHttpCookieCollection.Get("MatCookie5639sb");
        string strMatID = Crypto.DeCrypto(objHttpCookie.Values["MatrimonialID"]);

        switch (HF_Type.Value)
        {
        case "1":
            MatrimonialProfileManager.BookMark(strMatID, HF_ID.Value, false);
            IMG_AddLink.Visible = false;
            IMG_Label.Visible   = true;
            break;

        case "2":
            MatrimonialProfileManager.BookMark(strMatID, HF_ID.Value, true);
            IMG_AddLink.Visible = false;
            IMG_Label.Visible   = true;
            break;

        default:
            break;
        }
    }
Ejemplo n.º 21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie MyCookie;

            try
            {
                MyCookie = new HttpCookie("IMLastVisit");
                HttpCookieCollection MyCookieColl = Request.Cookies;
                MyCookie = MyCookieColl.Get("IMLastVisit");

                g_user_id    = MyCookie.Values["USER_ID"];
                g_lang       = int.Parse(MyCookie.Values["LANG"]);
                g_company_cd = MyCookie.Values["COMPANY_CD"];
                g_name       = HttpUtility.UrlDecode(MyCookie.Values["NAME"]);
            }
            catch
            {
                //Response.Redirect("~/NotLoginErr.htm");
                Response.Redirect("~/Login.aspx");
            }
            //g_user_id = "test";
            //g_lang = 2;
            //g_name = "TEST USER";
            if (!IsPostBack)
            {
                //// 画面編集
                Init_Label();
                Init_Proc();
            }
            lblMsg.Text = "";
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Converts The Cookies In The Given Cookie Collection in to HttpCookies
 /// </summary>
 /// <param name="cookies">The Cookie Collection To Be Converted</param>
 public static void ConvertCookiesToHttpOnly(HttpCookieCollection cookies)
 {
     for (int i = 0; i < cookies.Count; i++)
     {
         ConvertCookieToHttpOnly(cookies.Get(i));
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if ((Request.QueryString["id"] != null) || (Request.QueryString["typ"] != null))
            {
                HF_ToID.Value = Request.QueryString["id"];

                switch (Request.QueryString["typ"])
                {
                case "1":
                    RB_T1.Enabled = false;
                    break;

                case "2":
                    RB_T2.Enabled = false;
                    break;

                case "3":
                    RB_T3.Enabled = false;
                    break;

                default:
                    RB_T1.Enabled   = false;
                    RB_T2.Enabled   = false;
                    RB_T3.Enabled   = false;
                    IB_Send.Enabled = false;
                    L_Warning.Text  = "Pls Refresh the page and try again";
                    break;
                }
            }
            else
            {
                //Error 405
                Server.Transfer("~/Extras/ErrorReport.aspx?id=405");
            }
        }
        else // Update Databse
        {
            HttpCookieCollection objHttpCookieCollection = Request.Cookies;
            HttpCookie           objHttpCookie           = objHttpCookieCollection.Get("MatCookie5639sb");

            string strMtaID = Crypto.DeCrypto(objHttpCookie.Values["MatrimonialID"]);

            if (RB_T1.Checked)
            {
                InternalMessage.IntrestApprovel(strMtaID, HF_ToID.Value, InternalMessage.IntrestStatus.Pending);
            }
            else if (RB_T2.Checked)
            {
                InternalMessage.IntrestApprovel(strMtaID, HF_ToID.Value, InternalMessage.IntrestStatus.Accepted);
            }
            else if (RB_T3.Checked)
            {
                InternalMessage.IntrestApprovel(strMtaID, HF_ToID.Value, InternalMessage.IntrestStatus.Declined);
            }

            Server.Transfer("~/Extras/sucess.aspx");
        }
    }
    //Browsing the last
    protected void LB_Previous_Click(object sender, EventArgs e)
    {
        HttpCookieCollection objHttpCookieCollection = Request.Cookies;
        HttpCookie           objHttpCookie           = objHttpCookieCollection.Get("MatCookie5639sb");
        string strMatrimonialID = Crypto.DeCrypto(objHttpCookie.Values["MatrimonialID"]);

        LB_Next_1.Enabled = true;
        LB_Next_2.Enabled = true;

        //Getting values
        int intStart = int.Parse(HF_Start.Value);
        int intCount = int.Parse(HF_Count.Value);

        intStart -= 10;
        // End of record?
        if (intStart < 10)
        {
            LB_Previous_1.Enabled = false;
            LB_Previous_2.Enabled = false;
        }
        //Update Start Pointer
        HF_Start.Value = (intStart).ToString();
        //Getting SSList

        LoadList(MatrimonialProfileManager.GetBookMarkList(intStart, strMatrimonialID));
    }
Ejemplo n.º 25
0
        /// <summary>读取 Cookie</summary>
        /// <param name="name">要读取的 Cookie 名称</param>
        /// <param name="key">要读取的 Cookie 键</param>
        /// <returns>Cookie 值</returns>
        public static string GetCookie(string name, string key)
        {
            if (name.IsNullOrEmpty_() || key.IsNullOrEmpty_())
            {
                return(string.Empty);
            }
            HttpCookieCollection _cookies = HttpContext.Current.Request.Cookies;

            if (_cookies == null)
            {
                return(string.Empty);
            }
            HttpCookie _cookie = _cookies.Get(name);

            if (_cookie == null)
            {
                return(string.Empty);
            }
            string _value = _cookie.Values.Get(key);

            if (_value.IsNullOrEmpty_())
            {
                return(string.Empty);
            }
            return(_value);
        }
        public void CandidateSubsequentVisit()
        {
            var candidateId      = Guid.NewGuid();
            var candidateService = new Mock <ICandidateService>();
            var provider         = new HelpCookieProviderBuilder().With(candidateService).Build();
            var httpRequest      = new Mock <HttpRequestBase>();
            var requestCookies   = new HttpCookieCollection();
            var existingCookie   = new HttpCookie(HelpCookieProvider.CookieName);

            existingCookie[HelpCookieProvider.CookieKeys.ShowSearchTour.ToString()] = candidateId.ToString();
            requestCookies.Add(existingCookie);
            httpRequest.Setup(m => m.Cookies).Returns(requestCookies);
            var httpResponse    = new Mock <HttpResponseBase>();
            var responseCookies = new HttpCookieCollection();

            httpResponse.Setup(m => m.Cookies).Returns(responseCookies);
            var httpContext = new HttpContextBuilder().With(httpRequest).With(httpResponse).Build();

            var showSearchTour = provider.ShowSearchTour(httpContext, candidateId);

            showSearchTour.Should().BeFalse();
            var cookie = responseCookies.Get(HelpCookieProvider.CookieName);

            cookie.Should().BeNull();
            candidateService.Verify(cs => cs.GetCandidate(It.IsAny <Guid>()), Times.Never);
        }
    protected void IMG_Grand_Click(object sender, ImageClickEventArgs e)
    {
        HttpCookieCollection objHttpCookieCollection = Request.Cookies;
        HttpCookie           objHttpCookie           = objHttpCookieCollection.Get("MatCookie5639sb");

        string strMatID = Crypto.DeCrypto(objHttpCookie.Values["MatrimonialID"]);


        switch (HF_Type.Value.ToLower())
        {
        case "photo":
            InternalMessage.GrandPhotoRequest(HF_ID.Value, strMatID, true);
            IMG_Grand.Visible   = false;
            IMG_Granted.Visible = true;
            break;

        case "horoscope":
            InternalMessage.GrandPhotoRequest(HF_ID.Value, strMatID, false);
            IMG_Grand.Visible   = false;
            IMG_Granted.Visible = true;
            break;

        default:
            IMG_Grand.Visible   = false;
            IMG_Granted.Visible = true;
            break;
        }
    }
        public void CandidateFirstVisit(bool showSearchTourPreference)
        {
            var candidateId      = Guid.NewGuid();
            var candidateService = new Mock <ICandidateService>();
            var helpPreferences  = new HelpPreferences
            {
                ShowSearchTour = showSearchTourPreference
            };

            candidateService.Setup(cs => cs.GetCandidate(candidateId)).Returns(new CandidateBuilder(candidateId).With(helpPreferences).Build);
            var provider        = new HelpCookieProviderBuilder().With(candidateService).Build();
            var httpResponse    = new Mock <HttpResponseBase>();
            var responseCookies = new HttpCookieCollection();

            httpResponse.Setup(m => m.Cookies).Returns(responseCookies);
            var httpContext = new HttpContextBuilder().With(httpResponse).Build();

            var showSearchTour = provider.ShowSearchTour(httpContext, candidateId);

            showSearchTour.Should().Be(showSearchTourPreference);
            var cookie = responseCookies.Get(HelpCookieProvider.CookieName);

            cookie.Should().NotBeNull();
            var cookieValue = cookie[HelpCookieProvider.CookieKeys.ShowSearchTour.ToString()];

            cookieValue.Should().Be(candidateId.ToString());
            candidateService.Verify(cs => cs.GetCandidate(It.IsAny <Guid>()), Times.Once);
        }
        public void Deny_Unrestricted()
        {
            HttpCookieCollection jar = new HttpCookieCollection();

            jar.Add(biscuit);
            jar.CopyTo(new object[1], 0);
            Assert.IsNull(jar.GetKey(0), "GetKey");
            jar.Remove("chocolat");
            jar.Set(biscuit);
            Assert.IsNotNull(jar.Get(0), "Get(int)");
            Assert.IsNull(jar.Get("chocolat"), "Get(string)");
            Assert.IsNotNull(jar[0], "this[int]");
            Assert.IsNull(jar["chocolat"], "this[string]");
            Assert.AreEqual(1, jar.AllKeys.Length, "AllKeys");
            jar.Clear();
        }
Ejemplo n.º 30
0
        public ActionResult Index()
        {
            carpetaRepository.CrearGeneral();
            HttpCookieCollection MyCookieCollection = Request.Cookies;
            HttpCookie           MyCookie           = MyCookieCollection.Get("UsuarioCookies");

            if (MyCookie != null)
            {
                UsuarioLogin usuario = new UsuarioLogin();

                usuario.Email            = Cipher.DecryptString(MyCookie["Email"]);
                usuario.ContraseniaLogin = Cipher.DecryptString(MyCookie["Contrasenia"]);

                Usuario usuarioEncontrado = usuarioRepository.BuscarUsuarioLogueado(usuario);

                if (usuarioEncontrado.EstadoLogin == 1)
                {
                    Session["ID"]          = MyCookie["ID"];
                    Session["Email"]       = MyCookie["Email"];
                    Session["Contrasenia"] = MyCookie["Contrasenia"];

                    return(RedirectToAction("Home"));
                }
            }

            return(View());
        }
Ejemplo n.º 31
0
 private static void UpdateCookie(string cookie_name, string cookie_value, HttpCookieCollection cookies)
 {
     HttpCookie cookie = cookies.Get(cookie_name);
     if (null == cookie)
     {
         cookie = new HttpCookie(cookie_name);
     }
     cookie.Value = cookie_value;
     cookies.Set(cookie);
 }
Ejemplo n.º 32
0
        private static void ValidateCookieCollection(HttpCookieCollection cc)
        {
            int c = cc.Count;

            for (int i = 0; i < c; i++)
            {
                String key = cc.GetKey(i);
                String val = cc.Get(i).Value;

                if (!String.IsNullOrEmpty(val))
                    ValidateString(val, key, "Request.Cookies");
            }
        }