示例#1
0
        public static string Generate(string userId, HullConfiguration configuration)
        {
            var signature = Utilities.BuildSignedUserId(userId, configuration.AppSecret);
            var raw       = new RawCookieData
            {
                AuthScope = "User:" + userId,
                UserId    = userId,
                UserSig   = signature
            };

            var rawJson     = JsonConvert.SerializeObject(raw);
            var jsonBytes   = Encoding.UTF8.GetBytes(rawJson);
            var encodedData = Convert.ToBase64String(jsonBytes);

            return(encodedData);
        }
示例#2
0
        public HullCookie(string rawCookie, HullConfiguration configuration)
        {
            // Invalid by default
            this.IsValid = false;

            if (!string.IsNullOrEmpty(rawCookie))
            {
                var decodedData = Convert.FromBase64String(rawCookie);
                var userJson    = Encoding.UTF8.GetString(decodedData);

                var userData = JsonConvert.DeserializeObject <RawCookieData>(userJson);

                if (userData != null && !string.IsNullOrEmpty(userData.UserId))
                {
                    this.UserId = userData.UserId;

                    this.IsValid = Utilities.CheckSignedUserId(
                        userData.UserId,
                        userData.UserSig,
                        configuration.AppSecret);
                }
            }
        }
示例#3
0
 public HullClient(HullConfiguration config)
 {
     this.config     = config;
     this.httpClient = new RestClient(this.config.OrgUrl);
 }