示例#1
0
        public void DecodingQuotedCookie()
        {
            var sources = new List <string>
            {
                "a=\"\",",
                "b=\"1\","
            };

            var cookies = new List <ICookie>();

            foreach (string source in sources)
            {
                cookies.Add(ClientCookieDecoder.StrictDecoder.Decode(source));
            }
            Assert.Equal(2, cookies.Count);

            ICookie c = cookies[0];

            Assert.Equal("a", c.Name);
            Assert.Equal("", c.Value);

            c = cookies[1];
            Assert.Equal("b", c.Name);
            Assert.Equal("1", c.Value);
        }
示例#2
0
        public B2CAuthenticationProvider(ICookie cookies)
        {
            _cookies   = cookies;
            _authority = $"{_authorityBase}{PolicySignIn}";

            Initialize();
        }
示例#3
0
        public string Encode(params ICookie[] cookies)
        {
            if (cookies is null || 0u >= (uint)cookies.Length)
            {
                return(null);
            }

            StringBuilder buf = StringBuilder();

            if (this.Strict)
            {
                if (cookies.Length == 1)
                {
                    this.Encode(buf, cookies[0]);
                }
                else
                {
                    var cookiesSorted = new ICookie[cookies.Length];
                    Array.Copy(cookies, cookiesSorted, cookies.Length);
                    Array.Sort(cookiesSorted, Comparer);
                    foreach (ICookie c in cookiesSorted)
                    {
                        this.Encode(buf, c);
                    }
                }
            }
            else
            {
                foreach (ICookie c in cookies)
                {
                    this.Encode(buf, c);
                }
            }
            return(StripTrailingSeparatorOrNull(buf));
        }
示例#4
0
 private static void ValidateCookie(ICookie cookie, string name, string value, bool httpOnly, bool secure)
 {
     cookie.Name.ShouldEqual(name);
     cookie.Value.ShouldEqual(value);
     cookie.HttpOnly.ShouldEqual(httpOnly);
     cookie.Secure.ShouldEqual(secure);
 }
示例#5
0
        public void Cookie_ContainsTest()
        {
            ICookie cookie = setupICookie();

            Assert.True(cookie.Contains("cookiemanager_1"));
            Assert.True(cookie.Contains("cookiemanager_5"));
        }
示例#6
0
        public void Cookie_GetPlainChunksTest()
        {
            ICookie cookie       = setupICookie();
            string  actualString = cookie.Get("cm_key1");

            Assert.AreEqual(expectedTestString, actualString);
        }
 public RequestsController(ITelemetryRetrievalService telemetryRetrievalService, IAuthenticationService authenticationService, ICookie cookie, ICookieManager cookieManager)
 {
     this.telemetryRetrievalService = telemetryRetrievalService;
     this.authenticationService     = authenticationService;
     this.cookie        = cookie;
     this.cookieManager = cookieManager;
 }
示例#8
0
        public void Remove(string name)
        {
            ICookie cookie = cookiesDict[name];

            cookiesDict.Remove(name);
            cookiesList.Remove(cookie);
        }
示例#9
0
 public Bakery(int totalCookies = 12)
 {
     IsOpen        = true;
     _totalCookies = totalCookies;
     Cookies       = new ICookie[totalCookies];
     NextCookieId  = 1;
 }
示例#10
0
 public MessageHandleController(IApplicationContextAccessor applicationContextAccessor, IMessageService messageService, ICommentsService commentsService, ICookie cookie)
 {
     _applicationContextAccessor = applicationContextAccessor;
     _messageService             = messageService;
     _commentService             = commentsService;
     _cookie = cookie;
 }
示例#11
0
 public DiscordController(IAuthenticationService authenticationService, IDiscordService discordService, ICookieManager cookieManager, ICookie cookie)
 {
     this.authService    = authenticationService;
     this.discordService = discordService;
     _cookie             = cookie;
     _cookieManager      = cookieManager;
 }
