Inheritance: OAuthBase
Beispiel #1
0
        private void AddAuthParameters(ICollection <WebParameter> parameters, string timestamp, string nonce)
        {
            WebParameterCollection webParameterCollection = new WebParameterCollection
            {
                new WebParameter("oauth_consumer_key", this.ConsumerKey),
                new WebParameter("oauth_nonce", nonce),
                new WebParameter("oauth_signature_method", OAuthRequest.ToRequestValue(this.SignatureMethod)),
                new WebParameter("oauth_timestamp", timestamp),
                new WebParameter("oauth_version", this.Version ?? "1.0")
            };

            if (!OAuthRequest.IsNullOrBlank(this.Token))
            {
                webParameterCollection.Add(new WebParameter("oauth_token", this.Token));
            }
            if (!OAuthRequest.IsNullOrBlank(this.CallbackUrl))
            {
                webParameterCollection.Add(new WebParameter("oauth_callback", this.CallbackUrl));
            }
            if (!OAuthRequest.IsNullOrBlank(this.Verifier))
            {
                webParameterCollection.Add(new WebParameter("oauth_verifier", this.Verifier));
            }
            if (!OAuthRequest.IsNullOrBlank(this.SessionHandle))
            {
                webParameterCollection.Add(new WebParameter("oauth_session_handle", this.SessionHandle));
            }
            foreach (WebParameter item in webParameterCollection)
            {
                parameters.Add(item);
            }
        }
Beispiel #2
0
        public static OAuthRequest ForAccessTokenRefresh(string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret, string sessionHandle)
        {
            OAuthRequest oauthRequest = OAuthRequest.ForAccessToken(consumerKey, consumerSecret, accessToken, accessTokenSecret);

            oauthRequest.SessionHandle = sessionHandle;
            return(oauthRequest);
        }
Beispiel #3
0
        public static OAuthRequest ForRequestToken(string consumerKey, string consumerSecret, string callbackUrl)
        {
            OAuthRequest oauthRequest = OAuthRequest.ForRequestToken(consumerKey, consumerSecret);

            oauthRequest.CallbackUrl = callbackUrl;
            return(oauthRequest);
        }
Beispiel #4
0
        private string GetClientSignatureAuthorizationQuery(WebParameterCollection parameters)
        {
            string newSignatureXAuth = this.GetNewSignatureXAuth(parameters);

            parameters.Add("oauth_signature", newSignatureXAuth);
            return(OAuthRequest.WriteAuthorizationQuery(parameters));
        }
Beispiel #5
0
        public static OAuthRequest ForAccessToken(string consumerKey, string consumerSecret, string requestToken, string requestTokenSecret, string verifier)
        {
            OAuthRequest oauthRequest = OAuthRequest.ForAccessToken(consumerKey, consumerSecret, requestToken, requestTokenSecret);

            oauthRequest.Verifier = verifier;
            return(oauthRequest);
        }
Beispiel #6
0
        public static OAuthRequest ForRequestToken(string consumerKey, string consumerSecret)
        {
            var credentials = new OAuthRequest
            {
                Method             = "GET",
                Type               = OAuthRequestType.RequestToken,
                SignatureMethod    = OAuthSignatureMethod.HmacSha1,
                SignatureTreatment = OAuthSignatureTreatment.Escaped,
                ConsumerKey        = consumerKey,
                ConsumerSecret     = consumerSecret
            };

            return(credentials);
        }
 private void ValidateProtectedResourceState()
 {
     if (OAuthRequest.IsNullOrBlank(this.Method))
     {
         throw new ArgumentException("You must specify an HTTP method");
     }
     if (OAuthRequest.IsNullOrBlank(this.ConsumerKey))
     {
         throw new ArgumentException("You must specify a consumer key");
     }
     if (OAuthRequest.IsNullOrBlank(this.ConsumerSecret))
     {
         throw new ArgumentException("You must specify a consumer secret");
     }
 }
Beispiel #8
0
        public static OAuthRequest ForClientAuthentication(string consumerKey, string consumerSecret, string username, string password)
        {
            var credentials = new OAuthRequest
            {
                Method             = "GET",
                Type               = OAuthRequestType.ClientAuthentication,
                SignatureMethod    = OAuthSignatureMethod.HmacSha1,
                SignatureTreatment = OAuthSignatureTreatment.Escaped,
                ConsumerKey        = consumerKey,
                ConsumerSecret     = consumerSecret,
                ClientUsername     = username,
                ClientPassword     = password
            };

            return(credentials);
        }
Beispiel #9
0
        public static OAuthRequest ForProtectedResource(string method, string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret)
        {
            var credentials = new OAuthRequest
            {
                Method             = method ?? "GET",
                Type               = OAuthRequestType.ProtectedResource,
                SignatureMethod    = OAuthSignatureMethod.HmacSha1,
                SignatureTreatment = OAuthSignatureTreatment.Escaped,
                ConsumerKey        = consumerKey,
                ConsumerSecret     = consumerSecret,
                Token              = accessToken,
                TokenSecret        = accessTokenSecret
            };

            return(credentials);
        }
        public static OAuthRequest ForAccessToken(string consumerKey, string consumerSecret, string requestToken, string requestTokenSecret, OAuthSignatureMethod oAuthSignatureMethod = OAuthSignatureMethod.HmacSha1)
        {
            var credentials = new OAuthRequest
            {
                Method             = "GET",
                Type               = OAuthRequestType.AccessToken,
                SignatureMethod    = oAuthSignatureMethod,
                SignatureTreatment = OAuthSignatureTreatment.Escaped,
                ConsumerKey        = consumerKey,
                ConsumerSecret     = consumerSecret,
                Token              = requestToken,
                TokenSecret        = requestTokenSecret
            };

            return(credentials);
        }
Beispiel #11
0
        public async Task <Token> GetRequestToken(string callback)
        {
            var msg = new HttpRequestMessage
            {
                Method     = HttpMethod.Get,
                RequestUri = new Uri(BaseUrl, "?title=Special:OAuth/initiate"),
            };
            var req = new OAuth.OAuthRequest
            {
                Type        = OAuth.OAuthRequestType.RequestToken,
                CallbackUrl = callback,
            };

            Sign(msg, req);
            var response = await Query(msg);

            return(GetToken(response));
        }
