8787 </xsl : if >
8888 </xsl : template >
8989
90- <!-- enable HTTPS if it's not already enabled -->
91- <xsl : template match =" Service[not(Connector/@protocol = 'org.apache.coyote.http11.Http11NioProtocol')]/*[last()]" >
90+ <xsl : template match =" Server/Service/Engine" >
9291 <xsl : copy >
93- <xsl : apply-templates select =" @*|node()" />
92+ <xsl : apply-templates select =" @*" />
93+
94+ <!-- add RemoteIpValve if requested and not already present -->
95+ <xsl : if test =" translate($RemoteIpValve, $lowercase, $uppercase) = 'TRUE' and not(Valve[@className='org.apache.catalina.valves.RemoteIpValve'])" >
96+ <Valve className =" org.apache.catalina.valves.RemoteIpValve" >
97+ <xsl : attribute name =" protocolHeader" >
98+ <xsl : value-of select =" $RemoteIpValve.protocolHeader" />
99+ </xsl : attribute >
100+ <xsl : attribute name =" portHeader" >
101+ <xsl : value-of select =" $RemoteIpValve.portHeader" />
102+ </xsl : attribute >
103+ <xsl : attribute name =" remoteIpHeader" >
104+ <xsl : value-of select =" $RemoteIpValve.remoteIpHeader" />
105+ </xsl : attribute >
106+ <xsl : attribute name =" hostHeader" >
107+ <xsl : value-of select =" $RemoteIpValve.hostHeader" />
108+ </xsl : attribute >
109+ </Valve >
110+ </xsl : if >
111+
112+ <xsl : apply-templates select =" node()" />
94113 </xsl : copy >
95-
96- <!-- xsltproc does not support boolean parameters -->
97- <xsl : if test =" translate($Connector.https, $lowercase, $uppercase) = 'TRUE'" >
114+
115+ <!-- add HTTPS connector after Engine if not already present -->
116+ <xsl : if test =" not(../Connector[@protocol = 'org.apache.coyote.http11.Http11NioProtocol']) and translate($Connector.https, $lowercase, $uppercase) = 'TRUE'" >
98117 <Connector port =" {$Connector.port.https}" protocol =" org.apache.coyote.http11.Http11NioProtocol"
99118 maxThreads =" {$Connector.maxThreads.https}" SSLEnabled =" true" secure =" true"
100119 keystoreFile =" {$Connector.keystoreFile.https}" keystorePass =" {$Connector.keystorePass.https}"
128147 </Connector >
129148 </xsl : if >
130149 </xsl : template >
131-
132- <xsl : template match =" Server/Service/Engine" >
133- <xsl : copy >
134- <xsl : apply-templates select =" @*" />
135-
136- <!-- add RemoteIpValve if requested and not already present -->
137- <xsl : if test =" translate($RemoteIpValve, $lowercase, $uppercase) = 'TRUE' and not(Valve[@className='org.apache.catalina.valves.RemoteIpValve'])" >
138- <Valve className =" org.apache.catalina.valves.RemoteIpValve" >
139- <xsl : attribute name =" protocolHeader" >
140- <xsl : value-of select =" $RemoteIpValve.protocolHeader" />
141- </xsl : attribute >
142- <xsl : attribute name =" portHeader" >
143- <xsl : value-of select =" $RemoteIpValve.portHeader" />
144- </xsl : attribute >
145- <xsl : attribute name =" remoteIpHeader" >
146- <xsl : value-of select =" $RemoteIpValve.remoteIpHeader" />
147- </xsl : attribute >
148- <xsl : attribute name =" hostHeader" >
149- <xsl : value-of select =" $RemoteIpValve.hostHeader" />
150- </xsl : attribute >
151- </Valve >
152- </xsl : if >
153-
154- <xsl : apply-templates select =" node()" />
155- </xsl : copy >
156- </xsl : template >
157150
158151</xsl : stylesheet >
0 commit comments