示例#12
0
        public IList <string> Encode(params ICookie[] cookies)
        {
            if (cookies == null || cookies.Length == 0)
            {
                return(EmptyStrings);
            }

            var encoded = new List <string>(cookies.Length);
            Dictionary <string, int> nameToIndex = this.Strict && cookies.Length > 1 ? new Dictionary <string, int>() : null;
            bool hasDupdName = false;

            for (int i = 0; i < cookies.Length; i++)
            {
                ICookie c = cookies[i];
                encoded.Add(this.Encode(c));
                if (nameToIndex != null)
                {
                    if (nameToIndex.ContainsKey(c.Name))
                    {
                        nameToIndex[c.Name] = i;
                        hasDupdName         = true;
                    }
                    else
                    {
                        nameToIndex.Add(c.Name, i);
                    }
                }
            }
            return(hasDupdName ? Dedup(encoded, nameToIndex) : encoded);
        }
示例#13
0
        public IList <string> Encode(params ICookie[] cookies)
        {
            if (cookies is null || 0u >= (uint)cookies.Length)
            {
                return(ImmutableList <string> .Empty);
            }

            var encoded = new List <string>(cookies.Length);
            Dictionary <string, int> nameToIndex = this.Strict && (uint)cookies.Length > 1u ? new Dictionary <string, int>(StringComparer.Ordinal) : null;
            bool hasDupdName = false;

            for (int i = 0; i < cookies.Length; i++)
            {
                ICookie c = cookies[i];
                encoded.Add(this.Encode(c));
                if (nameToIndex is object)
                {
                    if (nameToIndex.ContainsKey(c.Name))
                    {
                        nameToIndex[c.Name] = i;
                        hasDupdName         = true;
                    }
                    else
                    {
                        nameToIndex.Add(c.Name, i);
                    }
                }
            }
            return(hasDupdName ? Dedup(encoded, nameToIndex) : encoded);
        }
示例#14
0
        public void DecodingValuesWithCommasAndEqualsFails()
        {
            const string Source = "A=v=1&lg=en-US,it-IT,it&intl=it&np=1;T=z=E";
            ICookie      cookie = ClientCookieDecoder.StrictDecoder.Decode(Source);

            Assert.Null(cookie);
        }
示例#15
0
 public AccountController(IGameService gameService, IAuthenticationService authenticationService, ICookie cookie, ICookieManager cookieManager)
 {
     _gameService           = gameService;
     _authenticationService = authenticationService;
     _cookie        = cookie;
     _cookieManager = cookieManager;
 }
示例#16
0
 public ItemsController(IGameService gameService, IAuthenticationService authenticationService, IObjectService objectService, ICookie cookie, ICookieManager cookieManager)
 {
     _gameService           = gameService;
     _authenticationService = authenticationService;
     _cookie        = cookie;
     _cookieManager = cookieManager;
     _objectService = objectService;
 }
示例#17
0
 public HomeController(IAuthenticationService authenticationService, IDiscordService discordService, ICookie cookie, ICookieManager cookieManager, IConfiguration configuration)
 {
     this.authService    = authenticationService;
     this.discordService = discordService;
     _cookie             = cookie;
     _cookieManager      = cookieManager;
     _configuration      = configuration;
 }
示例#18
0
        public void IgnoreEmptyPath()
        {
            const string EmptyPath = "sessionid=OTY4ZDllNTgtYjU3OC00MWRjLTkzMWMtNGUwNzk4MTY0MTUw;Domain=;Path=";
            ICookie      cookie    = ClientCookieDecoder.StrictDecoder.Decode(EmptyPath);

            Assert.NotNull(cookie);
            Assert.Null(cookie.Path);
        }
示例#19
0
        public FluentSessionRecorder SetCookie(ICookie cookie)
        {
            var command = new SetCookieCommand(cookie);

            _performer.Perform(command);

            return(this);
        }
示例#20
0
        public void DecodingValueWithCommaFails()
        {
            const string Source = "UserCookie=timeZoneName=(GMT+04:00) Moscow, St. Petersburg, Volgograd&promocode=&region=BE;"
                                  + " expires=Sat, 01-Dec-2012 10:53:31 GMT; path=/";
            ICookie cookie = ClientCookieDecoder.StrictDecoder.Decode(Source);

            Assert.Null(cookie);
        }
 public AccountController(IAuthenticationService authenticationService, ICookie cookie, ICookieManager cookieManager, IDiscordService discordService, IActivityReportService activityReportService)
 {
     _authenticationService = authenticationService;
     _cookie                = cookie;
     _cookieManager         = cookieManager;
     _discordService        = discordService;
     _activityReportService = activityReportService;
 }