Beispiel #12
0
        public string getRequestToken()
        {
            string       oauth_token = this._oauthConfig.OauthToken;
            OAuthRequest request     = new OAuthRequest(this, base._debugType);
            string       tokens      = request.request(new Uri(this._oauthConfig.RequestTokenUrl), "GET", oauth_token, "", null).ToString();

            if (tokens == String.Empty || tokens.Length == 0)
            {
                return(null);
            }

            // Save Tokens in Configuration
            this._saveTokenDataInConfiguration(tokens);

            // Open Authorization Page
            this._openAuthorizationPage();
            return(tokens);
        }
Beispiel #13
0
        private string WriteAuthorizationHeader(WebParameterCollection parameters)
        {
            StringBuilder stringBuilder = new StringBuilder("OAuth ");

            if (!OAuthRequest.IsNullOrBlank(this.Realm))
            {
                stringBuilder.AppendFormat("realm=\"{0}\",", OAuthTools.UrlEncodeRelaxed(this.Realm));
            }
            parameters.Sort((WebParameter l, WebParameter r) => l.Name.CompareTo(r.Name));
            int num = 0;

            foreach (WebParameter webParameter in parameters.Where((WebParameter parameter) => !OAuthRequest.IsNullOrBlank(parameter.Name) && !OAuthRequest.IsNullOrBlank(parameter.Value) && (parameter.Name.StartsWith("oauth_") || parameter.Name.StartsWith("x_auth_"))))
            {
                num++;
                string format = (num >= parameters.Count) ? "{0}=\"{1}\"" : "{0}=\"{1}\",";
                stringBuilder.AppendFormat(format, webParameter.Name, webParameter.Value);
            }
            return(stringBuilder.ToString());
        }
 private void ValidateRequestState()
 {
     if (OAuthRequest.IsNullOrBlank(this.Method))
     {
         throw new ArgumentException("You must specify an HTTP method");
     }
     if (OAuthRequest.IsNullOrBlank(this.RequestUrl))
     {
         throw new ArgumentException("You must specify a request token URL");
     }
     if (OAuthRequest.IsNullOrBlank(this.ConsumerKey))
     {
         throw new ArgumentException("You must specify a consumer key");
     }
     if (OAuthRequest.IsNullOrBlank(this.ConsumerSecret))
     {
         throw new ArgumentException("You must specify a consumer secret");
     }
 }
Beispiel #15
0
        //OAuth oauth_consumer_key = "jira", oauth_nonce = "LyiqlQJcnUmcvqNvMPJLzNyPTEQnlKFFrFqlGayGg", oauth_signature_method = "RSA-SHA1", oauth_timestamp = "1539430294", oauth_version = "1.0", oauth_token = "fdfgfgfg", oauth_signature = "X%2F%2BVnUmrxKOqQxgXPJ6n1kBTMI1Igq7b1Cd6Kziq8QbkF7yVZGnP8c6azof0hlzf2LF013oFqDnf2NEpvSqeCWpn7YPg7PgAzEY%2Bzn5RI3NQcXsGMoSLZeVjQL%2FthWbAzeAfZUrz9fx2tV%2BQzSZS7bpmQ%2BeShO5IEGeq6EjgajU%3D"
        private void SetAuthorizatonHeader(HttpClient client, Model.UserSession userSession, string url, string requestType)
        {
            var key = PemKeyUtils.GetRSAProviderFromString(userSession.AuthClientConfig.ConsumerSecret);

            var oauth = new OAuth.OAuthRequest();

            oauth.RequestUrl      = url;
            oauth.Method          = requestType;
            oauth.ConsumerKey     = userSession.AuthClientConfig.ConsumerKey;
            oauth.ConsumerSecret  = userSession.AuthClientConfig.ConsumerSecret;
            oauth.SignatureMethod = OAuthSignatureMethod.RsaSha1;
            oauth.Token           = userSession.AccessToken;
            oauth.TokenSecret     = userSession.AccessSecret;
            oauth.Version         = "1.0";
            oauth.Type            = OAuthRequestType.ProtectedResource;

            var authorizationHeader = oauth.GetAuthorizationHeader();

            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("OAuth", authorizationHeader.Substring(5));
        }
Beispiel #16
0
        public async Task <Token> GetAccessToken(Token requestToken, string verifier)
        {
            var msg = new HttpRequestMessage
            {
                Method     = HttpMethod.Get,
                RequestUri = new Uri(BaseUrl, "?title=Special:OAuth/token"),
            };
            var req = new OAuth.OAuthRequest
            {
                Type        = OAuth.OAuthRequestType.AccessToken,
                Token       = requestToken.Key,
                TokenSecret = requestToken.Secret,
                Verifier    = verifier,
            };

            Sign(msg, req);
            var response = await Query(msg);

            return(GetToken(response));
        }
 private void AddXAuthParameters(
     ICollection <WebParameter> parameters,
     string timestamp,
     string nonce)
 {
     foreach (WebParameter webParameter in new WebParameterCollection()
     {
         new WebParameter("x_auth_username", this.ClientUsername),
         new WebParameter("x_auth_password", this.ClientPassword),
         new WebParameter("x_auth_mode", "client_auth"),
         new WebParameter("oauth_consumer_key", this.ConsumerKey),
         new WebParameter("oauth_signature_method", OAuthRequest.ToRequestValue(this.SignatureMethod)),
         new WebParameter("oauth_timestamp", timestamp),
         new WebParameter("oauth_nonce", nonce),
         new WebParameter("oauth_version", this.Version ?? "1.0")
     })
     {
         parameters.Add(webParameter);
     }
 }
