Exemple #1
0
 /// <summary>
 /// Creates an instance of HttpLiveClient with
 /// the Live ID username and password.
 /// </summary>
 /// <param name="username">Live ID username</param>
 /// <param name="password">Live ID password</param>
 public HttpLiveClient(string username, SecureString password)
 {
     this.username  = username;
     this.password  = password;
     this.challenge = null;
     this.liveAuth  = Utility.GetLiveIdAuth();
 }
Exemple #2
0
 /// <summary>
 /// If there is a cached challenge, it adds an authorization
 /// header to the argument HTTP Request headers containing the
 /// challenge response.
 /// </summary>
 /// <param name="headers">HTTP Request headers</param>
 public void SetAuthorization(WebHeaderCollection headers)
 {
     if (!String.IsNullOrEmpty(this.challenge))
     {
         LiveIdAuthentication.AddAuthorizationHeaderToRequestHeaders(
             headers, this.liveAuth.GetResponseForHttpChallenge(this.challenge));
     }
 }
Exemple #3
0
 public bool ProcessWebException(WebException ex)
 {
     this.challenge = LiveIdAuthentication.GetChallengeFromWebException(ex);
     if (String.IsNullOrEmpty(this.challenge))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Exemple #4
0
        /// <summary>
        /// Executes an HTTP request ensuring login
        /// is done before the request is executed.
        /// If a WebException occurs containing a valid
        /// challenge, the request is attempted again.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="func"></param>
        /// <returns></returns>
        private T ExecuteRequest <T>(Func <T> func)
        {
            this.EnsureLogin();

            try
            {
                return(func());
            }
            catch (WebException ex)
            {
                this.challenge = LiveIdAuthentication.GetChallengeFromWebException(ex);
                if (String.IsNullOrEmpty(this.challenge))
                {
                    throw;
                }
            }

            return(func());
        }