示例#22
0
 public WidgetController(IWidgetService widgetService, IWidgetTemplateService widgetTemplateService,
                         ICookie cookie, IPackageInstallerProvider packageInstallerProvider)
 {
     _widgetService         = widgetService;
     _widgetTemplateService = widgetTemplateService;
     _cookie = cookie;
     _packageInstallerProvider = packageInstallerProvider;
 }
 public FailuresController(ITelemetryRetrievalService telemetryRetrievalService, ICustomTelemetryService customTelemetryService, IAuthenticationService authenticationService, ICookie cookie, ICookieManager cookieManager)
 {
     this.customTelemetryService = customTelemetryService;
     this.telemetryRetrievalService = telemetryRetrievalService;
     this.authenticationService = authenticationService;
     this.cookie = cookie;
     this.cookieManager = cookieManager;
 }
示例#24
0
 public AccountController(IUserService userService,
                          ICookie cookie,
                          IUserRepository userRepo)
 {
     _userService = userService;
     _cookie      = cookie;
     _userRepo    = userRepo;
 }
示例#25
0
        public void Cookie_GetEncryptedChunksTest()
        {
            //TODO getting null value of data protector
            ICookie cookie       = setupICookie();
            string  actualString = cookie.Get("encrypted_key1");

            Assert.AreEqual(expectedTestString, actualString);
        }
示例#26
0
        public string Encode(ICookie cookie)
        {
            Contract.Requires(cookie != null);

            StringBuilder buf = StringBuilder();

            this.Encode(buf, cookie);
            return(StripTrailingSeparator(buf));
        }
示例#27
0
 public WidgetController(IWidgetBasePartService widgetService, IWidgetTemplateService widgetTemplateService,
                         ICookie cookie, IPackageInstallerProvider packageInstallerProvider, IWidgetActivator widgetActivator)
 {
     _widgetService         = widgetService;
     _widgetTemplateService = widgetTemplateService;
     _cookie = cookie;
     _packageInstallerProvider = packageInstallerProvider;
     _widgetActivator          = widgetActivator;
 }
示例#28
0
        public void Cookie_GetTest()
        {
            ICookie cookie         = setupICookie();
            var     expectedValue1 = cookieRequestHeaderList["cookiemanager_1"];
            var     expectedValue5 = cookieRequestHeaderList["cookiemanager_5"];

            Assert.AreEqual(expectedValue1, cookie.Get("cookiemanager_1"));
            Assert.AreEqual(expectedValue5, cookie.Get("cookiemanager_5"));
        }