Beispiel #18
0
        public string getAccessToken(string oauth_verifier)
        {
            string oauth_token               = this._oauthConfig.OauthToken;
            string oauth_token_secret        = this._oauthConfig.OauthTokenSecret;
            List <QueryParameter> parameters = new List <QueryParameter>();

            //parameters.Add(new QueryParameter("oauth_token", oauth_token));
            parameters.Add(new QueryParameter("oauth_verifier", oauth_verifier));
            OAuthRequest request = new OAuthRequest(this, base._debugType);
            string       tokens  = request.request(new Uri(this._oauthConfig.AccessTokenUrl), "GET", oauth_token, oauth_token_secret, parameters).ToString();

            if (tokens == String.Empty || tokens.Length == 0)
            {
                return(null);
            }

            // Save Tokens in Configuration
            this._saveTokenDataInConfiguration(tokens);

            return(tokens);
        }
        private static string WriteAuthorizationQuery(WebParameterCollection parameters)
        {
            StringBuilder stringBuilder = new StringBuilder();

            parameters.Sort((Comparison <WebParameter>)((l, r) => l.Name.CompareTo(r.Name)));
            int num = 0;

            foreach (WebParameter webParameter in parameters.Where <WebParameter>((Func <WebParameter, bool>)(parameter =>
            {
                if (!OAuthRequest.IsNullOrBlank(parameter.Name) && !OAuthRequest.IsNullOrBlank(parameter.Value))
                {
                    return(parameter.Name.StartsWith("oauth_"));
                }
                return(false);
            })))
            {
                ++num;
                string format = num < parameters.Count ? "{0}={1}&" : "{0}={1}";
                stringBuilder.AppendFormat(format, (object)webParameter.Name, (object)webParameter.Value);
            }
            return(stringBuilder.ToString());
        }
 private void ValidateClientAuthAccessRequestState()
 {
     if (OAuthRequest.IsNullOrBlank(this.Method))
     {
         throw new ArgumentException("You must specify an HTTP method");
     }
     if (OAuthRequest.IsNullOrBlank(this.RequestUrl))
     {
         throw new ArgumentException("You must specify an access token URL");
     }
     if (OAuthRequest.IsNullOrBlank(this.ConsumerKey))
     {
         throw new ArgumentException("You must specify a consumer key");
     }
     if (OAuthRequest.IsNullOrBlank(this.ConsumerSecret))
     {
         throw new ArgumentException("You must specify a consumer secret");
     }
     if (OAuthRequest.IsNullOrBlank(this.ClientUsername) || OAuthRequest.IsNullOrBlank(this.ClientPassword))
     {
         throw new ArgumentException("You must specify user credentials");
     }
 }
