Exemplo n.º 1
0
        public async Task <bool> Validate()
        {
            if (_setupUrl != null)
            {
                return(false);
            }
            if (Mode != "id_res")
            {
                return(false);
            }
            // isset($this->data['openid_claimed_id']) ?$this->data['openid_claimed_id']:$this->data['openid_identity'];
            ClaimedID = _queryParams.GetValues("openid.claimed_id")?.Single() ?? _queryParams.GetValues("openid.identity")?.Single();

            //Build the request to validate with the openid server
            var args = new Dictionary <string, string>();

            args.Add("openid.assoc_handle", _queryParams.GetValues("openid.assoc_handle")?.Single());
            args.Add("openid.signed", _queryParams.GetValues("openid.signed")?.Single());
            args.Add("openid.sig", _queryParams.GetValues("openid.sig")?.Single());

            if (_queryParams.GetValues("openid.ns") != null)
            {
                //OpenID 2.0 server, find endpoint using discovery
                args.Add("openid.ns", "http://specs.openid.net/auth/2.0");
            }

            if (!ReturnUrl.Equals(_queryParams.GetValues("openid.return_to").Single()))
            {
                return(false);
            }

            string server = await Discover(ClaimedID);

            var items = _queryParams.GetValues("openid.signed")[0];

            var claims = items.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string claim in claims)
            {
                string key   = $"openid.{claim}";
                string value = _queryParams.GetValues(key).Single();
                if (!args.ContainsKey(key))
                {
                    args.Add(key, value);
                }
            }

            args.Add("openid.mode", "check_authentication");

            var        content = new FormUrlEncodedContent(args);
            HttpClient client  = new HttpClient();

            var response = await client.PostAsync(server, content);

            var text = await response.Content.ReadAsStringAsync();

            return(text.Contains("is_valid:true"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns true if HostedCheckoutSpecificInput instances are equal
        /// </summary>
        /// <param name="other">Instance of HostedCheckoutSpecificInput to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(HostedCheckoutSpecificInput other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     IsRecurring == other.IsRecurring ||
                     IsRecurring != null &&
                     IsRecurring.Equals(other.IsRecurring)
                     ) &&
                 (
                     Locale == other.Locale ||
                     Locale != null &&
                     Locale.Equals(other.Locale)
                 ) &&
                 (
                     PaymentProductFilters == other.PaymentProductFilters ||
                     PaymentProductFilters != null &&
                     PaymentProductFilters.Equals(other.PaymentProductFilters)
                 ) &&
                 (
                     ReturnCancelState == other.ReturnCancelState ||
                     ReturnCancelState != null &&
                     ReturnCancelState.Equals(other.ReturnCancelState)
                 ) &&
                 (
                     ReturnUrl == other.ReturnUrl ||
                     ReturnUrl != null &&
                     ReturnUrl.Equals(other.ReturnUrl)
                 ) &&
                 (
                     ShowResultPage == other.ShowResultPage ||
                     ShowResultPage != null &&
                     ShowResultPage.Equals(other.ShowResultPage)
                 ) &&
                 (
                     Tokens == other.Tokens ||
                     Tokens != null &&
                     Tokens.Equals(other.Tokens)
                 ) &&
                 (
                     ValidateShoppingCart == other.ValidateShoppingCart ||
                     ValidateShoppingCart != null &&
                     ValidateShoppingCart.Equals(other.ValidateShoppingCart)
                 ) &&
                 (
                     Variant == other.Variant ||
                     Variant != null &&
                     Variant.Equals(other.Variant)
                 ));
        }