コード例 #1
0
        /// <summary>
        /// Create the info section for the cast call.
        /// </summary>
        /// <returns>The infor section.</returns>
        internal XElement CreateCastCallInfoSection()
        {
            XElement content = new XElement("content",
                                            new XElement("app-id", AppIdInstance.ToString()),
                                            new XElement("hmac", "HMACSHA256"),
                                            new XElement("signing-time", DateTime.UtcNow.ToString("O"))
                                            );

            XElement outer = new XElement("outer", content);

            XmlReader reader = outer.CreateReader();

            reader.MoveToContent();
            string s = reader.ReadInnerXml();

            s = CHBaseService.GetOuterXml(content);

            string hmac = MobilePlatform.ComputeSha256Hmac(Convert.FromBase64String(SharedSecret), s);

            XElement info = new XElement("info",
                                         new XElement("auth-info",
                                                      new XElement("app-id", AppIdInstance.ToString()),
                                                      new XElement("credential",
                                                                   new XElement("appserver2",
                                                                                new XElement("hmacSig", hmac,
                                                                                             new XAttribute("algName", "HMACSHA256")
                                                                                             ),
                                                                                content
                                                                                )
                                                                   )
                                                      )
                                         );

            return(info);
        }
コード例 #2
0
 /// <summary>
 /// Check that the application is authenticated.
 /// </summary>
 /// <param name="service">The service.</param>
 /// <param name="authenticationCompleted">Completion handler.</param>
 /// <param name="shellAuthRequired">Handler if shell authorization is required.</param>
 public static void BeginAuthenticationCheck(
     CHBaseService service,
     EventHandler<CHBaseResponseEventArgs> authenticationCompleted,
     EventHandler<CHBaseResponseEventArgs> shellAuthRequired)
 {
     AuthenticationCheckState state = new AuthenticationCheckState(service, authenticationCompleted, shellAuthRequired);
     BeginAuthenticationCheck(state);
 }
コード例 #3
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(
            CHBaseService service,
            EventHandler<CHBaseResponseEventArgs> authenticationCompleted,
            EventHandler<CHBaseResponseEventArgs> shellAuthRequired)
        {
            AuthenticationCheckState state = new AuthenticationCheckState(service, authenticationCompleted, shellAuthRequired);

            state.ShellAuthRequiredHandler(null, null);
        }
コード例 #4
0
        /// <summary>
        /// Check that the application is authenticated.
        /// </summary>
        /// <param name="service">The service.</param>
        /// <param name="authenticationCompleted">Completion handler.</param>
        /// <param name="shellAuthRequired">Handler if shell authorization is required.</param>
        public static void BeginAuthenticationCheck(
            CHBaseService service,
            EventHandler <CHBaseResponseEventArgs> authenticationCompleted,
            EventHandler <CHBaseResponseEventArgs> shellAuthRequired)
        {
            AuthenticationCheckState state = new AuthenticationCheckState(service, authenticationCompleted, shellAuthRequired);

            BeginAuthenticationCheck(state);
        }
コード例 #5
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(
            CHBaseService service,
            EventHandler <CHBaseResponseEventArgs> authenticationCompleted,
            EventHandler <CHBaseResponseEventArgs> shellAuthRequired)
        {
            AuthenticationCheckState state = new AuthenticationCheckState(service, authenticationCompleted, shellAuthRequired);

            state.ShellAuthRequiredHandler(null, null);
        }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the AuthenticationCheckState class.
 /// </summary>
 /// <param name="service">The service.</param>
 /// <param name="authenticationCompleted">Completion handler.</param>
 /// <param name="shellAuthRequired">Authorization required handler.</param>
 public AuthenticationCheckState(
     CHBaseService service,
     EventHandler <CHBaseResponseEventArgs> authenticationCompleted,
     EventHandler <CHBaseResponseEventArgs> shellAuthRequired)
 {
     Service = service;
     AuthenticationCompletedHandler = authenticationCompleted;
     ShellAuthRequiredHandler       = shellAuthRequired;
 }
コード例 #7
0
        /// <summary>
        /// Process the list of authorized people and continue the flow.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The event arguments.</param>
        private static void GetAuthorizedPeopleCompleted(object sender, CHBaseResponseEventArgs e)
        {
            AuthenticationCheckState state = (AuthenticationCheckState)e.Request.UserState;

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

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

            XElement responseResults = response.Descendants("response-results").Single();

            state.Service.Records.Clear();

            foreach (XElement personInfo in responseResults.Elements("person-info"))
            {
                Guid   personId   = new Guid(personInfo.Element("person-id").Value);
                string personName = personInfo.Element("name").Value;

                // If we loaded our settings, the current record is incomplete. We will try
                // to match it to one that we got back...
                CHBaseRecord currentRecord = state.Service.CurrentRecord;
                state.Service.CurrentRecord = null;

                foreach (XElement recordNode in personInfo.Elements("record"))
                {
                    CHBaseRecord record = CHBaseRecord.Create(personId, personName, CHBaseService.GetOuterXml(recordNode));
                    if (record != null)
                    {
                        state.Service.Records.Add(record);

                        if ((currentRecord != null) &&
                            (currentRecord.PersonId == record.PersonId) &&
                            (currentRecord.RecordId == record.RecordId))
                        {
                            state.Service.CurrentRecord = record;
                        }
                    }
                }
            }

            if (state.Service.Records.Count != 0)
            {
                // all done
                state.AuthenticationCompletedHandler(state.Service, null);
            }
            else
            {
                // unsuccessful, restart from scratch...
                state.Service.ClearProvisioningInformation();
                BeginAuthenticationCheck(state);
            }
        }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the AuthenticationCheckState class.
 /// </summary>
 /// <param name="service">The service.</param>
 /// <param name="authenticationCompleted">Completion handler.</param>
 /// <param name="shellAuthRequired">Authorization required handler.</param>
 public AuthenticationCheckState(
     CHBaseService service,
     EventHandler<CHBaseResponseEventArgs> authenticationCompleted,
     EventHandler<CHBaseResponseEventArgs> shellAuthRequired)
 {
     Service = service;
     AuthenticationCompletedHandler = authenticationCompleted;
     ShellAuthRequiredHandler = shellAuthRequired;
 }
コード例 #9
0
 // Code to execute when the application is launching (eg, from Start)
 // This code will not execute when the application is reactivated
 private void Application_Launching(object sender, LaunchingEventArgs e)
 {
     HealthVaultService = new CHBaseService(platformUrl, shellUrl, new Guid(masterAppId));
 }