Beispiel #21
0
        public Object request(string url, string httpMethod, List <QueryParameter> parameters, string responseFormat)
        {
            string       oauth_token        = this._oauthConfig.OauthToken;
            string       oauth_token_secret = this._oauthConfig.OauthTokenSecret;
            OAuthRequest request            = new OAuthRequest(this, base._debugType);
            string       response           = request.request(new Uri(url), httpMethod, oauth_token, oauth_token_secret, parameters).ToString();

            if (response == String.Empty || response.Length == 0)
            {
                base._debug("The Request Response was empty");
                return(null);
            }
            Object result = null;

            switch (responseFormat)
            {
            case "DataSet":
                System.IO.StringReader strreader = new System.IO.StringReader(response);
                DataSet ds = new DataSet();
                ds.ReadXml(strreader);
                result = ds;
                break;

            case "XML":
                System.IO.StringReader strxmlreader = new System.IO.StringReader(response);
                XmlTextReader          xmlReader    = new XmlTextReader(strxmlreader);
                xmlReader.Read();
                result = xmlReader;
                break;

            case "PLAIN":
            default:
                result = response;
                break;
            }
            return(result);
        }
        private void getC2GAccessToken(string[] tokenData)
        {
            var car2GoGetTokenEndpoint = "https://www.car2go.com/api/accesstoken";

            var oauthRequest = new OAuthRequest() {
                CallbackUrl = "oob",
                ConsumerKey = FreeCarsCredentials.Car2Go.ConsumerKey,
                ConsumerSecret = FreeCarsCredentials.Car2Go.SharedSecred,
                Method = "GET",
                RequestUrl = car2GoGetTokenEndpoint,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                Token = tokenData[0],
                TokenSecret = (string)App.GetAppSetting("car2go.oauth_token_secret"),
                //TokenSecret = tokenData[1],
                Type = OAuthRequestType.AccessToken,
                Verifier = tokenData[1],
                Version = "1.0",
            };
            var requestParameters = oauthRequest.GetAuthorizationQuery();
            var requestUrl = new Uri(car2GoGetTokenEndpoint + "?" + requestParameters, UriKind.Absolute);

            var webClient = new WebClient();
            webClient.DownloadStringCompleted += (client, arguments) => {
                if (null != arguments.Error) {
                    MessageBox.Show(Strings.SettingsPageCar2GoAuthFailed);
                    return;
                }
                var results = arguments.Result.Split(new char[] { '&' }, StringSplitOptions.None);
                App.SetAppSetting("car2go.oauth_token", results[0].Split(new char[] { '=' })[1]);
                App.SetAppSetting("car2go.oauth_token_secret", results[1].Split(new char[] { '=' })[1]);
                App.SetAppSetting("car2go.oauth_token_timestamp", DateTime.UtcNow);
                CheckCar2GoApiAccess();
            };
            webClient.DownloadStringAsync(requestUrl);
        }
 public void verifyUrl(string url)
 {
     var qsParams = HttpUtility.ParseQueryString(url);
     var token = qsParams.Get("oauth_token");
     var verifier = qsParams.Get("oauth_verifier");
     OAuthRequest client = new OAuthRequest()
     {
         Method = "GET",
         Type = OAuthRequestType.AccessToken,
         SignatureMethod = OAuthSignatureMethod.HmacSha1,
         ConsumerKey = this.consumerKey,
         ConsumerSecret = this.consumerSecret,
         RequestUrl = "https://api.shapeways.com/oauth1/access_token/v1",
         Version = "1.0a",
         Realm = "shapeways.com",
         TokenSecret = this.OAuthSecret,
         Token = token,
         Verifier = verifier,
     };
     string auth = client.GetAuthorizationQuery();
     string requestUrl = client.RequestUrl + "?" + auth;
     HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUrl);
     HttpWebResponse response = (HttpWebResponse)request.GetResponse();
     string content = new StreamReader(response.GetResponseStream()).ReadToEnd();
     var result = HttpUtility.ParseQueryString(content);
     this.OAuthToken = result.Get("oauth_token");
     this.OAuthSecret = result.Get("oauth_token_secret");
 }
        private HttpWebResponse ConsumerHandshake(OAuthRequest client, string jsessionid, string setCookieHeader, string domain)
        {
            var authReq =
                (HttpWebRequest)
                    WebRequest.Create(serviceConfig.ServerRoot + AcsApiClientConfig.AuthUrl + "?" + OauthTokenKey + "=" +
                                      HttpUtility.UrlEncode(client.Token));

            authReq.AllowAutoRedirect = false;
            authReq.CookieContainer = new CookieContainer();

            authReq.CookieContainer.Add(new Cookie(SessionIdKey.ToUpper(), jsessionid) { Domain = domain });
            authReq.CookieContainer.Add(new Cookie(ConsumerTypeIdKey, ConsumerTypeValue) { Domain = domain });

            cookies.Add(new Cookie(ConsumerTypeIdKey, ConsumerTypeValue, "/", domain));

            CookieCollection newRequiredCookies = new CookieCollection();
            try
            {
                newRequiredCookies = AcsApiSetCookieHeaderParser.GetAllCookiesFromHeader(setCookieHeader,
                    new Uri(serviceConfig.ServerRoot).Host);
            }
            catch (Exception e)
            {
                throw new AcsApiException("Could not parse cookie for final request!");
            }
            RefreshCookies(newRequiredCookies, authReq);

            HttpWebResponse authReqResp;
            try
            {
                authReqResp = authReq.GetResponse() as HttpWebResponse;
            }
            catch (WebException wex)
            {
                throw new AcsApiException(AcsApiError.ServerError.ToString(), wex);
            }

            // bbax: response streams being closed while dealing with exceptions... yey..
            // todo: clean this up more...
            if (authReqResp?.Headers == null)
            {
                authReqResp?.Close();
                throw new AcsApiException(AcsApiError.CouldNotLogin);
            }
            return authReqResp;
        }
        private HttpWebResponse RequestFinal(OAuthRequest client, string accessToken, string oauthVerifier, string cdomain, string consumerCookies)
        {
            client.Token = accessToken;
            client.Type = OAuthRequestType.AccessToken;
            client.Verifier = oauthVerifier;
            client.RequestUrl = serviceConfig.ServerRoot + AcsApiClientConfig.AccessUrl;
            client.CallbackUrl = null;
            client.TokenSecret = HttpUtility.UrlDecode(client.TokenSecret);
            var auth = client.GetAuthorizationHeader();

            var accessTokenRequest = (HttpWebRequest)WebRequest.Create(serviceConfig.ServerRoot + AcsApiClientConfig.AccessUrl);
            accessTokenRequest.Method = "GET";
            accessTokenRequest.Headers.Add("Authorization", auth);
            accessTokenRequest.CookieContainer = new CookieContainer();
            //accessTokenRequest.CookieContainer.Add(new Cookie(ConsumerTypeIdKey, ConsumerTypeValue) { Domain = cdomain });

            CookieCollection newRequiredCookies = new CookieCollection();
            try
            {
                newRequiredCookies = AcsApiSetCookieHeaderParser.GetAllCookiesFromHeader(consumerCookies,
                    new Uri(serviceConfig.ServerRoot).Host);
            }
            catch (Exception e)
            {
                throw new AcsApiException("Could not parse cookie for final request!");
            }
            RefreshCookies(newRequiredCookies, accessTokenRequest);

            accessTokenRequest.AllowAutoRedirect = false;

            HttpWebResponse accessTokenResponse = null;

            try
            {
                accessTokenResponse = (HttpWebResponse)accessTokenRequest.GetResponse();
            }
            catch (WebException wex)
            {
                throw new AcsApiException(AcsApiError.ServerError.ToString(), wex);
            }
            return accessTokenResponse;
        }
        private void LoadFssToken()
        {
            // Creating a new instance directly
            var client = new OAuthRequest
            {
                Method = "GET",
                Type = OAuthRequestType.RequestToken,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                ConsumerKey = serviceConfig.ConsumerKey,
                ConsumerSecret = serviceConfig.ConsumerSecret,
                RequestUrl = serviceConfig.ServerRoot + AcsApiClientConfig.RequestUrl,
                CallbackUrl = serviceConfig.ServerRoot + "client"
            };


            //CookieCollection responseCookies = null;
            string setCookieHeader;
            var fields = new Hashtable();
            using (var responseWrapper = new WebResponseWrapper(RequestToken(client)))
            {
                var responseText = GetResponseFromWebResponseWrapped(responseWrapper);

                for (var i = 0; i < responseText.Split('&').Length; i++)
                {
                    var fieldInfo = responseText.Split('&')[i].Split('=');
                    fields[fieldInfo[0]] = fieldInfo[1];
                }

                //responseCookies = responseWrapper.Get().Cookies;
                setCookieHeader = responseWrapper.Get().Headers["Set-Cookie"];
            }

            var myHttpWebRequest = Login(client, setCookieHeader, fields);

            string jsessionid;
            setCookieHeader = null;
            try
            {
                using (var responseWrapper = new WebResponseWrapper((HttpWebResponse)myHttpWebRequest.GetResponse()))
                {
                    setCookieHeader = responseWrapper.Get().Headers["Set-Cookie"];
                    var sessionCookie = responseWrapper.Get().Cookies[SessionIdKey];
                    if (sessionCookie != null)
                    {
                        jsessionid = sessionCookie.Value;

                        InvokeLog("Jsesssion found at " + jsessionid);
                        cookies.Add(sessionCookie);
                    }
                    else
                    {
                        throw new InvalidOperationException("JSession Id returned null!");
                    }
                }
            }
            catch (WebException wex)
            {
                throw new AcsApiException(AcsApiError.ServerError.ToString(), wex);
            }

            var target = new Uri(serviceConfig.ServerRoot);
            var cdomain = target.Host;

            string[] locations;
            using (var responseWrapper = new WebResponseWrapper(ConsumerHandshake(client, jsessionid, setCookieHeader, cdomain)))
            {
                locations = responseWrapper.Get().Headers.GetValues("location");
                setCookieHeader = responseWrapper.Get().Headers["Set-Cookie"];
            }

            if (locations == null)
            {
                throw new AcsApiException(AcsApiError.CouldNotLogin);
            }

            var myUri = new Uri(locations.FirstOrDefault() ?? string.Empty);
            InvokeLog("Request for uri" + myUri);
            if (string.IsNullOrEmpty(myUri.Query))
            {
                // No oauth_token or oauth_verifier in location header, so didn't authenticate.
                throw new AcsApiException(AcsApiError.CouldNotLogin);
            }

            var accessToken = HttpUtility.ParseQueryString(myUri.Query).Get(OauthTokenKey);
            var oauthVerifier = HttpUtility.ParseQueryString(myUri.Query).Get(OauthVerifierKey);

            InvokeLog("Verifier response " + accessToken + " : " + oauthVerifier);

            if (string.IsNullOrEmpty(oauthVerifier))
            {
                throw new AcsApiException(AcsApiError.CouldNotFindVerifier);
            }

            using (var requestWrapper = new WebResponseWrapper(RequestFinal(client, accessToken, oauthVerifier, cdomain, setCookieHeader)))
            {
                using (var responseStream = new StreamWrapper(requestWrapper.Get().GetResponseStream()))
                {
                    if (responseStream.Get() == null)
                    {
                        throw new AcsApiException(AcsApiError.CouldNotGetAccesstoken);
                    }

                    string responseOutput;

                    // Pipes the stream to a higher level stream reader with the required encoding format. 
                    using (var readStream = new StreamReader(responseStream.Get(), Encoding.UTF8))
                    {
                        responseOutput = readStream.ReadToEnd();
                    }

                    serviceConfig.AccessToken = HttpUtility.ParseQueryString(responseOutput).Get(OauthTokenKey);
                    serviceConfig.AccessTokenSecret = HttpUtility.ParseQueryString(responseOutput).Get(OauthTokenSecretKey);

                    InvokeLog("Final Tokens: " + serviceConfig.AccessToken + " : " + serviceConfig.AccessTokenSecret);
                }
            }
        }
        private static void AddQueryStringParameters(OAuthRequest request, Uri uri)
        {
            var nameValueCollection = HttpUtility.ParseQueryString(uri.Query);

            for (var i = 0; i < nameValueCollection.Count; i++)
            {
                request.AddRequestParameter(nameValueCollection.GetKey(i), nameValueCollection.Get(i));
            }
        }
