/// <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); }
/// <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); } }