aboutsummaryrefslogtreecommitdiff
path: root/src/wixext/HttpCompiler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/wixext/HttpCompiler.cs')
-rw-r--r--src/wixext/HttpCompiler.cs114
1 files changed, 53 insertions, 61 deletions
diff --git a/src/wixext/HttpCompiler.cs b/src/wixext/HttpCompiler.cs
index c694ccde..094f5594 100644
--- a/src/wixext/HttpCompiler.cs
+++ b/src/wixext/HttpCompiler.cs
@@ -1,26 +1,20 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. 1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2 2
3namespace WixToolset.Extensions 3namespace WixToolset.Http
4{ 4{
5 using System; 5 using System;
6 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.Globalization;
8 using System.Xml.Linq; 7 using System.Xml.Linq;
9 using WixToolset.Data; 8 using WixToolset.Data;
10 using WixToolset.Extensibility; 9 using WixToolset.Extensibility;
10 using WixToolset.Http.Tuples;
11 11
12 /// <summary> 12 /// <summary>
13 /// The compiler for the WiX Toolset Http Extension. 13 /// The compiler for the WiX Toolset Http Extension.
14 /// </summary> 14 /// </summary>
15 public sealed class HttpCompiler : CompilerExtension 15 public sealed class HttpCompiler : BaseCompilerExtension
16 { 16 {
17 /// <summary> 17 public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/http";
18 /// Instantiate a new HttpCompiler.
19 /// </summary>
20 public HttpCompiler()
21 {
22 this.Namespace = "http://wixtoolset.org/schemas/v4/wxs/http";
23 }
24 18
25 /// <summary> 19 /// <summary>
26 /// Processes an element for the Compiler. 20 /// Processes an element for the Compiler.
@@ -29,7 +23,7 @@ namespace WixToolset.Extensions
29 /// <param name="parentElement">Parent element of element to process.</param> 23 /// <param name="parentElement">Parent element of element to process.</param>
30 /// <param name="element">Element to process.</param> 24 /// <param name="element">Element to process.</param>
31 /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param> 25 /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
32 public override void ParseElement(XElement parentElement, XElement element, IDictionary<string, string> context) 26 public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context)
33 { 27 {
34 switch (parentElement.Name.LocalName) 28 switch (parentElement.Name.LocalName)
35 { 29 {
@@ -41,10 +35,10 @@ namespace WixToolset.Extensions
41 switch (element.Name.LocalName) 35 switch (element.Name.LocalName)
42 { 36 {
43 case "UrlReservation": 37 case "UrlReservation":
44 this.ParseUrlReservationElement(element, serviceComponentId, serviceUser); 38 this.ParseUrlReservationElement(intermediate, section, element, serviceComponentId, serviceUser);
45 break; 39 break;
46 default: 40 default:
47 this.Core.UnexpectedElement(parentElement, element); 41 this.ParseHelper.UnexpectedElement(parentElement, element);
48 break; 42 break;
49 } 43 }
50 break; 44 break;
@@ -54,15 +48,15 @@ namespace WixToolset.Extensions
54 switch (element.Name.LocalName) 48 switch (element.Name.LocalName)
55 { 49 {
56 case "UrlReservation": 50 case "UrlReservation":
57 this.ParseUrlReservationElement(element, componentId, null); 51 this.ParseUrlReservationElement(intermediate, section, element, componentId, null);
58 break; 52 break;
59 default: 53 default:
60 this.Core.UnexpectedElement(parentElement, element); 54 this.ParseHelper.UnexpectedElement(parentElement, element);
61 break; 55 break;
62 } 56 }
63 break; 57 break;
64 default: 58 default:
65 this.Core.UnexpectedElement(parentElement, element); 59 this.ParseHelper.UnexpectedElement(parentElement, element);
66 break; 60 break;
67 } 61 }
68 } 62 }
@@ -73,9 +67,9 @@ namespace WixToolset.Extensions
73 /// <param name="node">The element to parse.</param> 67 /// <param name="node">The element to parse.</param>
74 /// <param name="componentId">Identifier of the component that owns this URL reservation.</param> 68 /// <param name="componentId">Identifier of the component that owns this URL reservation.</param>
75 /// <param name="securityPrincipal">The security principal of the parent element (null if nested under Component).</param> 69 /// <param name="securityPrincipal">The security principal of the parent element (null if nested under Component).</param>
76 private void ParseUrlReservationElement(XElement node, string componentId, string securityPrincipal) 70 private void ParseUrlReservationElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId, string securityPrincipal)
77 { 71 {
78 SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); 72 SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node);
79 Identifier id = null; 73 Identifier id = null;
80 int handleExisting = HttpConstants.heReplace; 74 int handleExisting = HttpConstants.heReplace;
81 string handleExistingValue = null; 75 string handleExistingValue = null;
@@ -90,10 +84,10 @@ namespace WixToolset.Extensions
90 switch (attrib.Name.LocalName) 84 switch (attrib.Name.LocalName)
91 { 85 {
92 case "Id": 86 case "Id":
93 id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); 87 id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib);
94 break; 88 break;
95 case "HandleExisting": 89 case "HandleExisting":
96 handleExistingValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 90 handleExistingValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
97 switch (handleExistingValue) 91 switch (handleExistingValue)
98 { 92 {
99 case "replace": 93 case "replace":
@@ -106,31 +100,31 @@ namespace WixToolset.Extensions
106 handleExisting = HttpConstants.heFail; 100 handleExisting = HttpConstants.heFail;
107 break; 101 break;
108 default: 102 default:
109 this.Core.OnMessage(WixErrors.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "HandleExisting", handleExistingValue, "replace", "ignore", "fail")); 103 this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "HandleExisting", handleExistingValue, "replace", "ignore", "fail"));
110 break; 104 break;
111 } 105 }
112 break; 106 break;
113 case "Sddl": 107 case "Sddl":
114 sddl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 108 sddl = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
115 break; 109 break;
116 case "Url": 110 case "Url":
117 url = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 111 url = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
118 break; 112 break;
119 default: 113 default:
120 this.Core.UnexpectedAttribute(node, attrib); 114 this.ParseHelper.UnexpectedAttribute(node, attrib);
121 break; 115 break;
122 } 116 }
123 } 117 }
124 else 118 else
125 { 119 {
126 this.Core.ParseExtensionAttribute(node, attrib); 120 this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib);
127 } 121 }
128 } 122 }
129 123
130 // Need the element ID for child element processing, so generate now if not authored. 124 // Need the element ID for child element processing, so generate now if not authored.
131 if (null == id) 125 if (null == id)
132 { 126 {
133 id = this.Core.CreateIdentifier("url", componentId, securityPrincipal, url); 127 id = this.ParseHelper.CreateIdentifier("url", componentId, securityPrincipal, url);
134 } 128 }
135 129
136 // Parse UrlAce children. 130 // Parse UrlAce children.
@@ -143,57 +137,56 @@ namespace WixToolset.Extensions
143 case "UrlAce": 137 case "UrlAce":
144 if (null != sddl) 138 if (null != sddl)
145 { 139 {
146 this.Core.OnMessage(WixErrors.IllegalParentAttributeWhenNested(sourceLineNumbers, "UrlReservation", "Sddl", "UrlAce")); 140 this.Messaging.Write(ErrorMessages.IllegalParentAttributeWhenNested(sourceLineNumbers, "UrlReservation", "Sddl", "UrlAce"));
147 } 141 }
148 else 142 else
149 { 143 {
150 foundACE = true; 144 foundACE = true;
151 this.ParseUrlAceElement(child, id.Id, securityPrincipal); 145 this.ParseUrlAceElement(intermediate, section, child, id.Id, securityPrincipal);
152 } 146 }
153 break; 147 break;
154 default: 148 default:
155 this.Core.UnexpectedElement(node, child); 149 this.ParseHelper.UnexpectedElement(node, child);
156 break; 150 break;
157 } 151 }
158 } 152 }
159 else 153 else
160 { 154 {
161 this.Core.ParseExtensionElement(node, child); 155 this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, node, child);
162 } 156 }
163 } 157 }
164 158
165 // Url is required. 159 // Url is required.
166 if (null == url) 160 if (null == url)
167 { 161 {
168 this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Url")); 162 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Url"));
169 } 163 }
170 164
171 // Security is required. 165 // Security is required.
172 if (null == sddl && !foundACE) 166 if (null == sddl && !foundACE)
173 { 167 {
174 this.Core.OnMessage(HttpErrors.NoSecuritySpecified(sourceLineNumbers)); 168 this.Messaging.Write(HttpErrors.NoSecuritySpecified(sourceLineNumbers));
175 } 169 }
176 170
177 if (!this.Core.EncounteredError) 171 if (!this.Messaging.EncounteredError)
178 { 172 {
179 Row row = this.Core.CreateRow(sourceLineNumbers, "WixHttpUrlReservation"); 173 var row = (WixHttpUrlReservationTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixHttpUrlReservation", id);
180 row[0] = id.Id; 174 row.HandleExisting = handleExisting;
181 row[1] = handleExisting; 175 row.Sddl = sddl;
182 row[2] = sddl; 176 row.Url = url;
183 row[3] = url; 177 row.Component_ = componentId;
184 row[4] = componentId;
185 178
186 if (this.Core.CurrentPlatform == Platform.ARM) 179 if (this.Context.Platform == Platform.ARM)
187 { 180 {
188 // Ensure ARM version of the CA is referenced. 181 // Ensure ARM version of the CA is referenced.
189 this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "WixSchedHttpUrlReservationsInstall_ARM"); 182 this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedHttpUrlReservationsInstall_ARM");
190 this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "WixSchedHttpUrlReservationsUninstall_ARM"); 183 this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedHttpUrlReservationsUninstall_ARM");
191 } 184 }
192 else 185 else
193 { 186 {
194 // All other supported platforms use x86. 187 // All other supported platforms use x86.
195 this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "WixSchedHttpUrlReservationsInstall"); 188 this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedHttpUrlReservationsInstall");
196 this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "WixSchedHttpUrlReservationsUninstall"); 189 this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedHttpUrlReservationsUninstall");
197 } 190 }
198 } 191 }
199 } 192 }
@@ -204,9 +197,9 @@ namespace WixToolset.Extensions
204 /// <param name="node">The element to parse.</param> 197 /// <param name="node">The element to parse.</param>
205 /// <param name="urlReservationId">The URL reservation ID.</param> 198 /// <param name="urlReservationId">The URL reservation ID.</param>
206 /// <param name="defaultSecurityPrincipal">The default security principal.</param> 199 /// <param name="defaultSecurityPrincipal">The default security principal.</param>
207 private void ParseUrlAceElement(XElement node, string urlReservationId, string defaultSecurityPrincipal) 200 private void ParseUrlAceElement(Intermediate intermediate, IntermediateSection section, XElement node, string urlReservationId, string defaultSecurityPrincipal)
208 { 201 {
209 SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); 202 SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node);
210 Identifier id = null; 203 Identifier id = null;
211 string securityPrincipal = defaultSecurityPrincipal; 204 string securityPrincipal = defaultSecurityPrincipal;
212 int rights = HttpConstants.GENERIC_ALL; 205 int rights = HttpConstants.GENERIC_ALL;
@@ -219,13 +212,13 @@ namespace WixToolset.Extensions
219 switch (attrib.Name.LocalName) 212 switch (attrib.Name.LocalName)
220 { 213 {
221 case "Id": 214 case "Id":
222 id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); 215 id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib);
223 break; 216 break;
224 case "SecurityPrincipal": 217 case "SecurityPrincipal":
225 securityPrincipal = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 218 securityPrincipal = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
226 break; 219 break;
227 case "Rights": 220 case "Rights":
228 rightsValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 221 rightsValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
229 switch (rightsValue) 222 switch (rightsValue)
230 { 223 {
231 case "all": 224 case "all":
@@ -238,42 +231,41 @@ namespace WixToolset.Extensions
238 rights = HttpConstants.GENERIC_EXECUTE; 231 rights = HttpConstants.GENERIC_EXECUTE;
239 break; 232 break;
240 default: 233 default:
241 this.Core.OnMessage(WixErrors.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Rights", rightsValue, "all", "delegate", "register")); 234 this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Rights", rightsValue, "all", "delegate", "register"));
242 break; 235 break;
243 } 236 }
244 break; 237 break;
245 default: 238 default:
246 this.Core.UnexpectedAttribute(node, attrib); 239 this.ParseHelper.UnexpectedAttribute(node, attrib);
247 break; 240 break;
248 } 241 }
249 } 242 }
250 else 243 else
251 { 244 {
252 this.Core.ParseExtensionAttribute(node, attrib); 245 this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib);
253 } 246 }
254 } 247 }
255 248
256 // Generate Id now if not authored. 249 // Generate Id now if not authored.
257 if (null == id) 250 if (null == id)
258 { 251 {
259 id = this.Core.CreateIdentifier("ace", urlReservationId, securityPrincipal, rightsValue); 252 id = this.ParseHelper.CreateIdentifier("ace", urlReservationId, securityPrincipal, rightsValue);
260 } 253 }
261 254
262 this.Core.ParseForExtensionElements(node); 255 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node);
263 256
264 // SecurityPrincipal is required. 257 // SecurityPrincipal is required.
265 if (null == securityPrincipal) 258 if (null == securityPrincipal)
266 { 259 {
267 this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "SecurityPrincipal")); 260 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "SecurityPrincipal"));
268 } 261 }
269 262
270 if (!this.Core.EncounteredError) 263 if (!this.Messaging.EncounteredError)
271 { 264 {
272 Row row = this.Core.CreateRow(sourceLineNumbers, "WixHttpUrlAce"); 265 var row = (WixHttpUrlAceTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixHttpUrlAce", id);
273 row[0] = id.Id; 266 row.WixHttpUrlReservation_ = urlReservationId;
274 row[1] = urlReservationId; 267 row.SecurityPrincipal = securityPrincipal;
275 row[2] = securityPrincipal; 268 row.Rights = rights;
276 row[3] = rights;
277 } 269 }
278 } 270 }
279 } 271 }