Beispiel #28
0
        private static string WriteAuthorizationQuery(WebParameterCollection parameters)
        {
            StringBuilder stringBuilder = new StringBuilder();

            parameters.Sort((WebParameter l, WebParameter r) => l.Name.CompareTo(r.Name));
            int num = 0;

            foreach (WebParameter webParameter in parameters.Where((WebParameter parameter) => !OAuthRequest.IsNullOrBlank(parameter.Name) && !OAuthRequest.IsNullOrBlank(parameter.Value) && (parameter.Name.StartsWith("oauth_") || parameter.Name.StartsWith("x_auth_"))))
            {
                num++;
                string format = (num >= parameters.Count) ? "{0}={1}" : "{0}={1}&";
                stringBuilder.AppendFormat(format, webParameter.Name, webParameter.Value);
            }
            return(stringBuilder.ToString());
        }
        private void connectCar2Go()
        {
            var car2GoGetTokenEndpoint = "https://www.car2go.com/api/reqtoken";
            var oauthRequest = new OAuthRequest {
                CallbackUrl = "oob",
                ConsumerKey = FreeCarsCredentials.Car2Go.ConsumerKey,
                ConsumerSecret = FreeCarsCredentials.Car2Go.SharedSecred,
                Method = "GET",
                RequestUrl = car2GoGetTokenEndpoint,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                Type = OAuthRequestType.RequestToken,
                Version = "1.0",
            };
            var requestParameters = oauthRequest.GetAuthorizationQuery();
            var requestUrl = new Uri(car2GoGetTokenEndpoint + "?" + requestParameters, UriKind.Absolute);

            var webClient = new WebClient();
            webClient.DownloadStringCompleted += delegate(object client, DownloadStringCompletedEventArgs arguments) {
                string[] results = { };
                if (null != arguments.Error) {
                    return;
                }
                var authorizeUrl = new Uri("https://www.car2go.com/api/authorize?" + arguments.Result, UriKind.Absolute);
                results = arguments.Result.Split(new string[] { "&" }, StringSplitOptions.None);
                App.SetAppSetting("car2go.oauth_token_secret", results[1].Split(new char[] { '=' })[1]);
                App.SetAppSetting("car2go.oauth_request_token", results[0].Split(new char[] { '=' })[1]);
                //(string)IsolatedStorageSettings.ApplicationSettings["current_map_city"]
                if (App.IsCertified) {
                    c2gAuthBrowser.Dispatcher.BeginInvoke(() => {
                        c2gAuthBrowser.Visibility = Visibility.Visible;
                        c2gAuthBrowser.Navigate(authorizeUrl);
                    });
                } else {
                    verifierPanel.Visibility = Visibility.Visible;
                    var authBrowserTask = new WebBrowserTask {
                        Uri = authorizeUrl,
                    };
                    c2gScrollViewer.ScrollToVerticalOffset(c2gScrollViewer.ActualHeight);
                    authBrowserTask.Show();
                }
            };
            webClient.DownloadStringAsync(requestUrl);
        }
Beispiel #30
0
 public static OAuthRequest ForProtectedResource(string method, string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret)
 {
     var credentials = new OAuthRequest
     {
         Method = "GET",
         Type = OAuthRequestType.ProtectedResource,
         SignatureMethod = OAuthSignatureMethod.HmacSha1,
         SignatureTreatment = OAuthSignatureTreatment.Escaped,
         ConsumerKey = consumerKey,
         ConsumerSecret = consumerSecret,
         Token = accessToken,
         TokenSecret = accessTokenSecret
     };
     return credentials;
 }
Beispiel #31
0
        public void GetAccess(string verificationCode)
        {
            this.client = OAuthRequest.ForAccessToken(this.consumer_key, this.consumer_secret, this.request_token, this.request_secret, verificationCode);
            this.client.RequestUrl = this.accessUrl;

            // Using URL query authorization
            string auth2 = this.client.GetAuthorizationQuery();
            var url2 = this.client.RequestUrl + "?" + auth2;
            var request2 = (HttpWebRequest)WebRequest.Create(url2);
            var response2 = (HttpWebResponse)request2.GetResponse();

            //Console.WriteLine(url2);
            //Console.WriteLine("STREAM!");

            //Console.WriteLine(StreamToString(response2.GetResponseStream()));

            string authQuery = StreamToString(response2.GetResponseStream());

            Console.WriteLine(authQuery);

            //Seperate the stream into an Array.
            List<string> query = new List<string>();

            //TODO: Fix ERROR!
            query = QueryToArray(authQuery);
            //Assign each query to their value.
            access_token = query[3];
            access_secret = query[1];

            //Console.WriteLine("Access Token: " + access_token);
            //Console.WriteLine("Access Secret: " + access_secret);
        }
