diff options
Diffstat (limited to 'src/wixext')
| -rw-r--r-- | src/wixext/HttpCompiler.cs | 117 | ||||
| -rw-r--r-- | src/wixext/HttpTableDefinitions.cs | 18 | ||||
| -rw-r--r-- | src/wixext/Symbols/HttpSymbolDefinitions.cs | 4 | ||||
| -rw-r--r-- | src/wixext/Symbols/WixHttpSniSslCertSymbol.cs | 95 |
4 files changed, 234 insertions, 0 deletions
diff --git a/src/wixext/HttpCompiler.cs b/src/wixext/HttpCompiler.cs index cb217147..6c572470 100644 --- a/src/wixext/HttpCompiler.cs +++ b/src/wixext/HttpCompiler.cs | |||
| @@ -48,6 +48,10 @@ namespace WixToolset.Http | |||
| 48 | 48 | ||
| 49 | switch (element.Name.LocalName) | 49 | switch (element.Name.LocalName) |
| 50 | { | 50 | { |
| 51 | case "SniSslCertificate": | ||
| 52 | this.ParseSniSslCertificateElement(intermediate, section, element, componentId); | ||
| 53 | break; | ||
| 54 | |||
| 51 | case "UrlReservation": | 55 | case "UrlReservation": |
| 52 | this.ParseUrlReservationElement(intermediate, section, element, componentId, null); | 56 | this.ParseUrlReservationElement(intermediate, section, element, componentId, null); |
| 53 | break; | 57 | break; |
| @@ -63,6 +67,119 @@ namespace WixToolset.Http | |||
| 63 | } | 67 | } |
| 64 | 68 | ||
| 65 | /// <summary> | 69 | /// <summary> |
| 70 | /// Parses a SniSsl element. | ||
| 71 | /// </summary> | ||
| 72 | /// <param name="node">The element to parse.</param> | ||
| 73 | /// <param name="componentId">Identifier of the component that owns this SNI SSL Certificate.</param> | ||
| 74 | private void ParseSniSslCertificateElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId) | ||
| 75 | { | ||
| 76 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); | ||
| 77 | Identifier id = null; | ||
| 78 | string host = null; | ||
| 79 | string port = null; | ||
| 80 | string appId = null; | ||
| 81 | string store = null; | ||
| 82 | string thumbprint = null; | ||
| 83 | var handleExisting = HandleExisting.Replace; | ||
| 84 | string handleExistingValue = null; | ||
| 85 | |||
| 86 | foreach (var attrib in node.Attributes()) | ||
| 87 | { | ||
| 88 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | ||
| 89 | { | ||
| 90 | switch (attrib.Name.LocalName) | ||
| 91 | { | ||
| 92 | case "Id": | ||
| 93 | id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); | ||
| 94 | break; | ||
| 95 | case "AppId": | ||
| 96 | appId = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | ||
| 97 | break; | ||
| 98 | case "HandleExisting": | ||
| 99 | handleExistingValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | ||
| 100 | switch (handleExistingValue) | ||
| 101 | { | ||
| 102 | case "replace": | ||
| 103 | handleExisting = HandleExisting.Replace; | ||
| 104 | break; | ||
| 105 | case "ignore": | ||
| 106 | handleExisting = HandleExisting.Ignore; | ||
| 107 | break; | ||
| 108 | case "fail": | ||
| 109 | handleExisting = HandleExisting.Fail; | ||
| 110 | break; | ||
| 111 | default: | ||
| 112 | this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "HandleExisting", handleExistingValue, "replace", "ignore", "fail")); | ||
| 113 | break; | ||
| 114 | } | ||
| 115 | break; | ||
| 116 | case "Host": | ||
| 117 | host = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | ||
| 118 | break; | ||
| 119 | case "Port": | ||
| 120 | port = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | ||
| 121 | break; | ||
| 122 | case "Store": | ||
| 123 | store = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | ||
| 124 | break; | ||
| 125 | case "Thumbprint": | ||
| 126 | thumbprint = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | ||
| 127 | break; | ||
| 128 | default: | ||
| 129 | this.ParseHelper.UnexpectedAttribute(node, attrib); | ||
| 130 | break; | ||
| 131 | } | ||
| 132 | } | ||
| 133 | else | ||
| 134 | { | ||
| 135 | this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); | ||
| 136 | } | ||
| 137 | } | ||
| 138 | |||
| 139 | // Need the element ID for child element processing, so generate now if not authored. | ||
| 140 | if (null == id) | ||
| 141 | { | ||
| 142 | id = this.ParseHelper.CreateIdentifier("ssl", componentId, host, port); | ||
| 143 | } | ||
| 144 | |||
| 145 | // Required attributes. | ||
| 146 | if (null == host) | ||
| 147 | { | ||
| 148 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Host")); | ||
| 149 | } | ||
| 150 | |||
| 151 | if (null == port) | ||
| 152 | { | ||
| 153 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Port")); | ||
| 154 | } | ||
| 155 | |||
| 156 | if (null == thumbprint) | ||
| 157 | { | ||
| 158 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Thumbprint")); | ||
| 159 | } | ||
| 160 | |||
| 161 | // Parse unknown children. | ||
| 162 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); | ||
| 163 | |||
| 164 | if (!this.Messaging.EncounteredError) | ||
| 165 | { | ||
| 166 | section.AddSymbol(new WixHttpSniSslCertSymbol(sourceLineNumbers, id) | ||
| 167 | { | ||
| 168 | Host = host, | ||
| 169 | Port = port, | ||
| 170 | Thumbprint = thumbprint, | ||
| 171 | AppId = appId, | ||
| 172 | Store = store, | ||
| 173 | HandleExisting = handleExisting, | ||
| 174 | ComponentRef = componentId, | ||
| 175 | }); | ||
| 176 | |||
| 177 | this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedHttpSniSslCertsInstall", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); | ||
| 178 | this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedHttpSniSslCertsUninstall", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); | ||
| 179 | } | ||
| 180 | } | ||
| 181 | |||
| 182 | /// <summary> | ||
| 66 | /// Parses a UrlReservation element. | 183 | /// Parses a UrlReservation element. |
| 67 | /// </summary> | 184 | /// </summary> |
| 68 | /// <param name="node">The element to parse.</param> | 185 | /// <param name="node">The element to parse.</param> |
diff --git a/src/wixext/HttpTableDefinitions.cs b/src/wixext/HttpTableDefinitions.cs index 0665ce8d..83cd565a 100644 --- a/src/wixext/HttpTableDefinitions.cs +++ b/src/wixext/HttpTableDefinitions.cs | |||
| @@ -6,6 +6,23 @@ namespace WixToolset.Http | |||
| 6 | 6 | ||
| 7 | public static class HttpTableDefinitions | 7 | public static class HttpTableDefinitions |
| 8 | { | 8 | { |
| 9 | public static readonly TableDefinition WixHttpSniSslCert = new TableDefinition( | ||
| 10 | "WixHttpSniSslCert", | ||
| 11 | HttpSymbolDefinitions.WixHttpSniSslCert, | ||
| 12 | new[] | ||
| 13 | { | ||
| 14 | new ColumnDefinition("WixHttpSniSslCert", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The non-localized primary key for the table.", modularizeType: ColumnModularizeType.Column), | ||
| 15 | new ColumnDefinition("Host", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Host for the SNI SSL certificate.", modularizeType: ColumnModularizeType.Property), | ||
| 16 | new ColumnDefinition("Port", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Port for the SNI SSL certificate.", modularizeType: ColumnModularizeType.Property), | ||
| 17 | new ColumnDefinition("Thumbprint", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "humbprint of the SNI SSL certificate to find.", modularizeType: ColumnModularizeType.Property), | ||
| 18 | new ColumnDefinition("AppId", ColumnType.String, 0, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Optional application id for the SNI SSL certificate.", modularizeType: ColumnModularizeType.Property), | ||
| 19 | new ColumnDefinition("Store", ColumnType.String, 0, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Optional application id for the SNI SSL certificate.", modularizeType: ColumnModularizeType.Property), | ||
| 20 | new ColumnDefinition("HandleExisting", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Unknown, minValue: 0, maxValue: 2, description: "The behavior when trying to install a SNI SSL certificate and it already exists."), | ||
| 21 | new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key into the Component table referencing the component that controls the URL reservation.", modularizeType: ColumnModularizeType.Column), | ||
| 22 | }, | ||
| 23 | symbolIdIsPrimaryKey: true | ||
| 24 | ); | ||
| 25 | |||
| 9 | public static readonly TableDefinition WixHttpUrlReservation = new TableDefinition( | 26 | public static readonly TableDefinition WixHttpUrlReservation = new TableDefinition( |
| 10 | "WixHttpUrlReservation", | 27 | "WixHttpUrlReservation", |
| 11 | HttpSymbolDefinitions.WixHttpUrlReservation, | 28 | HttpSymbolDefinitions.WixHttpUrlReservation, |
| @@ -35,6 +52,7 @@ namespace WixToolset.Http | |||
| 35 | 52 | ||
| 36 | public static readonly TableDefinition[] All = new[] | 53 | public static readonly TableDefinition[] All = new[] |
| 37 | { | 54 | { |
| 55 | WixHttpSniSslCert, | ||
| 38 | WixHttpUrlReservation, | 56 | WixHttpUrlReservation, |
| 39 | WixHttpUrlAce, | 57 | WixHttpUrlAce, |
| 40 | }; | 58 | }; |
diff --git a/src/wixext/Symbols/HttpSymbolDefinitions.cs b/src/wixext/Symbols/HttpSymbolDefinitions.cs index a6deb307..2aa03468 100644 --- a/src/wixext/Symbols/HttpSymbolDefinitions.cs +++ b/src/wixext/Symbols/HttpSymbolDefinitions.cs | |||
| @@ -7,6 +7,7 @@ namespace WixToolset.Http | |||
| 7 | 7 | ||
| 8 | public enum HttpSymbolDefinitionType | 8 | public enum HttpSymbolDefinitionType |
| 9 | { | 9 | { |
| 10 | WixHttpSniSslCert, | ||
| 10 | WixHttpUrlAce, | 11 | WixHttpUrlAce, |
| 11 | WixHttpUrlReservation, | 12 | WixHttpUrlReservation, |
| 12 | } | 13 | } |
| @@ -29,6 +30,9 @@ namespace WixToolset.Http | |||
| 29 | { | 30 | { |
| 30 | switch (type) | 31 | switch (type) |
| 31 | { | 32 | { |
| 33 | case HttpSymbolDefinitionType.WixHttpSniSslCert: | ||
| 34 | return HttpSymbolDefinitions.WixHttpSniSslCert; | ||
| 35 | |||
| 32 | case HttpSymbolDefinitionType.WixHttpUrlAce: | 36 | case HttpSymbolDefinitionType.WixHttpUrlAce: |
| 33 | return HttpSymbolDefinitions.WixHttpUrlAce; | 37 | return HttpSymbolDefinitions.WixHttpUrlAce; |
| 34 | 38 | ||
diff --git a/src/wixext/Symbols/WixHttpSniSslCertSymbol.cs b/src/wixext/Symbols/WixHttpSniSslCertSymbol.cs new file mode 100644 index 00000000..ec67a089 --- /dev/null +++ b/src/wixext/Symbols/WixHttpSniSslCertSymbol.cs | |||
| @@ -0,0 +1,95 @@ | |||
| 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 | |||
| 3 | namespace WixToolset.Http | ||
| 4 | { | ||
| 5 | using WixToolset.Data; | ||
| 6 | using WixToolset.Http.Symbols; | ||
| 7 | |||
| 8 | public static partial class HttpSymbolDefinitions | ||
| 9 | { | ||
| 10 | public static readonly IntermediateSymbolDefinition WixHttpSniSslCert = new IntermediateSymbolDefinition( | ||
| 11 | HttpSymbolDefinitionType.WixHttpSniSslCert.ToString(), | ||
| 12 | new[] | ||
| 13 | { | ||
| 14 | new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.Host), IntermediateFieldType.String), | ||
| 15 | new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.Port), IntermediateFieldType.String), | ||
| 16 | new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.Thumbprint), IntermediateFieldType.String), | ||
| 17 | new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.AppId), IntermediateFieldType.String), | ||
| 18 | new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.Store), IntermediateFieldType.String), | ||
| 19 | new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.HandleExisting), IntermediateFieldType.Number), | ||
| 20 | new IntermediateFieldDefinition(nameof(WixHttpSniSslCertSymbolFields.ComponentRef), IntermediateFieldType.String), | ||
| 21 | }, | ||
| 22 | typeof(WixHttpSniSslCertSymbol)); | ||
| 23 | } | ||
| 24 | } | ||
| 25 | |||
| 26 | namespace WixToolset.Http.Symbols | ||
| 27 | { | ||
| 28 | using WixToolset.Data; | ||
| 29 | |||
| 30 | public enum WixHttpSniSslCertSymbolFields | ||
| 31 | { | ||
| 32 | Host, | ||
| 33 | Port, | ||
| 34 | Thumbprint, | ||
| 35 | AppId, | ||
| 36 | Store, | ||
| 37 | HandleExisting, | ||
| 38 | ComponentRef, | ||
| 39 | } | ||
| 40 | |||
| 41 | public class WixHttpSniSslCertSymbol : IntermediateSymbol | ||
| 42 | { | ||
| 43 | public WixHttpSniSslCertSymbol() : base(HttpSymbolDefinitions.WixHttpSniSslCert, null, null) | ||
| 44 | { | ||
| 45 | } | ||
| 46 | |||
| 47 | public WixHttpSniSslCertSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(HttpSymbolDefinitions.WixHttpSniSslCert, sourceLineNumber, id) | ||
| 48 | { | ||
| 49 | } | ||
| 50 | |||
| 51 | public IntermediateField this[WixHttpSniSslCertSymbolFields index] => this.Fields[(int)index]; | ||
| 52 | |||
| 53 | public string Host | ||
| 54 | { | ||
| 55 | get => this.Fields[(int)WixHttpSniSslCertSymbolFields.Host].AsString(); | ||
| 56 | set => this.Set((int)WixHttpSniSslCertSymbolFields.Host, value); | ||
| 57 | } | ||
| 58 | |||
| 59 | public string Port | ||
| 60 | { | ||
| 61 | get => this.Fields[(int)WixHttpSniSslCertSymbolFields.Port].AsString(); | ||
| 62 | set => this.Set((int)WixHttpSniSslCertSymbolFields.Port, value); | ||
| 63 | } | ||
| 64 | |||
| 65 | public string Thumbprint | ||
| 66 | { | ||
| 67 | get => this.Fields[(int)WixHttpSniSslCertSymbolFields.Thumbprint].AsString(); | ||
| 68 | set => this.Set((int)WixHttpSniSslCertSymbolFields.Thumbprint, value); | ||
| 69 | } | ||
| 70 | |||
| 71 | public string AppId | ||
| 72 | { | ||
| 73 | get => this.Fields[(int)WixHttpSniSslCertSymbolFields.AppId].AsString(); | ||
| 74 | set => this.Set((int)WixHttpSniSslCertSymbolFields.AppId, value); | ||
| 75 | } | ||
| 76 | |||
| 77 | public string Store | ||
| 78 | { | ||
| 79 | get => this.Fields[(int)WixHttpSniSslCertSymbolFields.Store].AsString(); | ||
| 80 | set => this.Set((int)WixHttpSniSslCertSymbolFields.Store, value); | ||
| 81 | } | ||
| 82 | |||
| 83 | public HandleExisting HandleExisting | ||
| 84 | { | ||
| 85 | get => (HandleExisting)this.Fields[(int)WixHttpSniSslCertSymbolFields.HandleExisting].AsNumber(); | ||
| 86 | set => this.Set((int)WixHttpSniSslCertSymbolFields.HandleExisting, (int)value); | ||
| 87 | } | ||
| 88 | |||
| 89 | public string ComponentRef | ||
| 90 | { | ||
| 91 | get => this.Fields[(int)WixHttpSniSslCertSymbolFields.ComponentRef].AsString(); | ||
| 92 | set => this.Set((int)WixHttpSniSslCertSymbolFields.ComponentRef, value); | ||
| 93 | } | ||
| 94 | } | ||
| 95 | } | ||