示例#29
0
        public void DecodingLongValue()
        {
            const string LongValue =
                "b___$Q__$ha__<NC=MN(F__%#4__<NC=MN(F__2_d____#=IvZB__2_F____'=KqtH__2-9____" +
                "'=IvZM__3f:____$=HbQW__3g'____%=J^wI__3g-____%=J^wI__3g1____$=HbQW__3g2____" +
                "$=HbQW__3g5____%=J^wI__3g9____$=HbQW__3gT____$=HbQW__3gX____#=J^wI__3gY____" +
                "#=J^wI__3gh____$=HbQW__3gj____$=HbQW__3gr____$=HbQW__3gx____#=J^wI__3h_____" +
                "$=HbQW__3h$____#=J^wI__3h'____$=HbQW__3h_____$=HbQW__3h0____%=J^wI__3h1____" +
                "#=J^wI__3h2____$=HbQW__3h4____$=HbQW__3h7____$=HbQW__3h8____%=J^wI__3h:____" +
                "#=J^wI__3h@____%=J^wI__3hB____$=HbQW__3hC____$=HbQW__3hL____$=HbQW__3hQ____" +
                "$=HbQW__3hS____%=J^wI__3hU____$=HbQW__3h[____$=HbQW__3h^____$=HbQW__3hd____" +
                "%=J^wI__3he____%=J^wI__3hf____%=J^wI__3hg____$=HbQW__3hh____%=J^wI__3hi____" +
                "%=J^wI__3hv____$=HbQW__3i/____#=J^wI__3i2____#=J^wI__3i3____%=J^wI__3i4____" +
                "$=HbQW__3i7____$=HbQW__3i8____$=HbQW__3i9____%=J^wI__3i=____#=J^wI__3i>____" +
                "%=J^wI__3iD____$=HbQW__3iF____#=J^wI__3iH____%=J^wI__3iM____%=J^wI__3iS____" +
                "#=J^wI__3iU____%=J^wI__3iZ____#=J^wI__3i]____%=J^wI__3ig____%=J^wI__3ij____" +
                "%=J^wI__3ik____#=J^wI__3il____$=HbQW__3in____%=J^wI__3ip____$=HbQW__3iq____" +
                "$=HbQW__3it____%=J^wI__3ix____#=J^wI__3j_____$=HbQW__3j%____$=HbQW__3j'____" +
                "%=J^wI__3j(____%=J^wI__9mJ____'=KqtH__=SE__<NC=MN(F__?VS__<NC=MN(F__Zw`____" +
                "%=KqtH__j+C__<NC=MN(F__j+M__<NC=MN(F__j+a__<NC=MN(F__j_.__<NC=MN(F__n>M____" +
                "'=KqtH__s1X____$=MMyc__s1_____#=MN#O__ypn____'=KqtH__ypr____'=KqtH_#%h_____" +
                "%=KqtH_#%o_____'=KqtH_#)H6__<NC=MN(F_#*%'____%=KqtH_#+k(____'=KqtH_#-E_____" +
                "'=KqtH_#1)w____'=KqtH_#1)y____'=KqtH_#1*M____#=KqtH_#1*p____'=KqtH_#14Q__<N" +
                "C=MN(F_#14S__<NC=MN(F_#16I__<NC=MN(F_#16N__<NC=MN(F_#16X__<NC=MN(F_#16k__<N" +
                "C=MN(F_#17@__<NC=MN(F_#17A__<NC=MN(F_#1Cq____'=KqtH_#7)_____#=KqtH_#7)b____" +
                "#=KqtH_#7Ww____'=KqtH_#?cQ____'=KqtH_#His____'=KqtH_#Jrh____'=KqtH_#O@M__<N" +
                "C=MN(F_#O@O__<NC=MN(F_#OC6__<NC=MN(F_#Os.____#=KqtH_#YOW____#=H/Li_#Zat____" +
                "'=KqtH_#ZbI____%=KqtH_#Zbc____'=KqtH_#Zbs____%=KqtH_#Zby____'=KqtH_#Zce____" +
                "'=KqtH_#Zdc____%=KqtH_#Zea____'=KqtH_#ZhI____#=KqtH_#ZiD____'=KqtH_#Zis____" +
                "'=KqtH_#Zj0____#=KqtH_#Zj1____'=KqtH_#Zj[____'=KqtH_#Zj]____'=KqtH_#Zj^____" +
                "'=KqtH_#Zjb____'=KqtH_#Zk_____'=KqtH_#Zk6____#=KqtH_#Zk9____%=KqtH_#Zk<____" +
                "'=KqtH_#Zl>____'=KqtH_#]9R____$=H/Lt_#]I6____#=KqtH_#]Z#____%=KqtH_#^*N____" +
                "#=KqtH_#^:m____#=KqtH_#_*_____%=J^wI_#`-7____#=KqtH_#`T>____'=KqtH_#`T?____" +
                "'=KqtH_#`TA____'=KqtH_#`TB____'=KqtH_#`TG____'=KqtH_#`TP____#=KqtH_#`U_____" +
                "'=KqtH_#`U/____'=KqtH_#`U0____#=KqtH_#`U9____'=KqtH_#aEQ____%=KqtH_#b<)____" +
                "'=KqtH_#c9-____%=KqtH_#dxC____%=KqtH_#dxE____%=KqtH_#ev$____'=KqtH_#fBi____" +
                "#=KqtH_#fBj____'=KqtH_#fG)____'=KqtH_#fG+____'=KqtH_#g<d____'=KqtH_#g<e____" +
                "'=KqtH_#g=J____'=KqtH_#gat____#=KqtH_#s`D____#=J_#p_#sg?____#=J_#p_#t<a____" +
                "#=KqtH_#t<c____#=KqtH_#trY____$=JiYj_#vA$____'=KqtH_#xs_____'=KqtH_$$rO____" +
                "#=KqtH_$$rP____#=KqtH_$(_%____'=KqtH_$)]o____%=KqtH_$_@)____'=KqtH_$_k]____" +
                "'=KqtH_$1]+____%=KqtH_$3IO____%=KqtH_$3J#____'=KqtH_$3J.____'=KqtH_$3J:____" +
                "#=KqtH_$3JH____#=KqtH_$3JI____#=KqtH_$3JK____%=KqtH_$3JL____'=KqtH_$3JS____" +
                "'=KqtH_$8+M____#=KqtH_$99d____%=KqtH_$:Lw____#=LK+x_$:N@____#=KqtG_$:NC____" +
                "#=KqtG_$:hW____'=KqtH_$:i[____'=KqtH_$:ih____'=KqtH_$:it____'=KqtH_$:kO____" +
                "'=KqtH_$>*B____'=KqtH_$>hD____+=J^x0_$?lW____'=KqtH_$?ll____'=KqtH_$?lm____" +
                "%=KqtH_$?mi____'=KqtH_$?mx____'=KqtH_$D7]____#=J_#p_$D@T____#=J_#p_$V<g____" +
                "'=KqtH";
            ISet <ICookie> cookies = ServerCookieDecoder.StrictDecoder.Decode("bh=\"" + LongValue + "\";");

            Assert.NotNull(cookies);
            Assert.Equal(1, cookies.Count);

            ICookie c = cookies.First();

            Assert.Equal("bh", c.Name);
            Assert.Equal(LongValue, c.Value);
        }