Beispiel #32
0
 public static OAuthRequest ForRequestToken(string consumerKey, string consumerSecret)
 {
     var credentials = new OAuthRequest
     {
         Method = "GET",
         Type = OAuthRequestType.RequestToken,
         SignatureMethod = OAuthSignatureMethod.HmacSha1,
         SignatureTreatment = OAuthSignatureTreatment.Escaped,
         ConsumerKey = consumerKey,
         ConsumerSecret = consumerSecret
     };
     return credentials;
 }
Beispiel #33
-1
 public String connect()
 {
     OAuthRequest client = new OAuthRequest()
     {
         Method = "GET",
         Type = OAuthRequestType.RequestToken,
         SignatureMethod = OAuthSignatureMethod.HmacSha1,
         ConsumerKey = this.consumerKey,
         ConsumerSecret = this.consumerSecret,
         RequestUrl = "https://api.shapeways.com/oauth1/request_token/v1",
         Version = "1.0a",
         Realm = "shapeways.com",
         CallbackUrl = this.callback,
     };
     string auth = client.GetAuthorizationQuery();
     string url = client.RequestUrl + "?" + auth;
     HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
     HttpWebResponse response = (HttpWebResponse)request.GetResponse();
     string content = new StreamReader(response.GetResponseStream()).ReadToEnd();
     var result = HttpUtility.ParseQueryString(content);
     var authUrl = result.Get("authentication_url");
     this.OAuthToken = result.Get("oauth_token");
     this.OAuthSecret = result.Get("oauth_token_secret");
     response.Close();
     return authUrl;
 }
		private string BuildOAuthHeader(RequestData requestData, string fullUrl, IDictionary<string, string> parameters, RequestPayload requestBody)
		{
			var httpMethod = requestData.HttpMethod.ToString().ToUpperInvariant();

			var oauthRequest = new OAuthRequest
				{
					Type = OAuthRequestType.ProtectedResource,
					RequestUrl = fullUrl,
					Method = httpMethod,
					ConsumerKey = _oAuthCredentials.ConsumerKey,
					ConsumerSecret = _oAuthCredentials.ConsumerSecret,
				};

			if (!string.IsNullOrEmpty(requestData.OAuthToken))
			{
				oauthRequest.Token = requestData.OAuthToken;
				oauthRequest.TokenSecret = requestData.OAuthTokenSecret;
			}

			if (ShouldReadParamsFromBody(parameters, requestBody))
			{
				var bodyParams = HttpUtility.ParseQueryString(requestBody.Data);
				var keys = bodyParams.AllKeys.Where(x => !string.IsNullOrEmpty(x));
				foreach (var key in keys)
				{
					parameters.Add(key, bodyParams[key]);
				}
			}

			return oauthRequest.GetAuthorizationHeader(parameters);
		}
Beispiel #35
-1
        public dynamic Get(string endpoint)
        {
            //Make a protected resource call!

            this.client = OAuthRequest.ForProtectedResource("GET", this.consumer_key, this.consumer_secret, this.access_token, this.access_secret);

            //INSERT API Endpoint:
            this.client.RequestUrl = this.baseUrl + endpoint;
            //client.RequestUrl = baseUrl + "api/2/ping";

            // Using URL query authorization
            string auth = this.client.GetAuthorizationQuery();
            var url = this.client.RequestUrl + "?" + auth;
            var request = (HttpWebRequest)WebRequest.Create(url);
            //request3.ContentType = "application/json; charset=utf-8";
            var response = (HttpWebResponse)request.GetResponse();

            //Console.WriteLine(StreamToString(response3.GetResponseStream()));

            string json = StreamToString(response.GetResponseStream());

            //Read the JSON from the string.
            JsonTextReader reader = new JsonTextReader(new StringReader(json));

            //Serialize the JSON text.
            JsonSerializer se = new JsonSerializer();

            //Deserialize the text and place in dynamic type, for easy manipulation.
            dynamic parsedData = se.Deserialize(reader);

            return parsedData;
        }
Beispiel #36
-1
        private static string MakeRequest(Settings settings, string baseUrl, string path, string method = "GET", Dictionary<String, String> data = null)
        {
            string url = baseUrl + path;
            //create an instance of OAuthRequest with the appropriate properties
            OAuthRequest client = new OAuthRequest
            {
                Method = method,
                Type = OAuthRequestType.RequestToken,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                ConsumerKey = settings.consumerKey,
                ConsumerSecret = GetSha1(settings.consumerSecret, settings.salt),
                RequestUrl = url
            };

            string auth = client.GetAuthorizationHeader();
            WebClient c = new WebClient();
            c.Headers.Add("Authorization", auth);
            c.BaseAddress = baseUrl;
            if (method == "GET")
            {
                return c.DownloadString(path);
            }
            else
            {
                c.Headers[HttpRequestHeader.ContentType] = "application/json";
                return c.UploadString(path, JsonConvert.SerializeObject(data));
            }
        }
Beispiel #37
-1
        public Object request(string url, string httpMethod, List<QueryParameter> parameters, string responseFormat)
        {
            string oauth_token = this._oauthConfig.OauthToken;
            string oauth_token_secret = this._oauthConfig.OauthTokenSecret;
            OAuthRequest request = new OAuthRequest(this, base._debugType);
            string response = request.request(new Uri(url), httpMethod, oauth_token, oauth_token_secret, parameters).ToString();
            if (response == String.Empty || response.Length == 0)
            {
                base._debug("The Request Response was empty");
                return null;
            }
            Object result = null;

            switch (responseFormat)
            {
                case "DataSet":
                    System.IO.StringReader strreader = new System.IO.StringReader(response);
                    DataSet ds = new DataSet();
                    ds.ReadXml(strreader);
                    result = ds;
                    break;
                case "XML":
                    System.IO.StringReader strxmlreader = new System.IO.StringReader(response);
                    XmlTextReader xmlReader = new XmlTextReader(strxmlreader);
                    xmlReader.Read();
                    result = xmlReader;
                    break;
                case "PLAIN":
                default:
                    result = response;
                    break;
            }
            return result;
        }
