private static string SerializeSOAPEnvelope(CSOAPCommon.Envelope envelope) { if (envelope == null) { return(string.Empty); } var xmlSerializer = new XmlSerializer(typeof(CSOAPCommon.Envelope)); XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("s", "http://www.w3.org/2003/05/soap-envelope"); ns.Add("a", "http://www.w3.org/2005/08/addressing"); using (var stringWriter = new StringWriter()) { using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings { Indent = true })) { xmlSerializer.Serialize(xmlWriter, envelope, ns); return(stringWriter.ToString().Replace("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n", "")); } } }
private static async Task <(CGetExtendedUpdateInfoResponse.GetExtendedUpdateInfoResponse, string)> GetExtendedUpdateInfo( CSOAPCommon.Cookie cookie, string token, string[] revisionId, CTAC ctac) { CSOAPCommon.Envelope envelope = GetEnveloppe("GetExtendedUpdateInfo", token, false); envelope.Body.GetExtendedUpdateInfo = new CGetExtendedUpdateInfoRequest.GetExtendedUpdateInfo() { Cookie = cookie, RevisionIDs = new CGetExtendedUpdateInfoRequest.RevisionIDs() { Int = revisionId }, InfoTypes = new CSOAPCommon.InfoTypes() { XmlUpdateFragmentType = new string[] { "FileUrl", "FileDecryption", "Extended", "LocalizedProperties", "Eula", "Published", "Core", "VerificationRule" } }, Locales = new CSOAPCommon.Locales() { String = new string[] { "en-US", "en" } }, DeviceAttributes = ctac.DeviceAttributes }; string message = SerializeSOAPEnvelope(envelope); string response = await PostToWindowsUpdateAsync("GetCookie", message, false); CSOAPCommon.Envelope renvelope = DeserializeSOAPEnvelope(response); return(renvelope.Body.GetExtendedUpdateInfoResponse, response); }
private static async Task <(CGetExtendedUpdateInfo2Response.GetExtendedUpdateInfo2Response, string)> GetExtendedUpdateInfo2( string token, string UpdateID, string RevisionNumber, CTAC ctac ) { CSOAPCommon.Envelope envelope = GetEnveloppe("GetExtendedUpdateInfo2", token, true); envelope.Body.GetExtendedUpdateInfo2 = new CGetExtendedUpdateInfo2Request.GetExtendedUpdateInfo2() { UpdateIDs = new CGetExtendedUpdateInfo2Request.UpdateIDs() { UpdateIdentity = new CGetExtendedUpdateInfo2Request.UpdateIdentity() { UpdateID = UpdateID, RevisionNumber = RevisionNumber } }, InfoTypes = new CSOAPCommon.InfoTypes() { XmlUpdateFragmentType = new string[] { "FileUrl", "FileDecryption", "EsrpDecryptionInformation", "PiecesHashUrl", "BlockMapUrl" } }, DeviceAttributes = ctac.DeviceAttributes }; string message = SerializeSOAPEnvelope(envelope); string response = await PostToWindowsUpdateAsync("GetExtendedUpdateInfo2", message, true); CSOAPCommon.Envelope renvelope = DeserializeSOAPEnvelope(response); return(renvelope.Body.GetExtendedUpdateInfo2Response, response); }
private static async Task <(CGetCookieResponse.GetCookieResponse, string)> GetCookie() { CSOAPCommon.Envelope envelope = GetEnveloppe("GetCookie", null, false); envelope.Body.GetCookie = new CGetCookieRequest.GetCookie() { OldCookie = new CGetCookieRequest.OldCookie() { Expiration = Constants.OldCookieExpiration }, LastChange = Constants.LastChangeDate, CurrentTime = DateTime.Now.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"), ProtocolVersion = Constants.ClientProtocolVersion }; string message = SerializeSOAPEnvelope(envelope); string response = await PostToWindowsUpdateAsync("GetCookie", message, false); CSOAPCommon.Envelope renvelope = DeserializeSOAPEnvelope(response); return(renvelope.Body.GetCookieResponse, response); }
private static CSOAPCommon.Envelope GetEnveloppe(string method, string authorizationToken, bool secured) { string _endpoint = Constants.Endpoint; if (secured) { _endpoint += "/secured"; } CSOAPCommon.Envelope envelope = new CSOAPCommon.Envelope() { Header = new CSOAPCommon.Header() { Action = new CSOAPCommon.Action() { MustUnderstand = "1", Text = Constants.Action + method }, MessageID = $"urn:uuid:{Guid.NewGuid().ToString("D")}", To = new CSOAPCommon.To() { MustUnderstand = "1", Text = _endpoint }, Security = new CSOAPCommon.Security() { MustUnderstand = "1", Timestamp = new CSOAPCommon.Timestamp() { Created = DateTime.Now.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"), Expires = Constants.SecurityExpirationTimestamp }, WindowsUpdateTicketsToken = new CSOAPCommon.WindowsUpdateTicketsToken() { Id = "ClientMSA" } } }, Body = new CSOAPCommon.Body() { } }; if (!string.IsNullOrEmpty(authorizationToken)) { envelope.Header.Security.WindowsUpdateTicketsToken.TicketType = new CSOAPCommon.TicketType[] { new CSOAPCommon.TicketType() { Name = "MSA", Version = "1.0", Policy = "MBI_SSL", User = authorizationToken }, new CSOAPCommon.TicketType() { Name = "AAD", Version = "1.0", Policy = "MBI_SSL" } }; } else { envelope.Header.Security.WindowsUpdateTicketsToken.Text = ""; } return(envelope); }
private static async Task <(CSyncUpdatesResponse.SyncUpdatesResponse, string)> SyncUpdates( CSOAPCommon.Cookie cookie, string token, IEnumerable <string> InstalledNonLeafUpdateIDs, IEnumerable <string> OtherCachedUpdateIDs, string[] CategoryIdentifiers, CTAC ctac ) { string[] _InstalledNonLeafUpdateIDs = Constants.InstalledNonLeafUpdateIDs.Select(x => x.ToString()).ToArray(); if (InstalledNonLeafUpdateIDs != null) { var tmplist = _InstalledNonLeafUpdateIDs.ToList(); tmplist.AddRange(InstalledNonLeafUpdateIDs); _InstalledNonLeafUpdateIDs = tmplist.ToArray(); } CSOAPCommon.Envelope envelope = GetEnveloppe("SyncUpdates", token, false); envelope.Body.SyncUpdates = new CSyncUpdatesRequest.SyncUpdates() { Cookie = cookie, Parameters = new CSyncUpdatesRequest.Parameters() { ExpressQuery = "false", InstalledNonLeafUpdateIDs = new CSyncUpdatesRequest.InstalledNonLeafUpdateIDs() { Int = _InstalledNonLeafUpdateIDs }, OtherCachedUpdateIDs = new CSyncUpdatesRequest.OtherCachedUpdateIDs() { Int = OtherCachedUpdateIDs != null?OtherCachedUpdateIDs.ToArray() : new string[0] }, SkipSoftwareSync = "false", NeedTwoGroupOutOfScopeUpdates = "true", FilterAppCategoryIds = CategoryIdentifiers != null && CategoryIdentifiers.Length != 0 ? new CSyncUpdatesRequest.FilterAppCategoryIds() { CategoryIdentifier = new CSyncUpdatesRequest.CategoryIdentifier() { Id = CategoryIdentifiers != null ? CategoryIdentifiers : new string[0] } } : null, AlsoPerformRegularSync = "false", ComputerSpec = "", ExtendedUpdateInfoParameters = new CSyncUpdatesRequest.ExtendedUpdateInfoParameters() { XmlUpdateFragmentTypes = new CSyncUpdatesRequest.XmlUpdateFragmentTypes() { XmlUpdateFragmentType = new string[] { "Extended", "LocalizedProperties", "Eula", "Published", "Core" } }, Locales = new CSOAPCommon.Locales() { String = new string[] { "en-US", "en" } } }, ClientPreferredLanguages = "", ProductsParameters = new CSyncUpdatesRequest.ProductsParameters() { SyncCurrentVersionOnly = ctac.SyncCurrentVersionOnly ? "true" : "false", DeviceAttributes = ctac.DeviceAttributes, CallerAttributes = ctac.CallerAttributes, Products = ctac.Products } } }; string message = SerializeSOAPEnvelope(envelope); string response = await PostToWindowsUpdateAsync("SyncUpdates", message, false); CSOAPCommon.Envelope renvelope = DeserializeSOAPEnvelope(response); return(renvelope.Body.SyncUpdatesResponse, response); }