/// <summary>
        /// Authorize other records.
        /// </summary>
        /// <param name="service">The HealthVaultService instance.</param>
        /// <param name="authenticationCompleted">Handler to call when finished.</param>
        /// <param name="shellAuthRequired">Handler to call for authorization.</param>
        public static void BeginAuthorizeRecords(
            CHBaseService service,
            EventHandler<CHBaseResponseEventArgs> authenticationCompleted,
            EventHandler<CHBaseResponseEventArgs> shellAuthRequired)
        {
            AuthenticationCheckState state = new AuthenticationCheckState(service, authenticationCompleted, shellAuthRequired);

            state.ShellAuthRequiredHandler(null, null);
        }
Beispiel #2
0
        /// <summary>
        /// Authorize other records.
        /// </summary>
        /// <param name="service">The HealthVaultService instance.</param>
        /// <param name="authenticationCompleted">Handler to call when finished.</param>
        /// <param name="shellAuthRequired">Handler to call for authorization.</param>
        public static void BeginAuthorizeRecords(
            HealthVaultService service,
            EventHandler <HealthVaultResponseEventArgs> authenticationCompleted,
            EventHandler <HealthVaultResponseEventArgs> shellAuthRequired)
        {
            AuthenticationCheckState state = new AuthenticationCheckState(service, authenticationCompleted, shellAuthRequired);

            state.ShellAuthRequiredHandler(null, null);
        }
Beispiel #3
0
        /// <summary>
        /// Handle the response from the CAST call and continue the flow.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The event arguments.</param>
        private static void CastCallCompleted(object sender, HealthVaultResponseEventArgs e)
        {
            AuthenticationCheckState state = (AuthenticationCheckState)e.Request.UserState;

            if (e.ErrorCode == ErrorInvalidApp)
            {
                state.Service.SharedSecret  = null;     // force creation of app from scratch...
                state.Service.AppIdInstance = Guid.Empty;
            }
            else if (e.ErrorText != null)
            {
                state.ShellAuthRequiredHandler(state.Service, e);
                return;
            }
            else
            {
                state.Service.SaveCastCallResults(e.ResponseXml);
            }

            BeginAuthenticationCheck(state);
        }
Beispiel #4
0
        /// <summary>
        /// Save the new application info and continue the process.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The event arguments.</param>
        private static void NewApplicationCreationInfoCompleted(object sender, HealthVaultResponseEventArgs e)
        {
            AuthenticationCheckState state = (AuthenticationCheckState)e.Request.UserState;

            if (e.ErrorText != null)
            {
                state.AuthenticationCompletedHandler(state.Service, e);
                return;
            }

            XElement response = XElement.Parse(e.ResponseXml);

            XNamespace responseNamespace = "urn:com.microsoft.wc.methods.response.NewApplicationCreationInfo";
            XElement   info = response.Element(responseNamespace + "info");

            state.Service.AppIdInstance            = new Guid(info.Element("app-id").Value);
            state.Service.SharedSecret             = info.Element("shared-secret").Value;
            state.Service.ApplicationCreationToken = info.Element("app-token").Value;

            state.ShellAuthRequiredHandler(state.Service, e);
        }