Beispiel #38
-1
        private NameValueCollection OAuthQuery(OAuthRequest oAuthRequest)
        {
            var auth = oAuthRequest.GetAuthorizationHeader();
            var request = new Common.Http.HttpRequest(oAuthRequest.RequestUrl);
            request.Headers.Add("Authorization", auth);
            var response = _httpClient.Get(request);

            return HttpUtility.ParseQueryString(response.Content);
        }
        public static OAuthRequest ParseRequest(string method, Uri url, string authorizationHeader)
        {
            var request = new OAuthRequest { Method = method, Url = url };

            AddQueryStringParameters(request, url);
            AddAuthorizationHeaderParameters(request, authorizationHeader);

            return request;
        }
Beispiel #40
-1
		public async Task<string> SendRequest(string endpointUrl, Dictionary<string, string> queryStringParams, HttpMethod httpMethod) {
			// create oauth client to generate our auth header
			OAuthRequest client = new OAuthRequest {
				Method = httpMethod.ToString().ToUpper(),
				Type = OAuthRequestType.ProtectedResource,
				SignatureMethod = OAuthSignatureMethod.HmacSha256,
				ConsumerKey = ACCESS_ID,
				ConsumerSecret = ACCESS_SECRET,
				RequestUrl = string.Concat(HOSTNAME, endpointUrl),
				Version = "1.0",
			};

			using (var http = new HttpClient()) {
				// add our auth header
				string authHeader;
				// for some reason, GET requests should not have the query string params in the auth header. this might be a bug on the server side.
				if (httpMethod != HttpMethod.Get && queryStringParams != null) {
					authHeader = client.GetAuthorizationHeader(queryStringParams);
				} else {
					authHeader = client.GetAuthorizationHeader();
				}
				http.DefaultRequestHeaders.Add("Authorization", authHeader);

				var url = client.RequestUrl;
				HttpResponseMessage response;

				if (httpMethod == HttpMethod.Get) {
					// GET
					// add our query string back into the url if its set
					if (queryStringParams != null) {
						url = string.Format("{0}?{1}", url, GetQueryString(queryStringParams));
					}
					response = await http.GetAsync(url);
				} else if (httpMethod == HttpMethod.Post) {
					// POST
					response = await http.PostAsync(url, queryStringParams == null ? null : new FormUrlEncodedContent(queryStringParams));
				} else if (httpMethod == HttpMethod.Put) {
					// PUT
					response = await http.PutAsync(url, queryStringParams == null ? null : new FormUrlEncodedContent(queryStringParams));
				} else {
					throw new Exception("http method not supported: " + httpMethod);
				}

				// handle response
				var content = await response.Content.ReadAsStringAsync();
				if (response.IsSuccessStatusCode) {
					return content;
				} else {
					return string.Format("{0}: {1}", response.StatusCode, content);
				}
			}

			return null;
		}
Beispiel #41
-1
        //Stream currentResponse;
        //Constructor
        public OAuth(string consumer_key, string consumer_secret)
        {
            this.baseUrl = "https://app.smartfile.com/";

            this.requestUrl = "https://app.smartfile.com/oauth/request_token/";
            this.userAuthorizeUrl = "https://app.smartfile.com/oauth/authorize/";
            this.accessUrl = "https://app.smartfile.com/oauth/access_token/";
            this.consumer_key = consumer_key;
            this.consumer_secret = consumer_secret;

            this.client = OAuthRequest.ForRequestToken(this.consumer_key, this.consumer_secret);
        }
Beispiel #42
-1
        public string getRequestTokenRedirectUrl(List<QueryParameter> extraparameters, string extrapost)
        {
            string oauth_token = this._oauthConfig.OauthToken;
            OAuthRequest request = new OAuthRequest(this, base._debugType);
            string tokens = request.request(new Uri(this._oauthConfig.RequestTokenUrl), "GET", oauth_token, "", extraparameters, extrapost).ToString();
            if (tokens == String.Empty || tokens.Length == 0) return null;

            // Save Tokens in Configuration
            this._saveTokenDataInConfiguration(tokens);

            // Open Authorization Page
            return this._getAuthorizationPageUrl();
        }
        public static OAuthRequest CreateRequest(string method, Uri url, string oauthConsumerKey, string oauthToken = null)
        {
            var request = new OAuthRequest { Method = method, Url = url };

            AddQueryStringParameters(request, url);

            request.OAuthConsumerKey = oauthConsumerKey;
            request.OAuthToken = oauthToken;
            request.OAuthNonce = OAuthRandom.GenerateAlphanumericKey(DefaultNonceLength);
            request.OAuthSignatureMethod = OAuthSignatureMethods.HMACSHA1;
            request.OAuthTimestamp = OAuthUtil.CalculateTimestamp(DateTime.UtcNow);

            return request;
        }
Beispiel #44
-1
        public string getRequestToken()
        {
            string oauth_token = this._oauthConfig.OauthToken;
            OAuthRequest request = new OAuthRequest(this, base._debugType);
            string tokens = request.request(new Uri(this._oauthConfig.RequestTokenUrl), "GET", oauth_token, "", null).ToString();
            if (tokens == String.Empty || tokens.Length == 0) return null;

            // Save Tokens in Configuration
            this._saveTokenDataInConfiguration(tokens);

            // Open Authorization Page
            this._openAuthorizationPage();
            return tokens;
        }
