Example #1
0
            public string ToQueryStringFragment(NameValueCollection additionalParameters, bool includeHMAC = true)
            {
                NameValueCollection nameValueCollection = new NameValueCollection();

                if (this.KeyVersion > 1)
                {
                    nameValueCollection.Add("pt", ((int)this.PayloadType).ToString(NumberFormatInfo.InvariantInfo));
                }
                else
                {
                    CryptoKeyPayloadType payloadType = this.PayloadType;
                    if (payloadType != CryptoKeyPayloadType.SvmFeedbackEncryption)
                    {
                        throw new InvalidOperationException(string.Format("Key of type {0} is not supported by legacy payloads, Key version must be greater than 1", Enum.GetName(typeof(CryptoKeyPayloadType), this.PayloadType)));
                    }
                    AuthkeyAuthenticationRequest.SignedUrl.LegacyPayloadType legacyPayloadType = AuthkeyAuthenticationRequest.SignedUrl.LegacyPayloadType.SvmFeedback;
                    NameValueCollection nameValueCollection2 = nameValueCollection;
                    string name = "pt";
                    int    num  = (int)legacyPayloadType;
                    nameValueCollection2.Add(name, num.ToString(NumberFormatInfo.InvariantInfo));
                }
                nameValueCollection.Add("kv", this.KeyVersion.ToString(NumberFormatInfo.InvariantInfo));
                nameValueCollection.Add("ts", this.UtcTimestamp.ToFileTimeUtc().ToString(NumberFormatInfo.InvariantInfo));
                nameValueCollection.Add("iv", AuthkeyAuthenticationRequest.UrlEncodeBase64String(Convert.ToBase64String(this.InitializationVector)));
                nameValueCollection.Add("authKey", AuthkeyAuthenticationRequest.UrlEncodeBase64String(Convert.ToBase64String(this.Payload)));
                if (includeHMAC && this.MessageAuthenticationCode != null)
                {
                    nameValueCollection.Add("hmac", AuthkeyAuthenticationRequest.UrlEncodeBase64String(Convert.ToBase64String(this.MessageAuthenticationCode)));
                }
                if (additionalParameters != null)
                {
                    nameValueCollection.Add(additionalParameters);
                }
                return(AuthkeyAuthenticationRequest.ConstructQueryString(nameValueCollection));
            }
Example #2
0
        public string ToQueryStringFragment()
        {
            NameValueCollection nameValueCollection = new NameValueCollection();

            if (this.Puid != 0UL)
            {
                nameValueCollection.Add("pd", this.Puid.ToString());
            }
            if (!string.IsNullOrEmpty(this.PrimaryEmail))
            {
                nameValueCollection.Add("aid", this.PrimaryEmail);
            }
            nameValueCollection.Add("cid", AuthkeyAuthenticationRequest.UrlEncodeBase64String(Convert.ToBase64String(this.CustomerGuid.ToByteArray())));
            nameValueCollection.Add("mc", this.MessageClass);
            nameValueCollection.Add("mg", AuthkeyAuthenticationRequest.UrlEncodeBase64String(Convert.ToBase64String(this.MailGuid.ToByteArray())));
            nameValueCollection.Add("opt", this.OptIn ? "1" : "0");
            return(AuthkeyAuthenticationRequest.ConstructQueryString(nameValueCollection));
        }