示例#30
0
        public void DecodingWeirdNames2()
        {
            const string Source = "HTTPOnly=";
            ICookie      cookie = ClientCookieDecoder.StrictDecoder.Decode(Source);

            Assert.NotNull(cookie);

            Assert.Equal("HTTPOnly", cookie.Name);
            Assert.Equal("", cookie.Value);
        }
示例#31
0
 public void BakeCookie(ICookie cookie)
 {
     if (cookie.IsBurnt(OvenTemperature))
     {
         cookie.SetCanEat(false);
     }
     else
     {
         cookie.SetCanEat(true);
     }
 }
 public ChocolateDecorator(ICookie IC)
     : base(IC)
 {
 }
 public DecoratorChocolate(ICookie IC)
     : base(IC)
 {
 }
示例#34
0
 public void AppendCookie(ICookie cookie)
 {
     cookies.Add(cookie);
 }
 public VanillaDecorator(ICookie original)
     : base(original)
 {
 }
示例#36
0
 private static void ValidateCookie(ICookie cookie, string name, string value, DateTime? expires, string domain, string path)
 {
     cookie.Name.ShouldEqual(name);
     cookie.Value.ShouldEqual(value);
     cookie.Expires.ShouldEqual(expires);
     cookie.Domain.ShouldEqual(domain);
     cookie.Path.ShouldEqual(path);
 }
 public ChocolateDecorator(ICookie original)
     : base(original)
 {
 }
 public void LogCookiePurchase(Customer customer, ICookie cookie, int currentCookie)
 {
     Log("{0,80}", string.Format("{0} received {1}", customer.Name, string.Format(cookie.GetCookieDescription(), currentCookie)));
 }
示例#39
0
 public void SetCookie(ICookie cookie)
 {
 }
示例#40
0
文件: Response.cs 项目: UStack/UWeb
 public IResponse AddCookie(ICookie cookie)
 {
     cookies.Add(cookie);
     return this;
 }
示例#41
0
 public RaisinDecorator(ICookie original)
     : base(original)
 {
 }
示例#42
0
 protected CookieDecorator(ICookie original)
 {
     this.original = original;
 }