Beispiel #45
-1
        public string getAccessToken(string oauth_verifier)
        {
            string oauth_token = this._oauthConfig.OauthToken;
            string oauth_token_secret = this._oauthConfig.OauthTokenSecret;
            List<QueryParameter> parameters = new List<QueryParameter>();
            //parameters.Add(new QueryParameter("oauth_token", oauth_token));
            parameters.Add(new QueryParameter("oauth_verifier", oauth_verifier));
            OAuthRequest request = new OAuthRequest(this, base._debugType);
            string tokens = request.request(new Uri(this._oauthConfig.AccessTokenUrl), "GET", oauth_token, oauth_token_secret, parameters, "").ToString();
            if (tokens == String.Empty || tokens.Length == 0) return null;

            // Save Tokens in Configuration
            this._saveTokenDataInConfiguration(tokens);

            return tokens;
        }
		private string BuildOAuthHeader(RequestData requestData, string fullUrl, IDictionary<string, string> parameters)
		{
			var oauthRequest = new OAuthRequest
				{
					Type = OAuthRequestType.ProtectedResource,
					RequestUrl = fullUrl,
					Method = requestData.HttpMethod.ToString().ToUpperInvariant(),
					ConsumerKey = _oAuthCredentials.ConsumerKey,
					ConsumerSecret = _oAuthCredentials.ConsumerSecret,
				};

			if (!string.IsNullOrEmpty(requestData.OAuthToken))
			{
				oauthRequest.Token = requestData.OAuthToken;
				oauthRequest.TokenSecret = requestData.OAuthTokenSecret;
			}

			return oauthRequest.GetAuthorizationHeader(parameters);
		}
Beispiel #47
-1
 public object getApiInfo()
 {
     OAuthRequest client = new OAuthRequest()
     {
         Method = "GET",
         Type = OAuthRequestType.ProtectedResource,
         SignatureMethod = OAuthSignatureMethod.HmacSha1,
         ConsumerKey = this.consumerKey,
         ConsumerSecret = this.consumerSecret,
         RequestUrl = "https://api.shapeways.com/api/v1",
         Version = "1.0a",
         Realm = "shapeways.com",
         TokenSecret = this.OAuthSecret,
         Token = this.OAuthToken,
     };
     string auth = client.GetAuthorizationQuery();
     string requestUrl = client.RequestUrl + "?" + auth;
     HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUrl);
     HttpWebResponse response = (HttpWebResponse)request.GetResponse();
     string content = new StreamReader(response.GetResponseStream()).ReadToEnd();
     return JsonConvert.DeserializeObject(content);
 }
Beispiel #48
-1
        protected override void UpdateHeaders(HttpClient client, string url)
        {
            if (url.Contains(OSM_ADDRESS) == false)
            {
                return;
            }

            var request = new OAuthRequest
            {
                ConsumerKey = "H5Us9nv9eDyFpKbBTiURf7ZqfdBArNddv10n6R6U",
                ConsumerSecret = "ccYaQUKLz26XEzbNd8uWoQ6HwbcnrUUp8milXnXG",
                Token = _tokenAndSecret.Token,
                TokenSecret = _tokenAndSecret.TokenSecret,
                Type = OAuthRequestType.ProtectedResource,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                RequestUrl = url,
                Version = "1.0",
                Method = "GET"
            };
            var auth = request.GetAuthorizationHeader().Replace("OAuth ", "");
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("OAuth", auth);
        }
        private static void AddAuthorizationHeaderParameters(OAuthRequest request, string authorizationHeader)
        {
            if (string.IsNullOrEmpty(authorizationHeader))
            {
                throw new ArgumentNullException("authorizationHeader");
            }

            var authorizationParametersMatch = OAuthHeaderRegex.Match(authorizationHeader);
            if (!authorizationParametersMatch.Success)
            {
                throw new ArgumentException("Invalid OAuth HTTP authorization header value. Must begin with \"OAuth\"");
            }

            var authorizationParametersValue = authorizationParametersMatch.Groups[1].Value;
            var authorizationParameterMatches = OAuthHeaderParameterRegex.Matches(authorizationParametersValue);

            foreach (var oauthParameterMatch in authorizationParameterMatches.Cast<Match>().Where(x => x.Success))
            {
                var key = oauthParameterMatch.Groups[1].Value;
                var value = oauthParameterMatch.Groups[2].Value;

                request.AddHeaderParameter(key, value);
            }
        }
Beispiel #50
-1
        // bbax: oAuth step 1: request_token
        private HttpWebResponse RequestToken(OAuthRequest client)
        {
            // Using HTTP header authorization
            var auth = client.GetAuthorizationHeader();
            var request = (HttpWebRequest)WebRequest.Create(client.RequestUrl);

            request.Headers.Add("Authorization", auth);
            var response = (HttpWebResponse)request.GetResponse();

            if (response == null)
            {
                throw new AcsApiException(AcsApiError.CouldNotAuthToken);
            }
            InvokeLog("Client token " + response);
            return response;
        }
Beispiel #51
-1
        public static OAuthRequest ForClientAuthentication(string consumerKey, string consumerSecret, string username, string password)
        {
            var credentials = new OAuthRequest
            {
                Method = "GET",
                Type = OAuthRequestType.ClientAuthentication,
                SignatureMethod = OAuthSignatureMethod.HmacSha1,
                SignatureTreatment = OAuthSignatureTreatment.Escaped,
                ConsumerKey = consumerKey,
                ConsumerSecret = consumerSecret,
                ClientUsername = username,
                ClientPassword = password
            };

            return credentials;
        }
Beispiel #52
-1
        private HttpWebRequest Login(OAuthRequest client, string responseCookies, Hashtable fields)
        {
            client.Token = fields[OauthTokenKey].ToString();
            client.TokenSecret = fields[OauthTokenSecretKey].ToString();

            InvokeLog("Token and Sec: " + client.Token + " : " + client.TokenSecret);

            var ascii = new ASCIIEncoding();
            var postData =
                ascii.GetBytes("j_username="******"&j_password="******"POST";
            myHttpWebRequest.AllowAutoRedirect = false;
            myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";
            myHttpWebRequest.ContentLength = postData.Length;
            myHttpWebRequest.CookieContainer = new CookieContainer();

            CookieCollection newRequiredCookies = new CookieCollection();
            try
            {
                newRequiredCookies = AcsApiSetCookieHeaderParser.GetAllCookiesFromHeader(responseCookies,
                    new Uri(serviceConfig.ServerRoot).Host);
            }
            catch (Exception e)
            {
                throw new AcsApiException("Could not parse cookie for final request!");
            }
            RefreshCookies(newRequiredCookies, myHttpWebRequest);

            using (var requestStream = myHttpWebRequest.GetRequestStream())
            {
                requestStream.Write(postData, 0, postData.Length);
                requestStream.Close();
            }
            return myHttpWebRequest;
        }