esp.xsl 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. ################################################################################
  4. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. ################################################################################
  18. -->
  19. <?xml-stylesheet type="text/xsl" href="C:\Development\deployment\xmlenv\esp.xsl"?>
  20. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xml:space="default"
  21. xmlns:seisint="http://seisint.com" xmlns:exslt="http://exslt.org/common" exclude-result-prefixes="seisint exslt">
  22. <xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="UTF-8"/>
  23. <!--xsl:template match="text()"/-->
  24. <xsl:param name="process" select="'esp'"/>
  25. <xsl:param name="instance" select="'2wd20'"/>
  26. <xsl:param name="isLinuxInstance" select="0"/>
  27. <xsl:param name="serviceFilesList" select="''"/>
  28. <xsl:param name="deployedFromDali" select="''"/>
  29. <xsl:param name="apos">'</xsl:param>
  30. <xsl:variable name="oldPathSeparator">
  31. <xsl:choose>
  32. <xsl:when test="$isLinuxInstance = 1">\:</xsl:when>
  33. <xsl:otherwise>/$</xsl:otherwise>
  34. </xsl:choose>
  35. </xsl:variable>
  36. <xsl:variable name="newPathSeparator">
  37. <xsl:choose>
  38. <xsl:when test="$isLinuxInstance = 1">/$</xsl:when>
  39. <xsl:otherwise>\:</xsl:otherwise>
  40. </xsl:choose>
  41. </xsl:variable>
  42. <xsl:variable name="break"><xsl:text>&#xa;</xsl:text></xsl:variable>
  43. <xsl:variable name="indent"><xsl:text>&#32;&#32;</xsl:text></xsl:variable>
  44. <xsl:variable name="espProcess" select="/Environment/Software/EspProcess[@name=$process]"/>
  45. <xsl:variable name="espBindingProtocol" select="/Environment/Software/EspProcess[@name=$process]/EspBinding/@protocol"/>
  46. <xsl:variable name="method" select="/Environment/Software/EspProcess[@name=$process]/EspBinding/@type"/>
  47. <xsl:variable name="controlPortSetting" select="/Environment/Software/EspProcess[@name=$process]/@controlPort"/>
  48. <xsl:variable name="controlPort">
  49. <xsl:choose>
  50. <xsl:when test="string($controlPortSetting) != ''"><xsl:value-of select="$controlPortSetting"/></xsl:when>
  51. <xsl:when test="string($espBindingProtocol) = 'https'">18010</xsl:when>
  52. <xsl:when test="string($espBindingProtocol) = 'http'">8010</xsl:when>
  53. <xsl:otherwise>0</xsl:otherwise><!-- the WSESPControl will not be in esp.xml if controlPort = 0-->
  54. </xsl:choose>
  55. </xsl:variable>
  56. <xsl:template match="/Environment">
  57. <xsl:copy>
  58. <Software>
  59. <xsl:apply-templates select="$espProcess"/>
  60. <xsl:copy-of select="/Environment/Software/Directories"/>
  61. </Software>
  62. <xsl:copy-of select="/Environment/Hardware/cost"/>
  63. </xsl:copy>
  64. </xsl:template>
  65. <xsl:template match="/Environment/Software/EspProcess">
  66. <!-- note that this can only be @name=$process since it is guided by template
  67. for /Environment above -->
  68. <xsl:copy>
  69. <xsl:apply-templates select="@*[string(.) != '']"/>
  70. <xsl:variable name="computerName" select="Instance[@name=$instance]/@computer"/>
  71. <xsl:attribute name="computer"><xsl:value-of select="$computerName"/></xsl:attribute>
  72. <xsl:attribute name="directory">
  73. <xsl:value-of select="translate(Instance[@name=$instance]/@directory, $oldPathSeparator, $newPathSeparator)"/>
  74. </xsl:attribute>
  75. <xsl:call-template name="addEnvironmentInfo"/>
  76. <xsl:call-template name="addMetricsConfig"/>
  77. <xsl:if test="ESPCacheGroup[1]">
  78. <xsl:value-of disable-output-escaping="yes" select="$break" />
  79. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  80. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  81. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  82. <ESPCache>
  83. <xsl:for-each select="ESPCacheGroup">
  84. <xsl:variable name="ecgid" select="current()/@id"/>
  85. <xsl:variable name="ecgInitString" select="current()/@initString"/>
  86. <xsl:value-of disable-output-escaping="yes" select="$break" />
  87. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  88. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  89. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  90. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  91. <Group id="{$ecgid}" initString="{$ecgInitString}"/>
  92. </xsl:for-each>
  93. <xsl:value-of disable-output-escaping="yes" select="$break" />
  94. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  95. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  96. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  97. </ESPCache>
  98. </xsl:if>
  99. <xsl:if test="./Authentication/@method='ldap' or ./Authentication/@method='ldaps' or ./Authentication/@method='secmgrPlugin'">
  100. <xsl:value-of disable-output-escaping="yes" select="$break" />
  101. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  102. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  103. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  104. <xsl:if test="AuthDomain[1]">
  105. <AuthDomains>
  106. <xsl:for-each select="AuthDomain">
  107. <xsl:value-of disable-output-escaping="yes" select="$break" />
  108. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  109. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  110. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  111. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  112. <xsl:copy-of select="."/>
  113. </xsl:for-each>
  114. <xsl:value-of disable-output-escaping="yes" select="$break" />
  115. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  116. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  117. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  118. </AuthDomains>
  119. </xsl:if>
  120. </xsl:if>
  121. <xsl:for-each select="Authentication">
  122. <xsl:if test="@method='ldap' or @method='ldaps'">
  123. <xsl:value-of disable-output-escaping="yes" select="$break" />
  124. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  125. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  126. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  127. <xsl:call-template name="doLdapSecurity">
  128. <xsl:with-param name="method" select="@method"/>
  129. <xsl:with-param name="ldapServer" select="@ldapServer"/>
  130. <xsl:with-param name="ldapConnections" select="@ldapConnections"/>
  131. <xsl:with-param name="passwordExpirationWarningDays" select="@passwordExpirationWarningDays"/>
  132. <xsl:with-param name="checkViewPermissions" select="@checkViewPermissions"/>
  133. <xsl:with-param name="localDomain" select="/Environment/Hardware/Computer[@name=$computerName]/@domain"/>
  134. </xsl:call-template>
  135. </xsl:if>
  136. </xsl:for-each>
  137. <xsl:if test="./Authentication/@method='secmgrPlugin'">
  138. <SecurityManagers>
  139. <xsl:for-each select="./EspBinding[@type != '']">
  140. <xsl:if test="not(preceding-sibling::EspBinding/@type = current()/@type)">
  141. <SecurityManager>
  142. <xsl:variable name="instanceName" select="@type"/>
  143. <xsl:if test="not(/Environment/Software/*[@name=$instanceName and @type='SecurityManager'])">
  144. <xsl:message terminate="yes">Security Manager instance of name <xsl:value-of select="@type"/> is referenced in service <xsl:value-of select="@name"/> of ESP <xsl:value-of select="../@name"/> but does not exist"</xsl:message>
  145. </xsl:if>
  146. <xsl:attribute name="name">
  147. <xsl:value-of select="/Environment/Software/*[@name=$instanceName and @type='SecurityManager']/@name"/>
  148. </xsl:attribute>
  149. <xsl:attribute name="instanceFactoryName">
  150. <xsl:value-of select="/Environment/Software/*[@name=$instanceName and @type='SecurityManager']/@instanceFactoryName"/>
  151. </xsl:attribute>
  152. <xsl:attribute name="libName">
  153. <xsl:value-of select="/Environment/Software/*[@name=$instanceName and @type='SecurityManager']/@libName"/>
  154. </xsl:attribute>
  155. <xsl:attribute name="type">
  156. <xsl:value-of select="name(/Environment/Software/*[@name=$instanceName and @type='SecurityManager'])"/>
  157. </xsl:attribute>
  158. <xsl:copy-of select="/Environment/Software/*[@name=$instanceName and @type='SecurityManager']"/>
  159. </SecurityManager>
  160. </xsl:if>
  161. </xsl:for-each>
  162. </SecurityManagers>
  163. </xsl:if>
  164. <xsl:variable name="maxRequestEntityLength">
  165. <xsl:choose>
  166. <xsl:when test="EspBinding[1]">
  167. <xsl:apply-templates select="EspBinding[1]" mode="maxRequestEntityLength">
  168. <xsl:with-param name="max" select="number(@maxRequestEntityLength)"/>
  169. </xsl:apply-templates>
  170. </xsl:when>
  171. <xsl:otherwise>
  172. <xsl:value-of select="@maxRequestEntityLength"/>
  173. </xsl:otherwise>
  174. </xsl:choose>
  175. </xsl:variable>
  176. <!-- insert http protocol, if being used for any binding and is not defined -->
  177. <xsl:if test="EspBinding[@protocol='http'] and not(EspProtocol[@name='http'])">
  178. <EspProtocol>
  179. <xsl:attribute name="name">http</xsl:attribute>
  180. <xsl:attribute name="type">http_protocol</xsl:attribute>
  181. <xsl:attribute name="plugin">esphttp</xsl:attribute>
  182. <xsl:attribute name="maxRequestEntityLength">
  183. <xsl:value-of select="$maxRequestEntityLength"/>
  184. </xsl:attribute>
  185. </EspProtocol>
  186. </xsl:if>
  187. <!-- insert https protocol, if a certificate has been specified for it-->
  188. <xsl:if test="EspBinding[@protocol='https']">
  189. <EspProtocol name="https" type="secure_http_protocol">
  190. <xsl:attribute name="plugin">esphttp</xsl:attribute>
  191. <xsl:attribute name="maxRequestEntityLength">
  192. <xsl:value-of select="$maxRequestEntityLength"/>
  193. </xsl:attribute>
  194. <certificate>
  195. <xsl:value-of select="HTTPS/@certificateFileName"/>
  196. </certificate>
  197. <privatekey>
  198. <xsl:value-of select="HTTPS/@privateKeyFileName"/>
  199. </privatekey>
  200. <passphrase>
  201. <xsl:value-of select="HTTPS/@passphrase"/>
  202. </passphrase>
  203. <cipherList>
  204. <xsl:value-of select="HTTPS/@cipherList"/>
  205. </cipherList>
  206. <verify enable="{HTTPS/@enableVerification}" address_match="{HTTPS/@requireAddressMatch}" accept_selfsigned="{HTTPS/@acceptSelfSigned}">
  207. <ca_certificates path="{HTTPS/@CA_Certificates_Path}"/>
  208. <trusted_peers><xsl:value-of select="HTTPS/@trustedPeers"/></trusted_peers>
  209. </verify>
  210. </EspProtocol>
  211. </xsl:if>
  212. <xsl:if test="string($controlPort) != '0'">
  213. <xsl:variable name="serviceName" select="concat('WSESPControl_', $process)"/>
  214. <xsl:variable name="servicePlugin">
  215. <xsl:call-template name="makeServicePluginName">
  216. <xsl:with-param name="plugin" select="'ws_espcontrol'"/>
  217. </xsl:call-template>
  218. </xsl:variable>
  219. <xsl:variable name="bindName" select="concat('WSESPControl_Binding_', $process)"/>
  220. <xsl:value-of disable-output-escaping="yes" select="$break" />
  221. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  222. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  223. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  224. <EspService name="{$serviceName}" type="WSESPControl" plugin="{$servicePlugin}"/>
  225. <xsl:value-of disable-output-escaping="yes" select="$break" />
  226. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  227. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  228. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  229. <EspBinding name="{$bindName}" service="{$serviceName}" protocol="{$espBindingProtocol}" type="ws_espcontrolSoapBinding" plugin="{$servicePlugin}" netAddress="0.0.0.0" port="{$controlPort}">
  230. <xsl:if test="EspControlBinding">
  231. <xsl:variable name="authNode" select="Authentication[1]"/>
  232. <xsl:variable name="espControlBinding" select="EspControlBinding"/>
  233. <xsl:call-template name="bindAuthentication">
  234. <xsl:with-param name="bindingNode" select="$espControlBinding"/>
  235. <xsl:with-param name="authMethod" select="$authNode/@method"/>
  236. </xsl:call-template>
  237. </xsl:if>
  238. </EspBinding>
  239. </xsl:if>
  240. <xsl:variable name="importedServiceDefinitionFiles">
  241. <xsl:call-template name="importServiceDefinitionFiles">
  242. <xsl:with-param name="filesList" select="$serviceFilesList"/>
  243. </xsl:call-template>
  244. </xsl:variable>
  245. <xsl:apply-templates select="exslt:node-set($importedServiceDefinitionFiles)" mode="processImportedServiceDefinitions"/>
  246. <xsl:apply-templates select="node()"/>
  247. </xsl:copy>
  248. </xsl:template>
  249. <xsl:template match="/Environment/Software/EspProtocol">
  250. <xsl:variable name="protocolName" select="@name"/>
  251. <xsl:if test="../EspBinding[@protocol=$protocolName]">
  252. <xsl:apply-templates select="."/>
  253. </xsl:if>
  254. </xsl:template>
  255. <xsl:template name="importServiceDefinitionFiles">
  256. <xsl:param name="filesList"/>
  257. <xsl:if test="string($filesList) != ''">
  258. <xsl:variable name="fileName" select="substring-before($filesList, ';')"/>
  259. <xsl:call-template name="getServiceDefinition">
  260. <xsl:with-param name="serviceFileName" select="$fileName"/>
  261. </xsl:call-template>
  262. <xsl:call-template name="importServiceDefinitionFiles">
  263. <xsl:with-param name="filesList" select="substring-after($filesList, ';')"/>
  264. </xsl:call-template>
  265. </xsl:if>
  266. </xsl:template>
  267. <xsl:template name="getServiceDefinition">
  268. <xsl:param name="serviceFileName"/>
  269. <xsl:variable name="serviceFile" select="document(concat('file:///', translate($serviceFileName, '\', '/')))"/>
  270. <xsl:if test="not($serviceFile)">
  271. <xsl:message terminate="yes">ESP service definition file <xsl:value-of select="$serviceFileName"/> not found!</xsl:message>
  272. </xsl:if>
  273. <xsl:variable name="serviceFileNode" select="$serviceFile/Environment/Software/EspProcess/*"/>
  274. <xsl:if test="not($serviceFileNode)">
  275. <xsl:message terminate="yes">No ESP service definition found in <xsl:value-of select="$serviceFileName"/>!</xsl:message>
  276. </xsl:if>
  277. <xsl:copy-of select="$serviceFileNode"/>
  278. </xsl:template>
  279. <xsl:template match="EspBinding">
  280. <xsl:variable name="name" select="@name"/>
  281. <xsl:variable name="port" select="@port"/>
  282. <xsl:variable name="service" select="@service"/>
  283. <xsl:variable name="type" select="/Environment/Software/EspService[@name=$service]/Properties/@type"/>
  284. <xsl:variable name="defaultForPort" select="string(@defaultForPort)='true'"/>
  285. <xsl:if test="string($service)=''">
  286. <xsl:message terminate="yes">No service is specified for ESP binding '<xsl:value-of select="$name"/>'.</xsl:message>
  287. </xsl:if>
  288. <xsl:if test="string($port) = ''">
  289. <xsl:message terminate="yes">No port is specified for ESP binding '<xsl:value-of select="$name"/>'.</xsl:message>
  290. </xsl:if>
  291. <xsl:for-each select="preceding-sibling::EspBinding[@port=$port]">
  292. <xsl:variable name="type2" select="/Environment/Software/EspService[@name=current()/@service]/Properties/@type"/>
  293. <xsl:choose>
  294. <xsl:when test="$type2=$type">
  295. <xsl:message terminate="yes">
  296. <xsl:text>Port conflict in ESP binding '</xsl:text>
  297. <xsl:value-of select="$name"/>
  298. <xsl:text>' of '</xsl:text>
  299. <xsl:value-of select="$process"/>
  300. <xsl:text>'! Port </xsl:text>
  301. <xsl:value-of select="$port"/>
  302. <xsl:text> is already bound to another service of the same type for binding '</xsl:text>
  303. <xsl:value-of select="current()/@name"/>
  304. <xsl:text>'.</xsl:text>
  305. </xsl:message>
  306. </xsl:when>
  307. <xsl:when test="$defaultForPort and @defaultForPort!='false'">
  308. <xsl:call-template name="message">
  309. <xsl:with-param name="text">
  310. <xsl:value-of select="concat('Multiple ESP bindings on port ', $port, ' of ESP ', $apos, $process, $apos)"/>
  311. <xsl:text> are defined as default. Last one would dictate root level access.</xsl:text>
  312. </xsl:with-param>
  313. </xsl:call-template>
  314. </xsl:when>
  315. </xsl:choose>
  316. </xsl:for-each>
  317. </xsl:template>
  318. <xsl:template match="EspBinding" mode="maxRequestEntityLength">
  319. <xsl:param name="max"/>
  320. <xsl:variable name="svcValue"
  321. select="number(/Environment/Software/EspService[@name=current()/@service]/@maxRequestEntityLength)"/>
  322. <xsl:variable name="newMax">
  323. <xsl:choose>
  324. <xsl:when test="$max &lt; $svcValue">
  325. <xsl:value-of select="$svcValue"/>
  326. </xsl:when>
  327. <xsl:otherwise>
  328. <xsl:value-of select="$max"/>
  329. </xsl:otherwise>
  330. </xsl:choose>
  331. </xsl:variable>
  332. <xsl:variable name="nextBinding" select="following-sibling::EspBinding[1]"/>
  333. <xsl:choose>
  334. <xsl:when test="$nextBinding">
  335. <xsl:apply-templates select="$nextBinding" mode="maxRequestEntityLength">
  336. <xsl:with-param name="max" select="$newMax"/>
  337. </xsl:apply-templates>
  338. </xsl:when>
  339. <xsl:otherwise>
  340. <xsl:value-of select="$newMax"/>
  341. </xsl:otherwise>
  342. </xsl:choose>
  343. </xsl:template>
  344. <!--don't produce in output -->
  345. <xsl:template match="EspProcess/Instance|EspProcess/HTTPS|ProtocolX"/>
  346. <!--don't produce in output -->
  347. <xsl:template match="@buildSet|@maxRequestEntityLength"/>
  348. <!--don't produce in output -->
  349. <xsl:template match="EspProcess/ESPCacheGroup"/>
  350. <!--don't produce in output -->
  351. <xsl:template match="EspProcess/AuthDomain"/>
  352. <!--don't produce in output -->
  353. <xsl:template match="EspProcess/EspControlBinding"/>
  354. <xsl:template match="/|@*|node()">
  355. <!--matches any attribute or child of any types-->
  356. <xsl:copy>
  357. <!--copy input to output-->
  358. <xsl:apply-templates select="@*|node()"/>
  359. </xsl:copy>
  360. </xsl:template>
  361. <xsl:template name="doLdapSecurity">
  362. <xsl:param name="method"/>
  363. <xsl:param name="ldapServer"/>
  364. <xsl:param name="ldapConnections"/>
  365. <xsl:param name="localDomain"/>
  366. <xsl:param name="passwordExpirationWarningDays"/>
  367. <xsl:param name="checkViewPermissions"/>
  368. <xsl:variable name="ldapServerNode" select="/Environment/Software/LDAPServerProcess[@name=$ldapServer]"/>
  369. <xsl:if test="not($ldapServerNode)">
  370. <xsl:message terminate="yes">LDAP server is either not specified or is invalid!</xsl:message>
  371. </xsl:if>
  372. <xsl:for-each select="$ldapServerNode">
  373. <xsl:element name="ldapSecurity">
  374. <xsl:attribute name="name">ldapserver</xsl:attribute>
  375. <xsl:attribute name="ldapProtocol"><xsl:value-of select="$method"/></xsl:attribute>
  376. <xsl:attribute name="localDomain"><xsl:value-of select="$localDomain"/></xsl:attribute>
  377. <xsl:attribute name="checkViewPermissions"><xsl:value-of select="$checkViewPermissions"/></xsl:attribute>
  378. <xsl:attribute name="maxConnections">
  379. <xsl:choose>
  380. <xsl:when test="string($ldapConnections) != ''"><xsl:value-of select="$ldapConnections"/></xsl:when>
  381. <xsl:otherwise><xsl:value-of select="@maxConnections"/></xsl:otherwise>
  382. </xsl:choose>
  383. </xsl:attribute>
  384. <xsl:attribute name="passwordExpirationWarningDays">
  385. <xsl:choose>
  386. <xsl:when test="string($passwordExpirationWarningDays) != ''">
  387. <xsl:value-of select="$passwordExpirationWarningDays"/>
  388. </xsl:when>
  389. <xsl:otherwise>10</xsl:otherwise>
  390. </xsl:choose>
  391. </xsl:attribute>
  392. <xsl:variable name="ldapAddress">
  393. <xsl:for-each select="Instance[@name]">
  394. <xsl:variable name="netAddress" select="/Environment/Hardware/Computer[@name=current()/@computer]/@netAddress"/>
  395. <xsl:if test="string($netAddress) = ''">
  396. <xsl:message terminate="yes">Invalid I.P. address for instance '<xsl:value-of select="@name"/>' of LDAP server '<xsl:value-of select="$ldapServer"/>'.</xsl:message>
  397. </xsl:if>
  398. <xsl:if test="position() > 1">|</xsl:if>
  399. <xsl:value-of select="$netAddress"/>
  400. </xsl:for-each>
  401. </xsl:variable>
  402. <xsl:if test="string($ldapAddress) != ''">
  403. <xsl:attribute name="ldapAddress"><xsl:value-of select="$ldapAddress"/></xsl:attribute>
  404. </xsl:if>
  405. <xsl:for-each select="@*">
  406. <xsl:choose>
  407. <xsl:when test="name()='ldapConnections'"/>
  408. <xsl:when test="name()='build'"/>
  409. <xsl:when test="name()='buildSet'"/>
  410. <xsl:when test="name()='name'"/>
  411. <xsl:when test="name()='modulesBasedn' and string(.) != ''">
  412. <xsl:attribute name="resourcesBasedn"><xsl:value-of select="."/></xsl:attribute>
  413. </xsl:when>
  414. <xsl:when test="name()='computer' and string(.) != '' and string($ldapAddress) = ''">
  415. <xsl:attribute name="ldapAddress"><xsl:value-of select="/Environment/Hardware/Computer[@name=current()]/@netAddress"/></xsl:attribute>
  416. </xsl:when>
  417. <xsl:when test="string(.) != ''">
  418. <xsl:copy/>
  419. </xsl:when>
  420. <xsl:otherwise/>
  421. </xsl:choose>
  422. </xsl:for-each>
  423. </xsl:element>
  424. </xsl:for-each>
  425. </xsl:template>
  426. <xsl:template name="dohtpasswdSecurity">
  427. <xsl:param name="method"/>
  428. <xsl:param name="htpasswdFile"/>
  429. <xsl:element name="htpasswdSecurity">
  430. <xsl:attribute name="method"> <xsl:value-of select="$method"/> </xsl:attribute>
  431. <xsl:attribute name="htpasswdFile"> <xsl:value-of select="$htpasswdFile"/> </xsl:attribute>
  432. </xsl:element>
  433. </xsl:template>
  434. <xsl:template name="doAccurintSecurity">
  435. <xsl:param name="method"/>
  436. <xsl:param name="accurintSecurity"/>
  437. <xsl:param name="localDomain"/>
  438. <xsl:for-each select="/Environment/Software/AccurintServerProcess[@name=$accurintSecurity]">
  439. <xsl:element name="AccurintSecurity">
  440. <xsl:attribute name="name">accurintserver</xsl:attribute>
  441. <xsl:attribute name="localDomain"><xsl:value-of select="$localDomain"/></xsl:attribute>
  442. <xsl:for-each select="@*">
  443. <xsl:choose>
  444. <xsl:when test="name()='build'"/>
  445. <xsl:when test="name()='buildSet'"/>
  446. <xsl:when test="name()='name'"/>
  447. <xsl:when test="string(.) != ''">
  448. <xsl:copy/>
  449. </xsl:when>
  450. <xsl:otherwise/>
  451. </xsl:choose>
  452. </xsl:for-each>
  453. <SafeIPList>
  454. <xsl:for-each select="/Environment/Software/AccurintServerProcess[@name=$accurintSecurity]/SafeIPList">
  455. <ip><xsl:value-of select="@ip"/></ip>
  456. </xsl:for-each>
  457. </SafeIPList>
  458. <xsl:for-each select="StoredProcedureMap">
  459. <StoredProcedureMap>
  460. <xsl:for-each select="@*">
  461. <xsl:copy/>
  462. </xsl:for-each>
  463. </StoredProcedureMap>
  464. </xsl:for-each>
  465. </xsl:element>
  466. </xsl:for-each>
  467. </xsl:template>
  468. <xsl:template match="@daliServers">
  469. <xsl:variable name="daliServerName" select="."/>
  470. <xsl:attribute name="daliServers">
  471. <xsl:for-each select="/Environment/Software/DaliServerProcess[@name=$daliServerName]/Instance">
  472. <xsl:call-template name="getNetAddress">
  473. <xsl:with-param name="computer" select="@computer"/>
  474. </xsl:call-template>
  475. <xsl:if test="string(@port) != ''">:<xsl:value-of select="@port"/>
  476. </xsl:if>
  477. <xsl:if test="position() != last()">, </xsl:if>
  478. </xsl:for-each>
  479. </xsl:attribute>
  480. <xsl:apply-templates select="@*|node()"/>
  481. </xsl:template>
  482. <xsl:template name="getNetAddress">
  483. <xsl:param name="computer"/>
  484. <xsl:value-of select="/Environment/Hardware/Computer[@name=$computer]/@netAddress"/>
  485. </xsl:template>
  486. <xsl:template name="makeServicePluginName">
  487. <xsl:param name="plugin"/>
  488. <xsl:choose>
  489. <xsl:when test="$isLinuxInstance"><xsl:value-of select="$plugin"/></xsl:when>
  490. <xsl:otherwise>
  491. <xsl:value-of select="$plugin"/>.dll</xsl:otherwise>
  492. </xsl:choose>
  493. </xsl:template>
  494. <xsl:template match="EspService" mode="processImportedServiceDefinitions">
  495. <xsl:variable name="name" select="@name"/>
  496. <xsl:if test="not(preceding-sibling::EspService[@name=$name])">
  497. <xsl:value-of disable-output-escaping="yes" select="$break" />
  498. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  499. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  500. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  501. <xsl:copy>
  502. <xsl:apply-templates select="*|@*[string(.) != '']|text()" mode="processImportedServiceDefinitions"/>
  503. </xsl:copy>
  504. </xsl:if>
  505. </xsl:template>
  506. <xsl:template match="EspBinding" mode="processImportedServiceDefinitions">
  507. <xsl:if test="not(preceding-sibling::EspBinding[@name=current()/@name])">
  508. <xsl:value-of disable-output-escaping="yes" select="$break" />
  509. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  510. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  511. <xsl:value-of disable-output-escaping="yes" select="$indent" />
  512. <xsl:variable name="bindNode" select="."/>
  513. <!--note that the name of this generated binding is not same as the original binding name
  514. and is mangled in this format: "[service-name]_[binding-name]_[esp-name]". Besides, the
  515. service name does not have to be same as @service in original esp binding, for instance,
  516. eclwatch is actually a collection of half a dozen services. Find the matching binding
  517. that ends with mangled name "_[binding-name]_[esp-name]". -->
  518. <xsl:variable name="origBindName">
  519. <xsl:for-each select="$espProcess/EspBinding">
  520. <xsl:variable name="mangledName" select="concat('_', @name, '_', $process)"/>
  521. <xsl:if test="contains($bindNode/@name, $mangledName) and substring-after($bindNode/@name, $mangledName)=''">
  522. <xsl:value-of select="@name"/>
  523. </xsl:if>
  524. </xsl:for-each>
  525. </xsl:variable>
  526. <xsl:variable name="envBindNode" select="$espProcess/EspBinding[@name = $origBindName]"/>
  527. <xsl:copy>
  528. <xsl:apply-templates select="@*[string(.) != '']" mode="processImportedServiceDefinitions">
  529. <xsl:with-param name="envBindNode" select="$envBindNode"/>
  530. </xsl:apply-templates>
  531. <!--if the generated EspBinding failed to propagate @wsdlServiceAddress from the original binding then add it there -->
  532. <xsl:if test="$envBindNode"><!--found matching original binding node in the environment-->
  533. <xsl:if test="string($bindNode/@wsdlServiceAddress) = ''">
  534. <xsl:copy-of select="$envBindNode/@wsdlServiceAddress"/>
  535. </xsl:if>
  536. <xsl:if test="string($bindNode/@defaultServiceVersion) = ''">
  537. <xsl:copy-of select="$envBindNode/@defaultServiceVersion"/>
  538. </xsl:if>
  539. </xsl:if>
  540. <xsl:if test="$envBindNode/CustomBindingParameter">
  541. <CustomBindingParameters>
  542. <xsl:for-each select="$envBindNode/CustomBindingParameter">
  543. <xsl:copy-of select="."/>
  544. </xsl:for-each>
  545. </CustomBindingParameters>
  546. </xsl:if>
  547. <!-- if the generated EspBinding/Authenticate is missing @workunitsBasedn then add it there -->
  548. <xsl:variable name="defaultWorkunitsBasedn">
  549. <xsl:choose>
  550. <xsl:when test="string($envBindNode/@workunitsBasedn) != ''"><xsl:value-of select="$envBindNode/@workunitsBasedn"/></xsl:when>
  551. <xsl:otherwise>ou=workunits,ou=ecl</xsl:otherwise>
  552. </xsl:choose>
  553. </xsl:variable>
  554. <xsl:for-each select="$bindNode/Authenticate">
  555. <xsl:copy>
  556. <xsl:apply-templates select="@*[string(.) != '']" mode="processImportedServiceDefinitions"/>
  557. <xsl:if test="string(@workunitsBasedn)=''">
  558. <xsl:attribute name="workunitsBasedn"><xsl:value-of select="$defaultWorkunitsBasedn"/></xsl:attribute>
  559. </xsl:if>
  560. <xsl:apply-templates select="* | text()" mode="processImportedServiceDefinitions"/>
  561. </xsl:copy>
  562. </xsl:for-each>
  563. <xsl:apply-templates select="*[name() != 'Authenticate'] | text()" mode="processImportedServiceDefinitions"/>
  564. </xsl:copy>
  565. </xsl:if>
  566. </xsl:template>
  567. <xsl:template name="addEnvironmentInfo">
  568. <Environment>
  569. <xsl:if test="string($deployedFromDali)!=''">
  570. <xsl:attribute name="daliAddress">
  571. <xsl:value-of select="$deployedFromDali"/>
  572. </xsl:attribute>
  573. </xsl:if>
  574. <!--get space delimited net addresses for all ECL watches in this environment-->
  575. <xsl:variable name="allEclWatches">
  576. <xsl:apply-templates select="/Environment/Software/EspProcess" mode="EclWatch"/>
  577. </xsl:variable>
  578. <xsl:call-template name="printUniqueTokens">
  579. <xsl:with-param name="s" select="$allEclWatches"/>
  580. <xsl:with-param name="enclosingTagName" select="'EclWatch'"/>
  581. </xsl:call-template>
  582. </Environment>
  583. </xsl:template>
  584. <xsl:template name="addMetricsConfig">
  585. <xsl:copy-of select="/Environment/Software/metrics"/>
  586. </xsl:template>
  587. <xsl:template match="/Environment/Software/EspProcess" mode="EclWatch">
  588. <xsl:for-each select="EspBinding">
  589. <xsl:variable name="protocol" select="@protocol"/>
  590. <xsl:variable name="port" select="@port"/>
  591. <xsl:variable name="method" select="@type"/>
  592. <xsl:variable name="service" select="@service"/>
  593. <xsl:variable name="type" select="/Environment/Software/EspService[@name=$service]/Properties/@type"/>
  594. <xsl:if test="$type='WsSMC' and starts-with($protocol, 'http') and string($port)!=''">
  595. <xsl:for-each select="../Instance">
  596. <xsl:value-of select="concat($protocol, '://')"/>
  597. <xsl:value-of select="/Environment/Hardware/Computer[@name=current()/@computer]/@netAddress"/>
  598. <xsl:text>:</xsl:text>
  599. <xsl:value-of select="$port"/>
  600. <xsl:text> </xsl:text>
  601. </xsl:for-each>
  602. </xsl:if>
  603. </xsl:for-each>
  604. </xsl:template>
  605. <xsl:template name="bindAuthentication">
  606. <xsl:param name="authMethod"/>
  607. <xsl:param name="bindingNode"/>
  608. <xsl:choose>
  609. <xsl:when test="$authMethod='basic'">
  610. <Authenticate type="Basic" method="UserDefined">
  611. <xsl:for-each select="$bindingNode/Authenticate[string(@path) != '']">
  612. <Location path="{@path}"/>
  613. </xsl:for-each>
  614. </Authenticate>
  615. </xsl:when>
  616. <xsl:when test="$authMethod='ldap' or $authMethod='ldaps'">
  617. <Authenticate method="LdapSecurity" config="ldapserver">
  618. <xsl:copy-of select="$bindingNode/@resourcesBasedn"/>
  619. <xsl:for-each select="$bindingNode/Authenticate[string(@path) != '']">
  620. <Location path="{@path}" resource="{@resource}" access="{@access}" description="{@description}"/>
  621. </xsl:for-each>
  622. <xsl:for-each select="$bindingNode/AuthenticateFeature[@authenticate='Yes']">
  623. <Feature name="{@name}" path="{@path}" resource="{@resource}" required="{@access}" description="{@description}"/>
  624. </xsl:for-each>
  625. <xsl:for-each select="$bindingNode/AuthenticateSetting[@include='Yes']">
  626. <Setting path="{@path}" resource="{@resource}" description="{@description}"/>
  627. </xsl:for-each>
  628. </Authenticate>
  629. </xsl:when>
  630. <xsl:when test="$authMethod='secmgrPlugin'">
  631. <Authenticate>
  632. <xsl:attribute name="method">
  633. <xsl:value-of select="$bindingNode/@type"/>
  634. </xsl:attribute>
  635. <xsl:copy-of select="$bindingNode/@resourcesBasedn"/>
  636. <xsl:for-each select="$bindingNode/Authenticate[string(@path) != '']">
  637. <Location path="{@path}" resource="{@resource}" access="{@access}" description="{@description}"/>
  638. </xsl:for-each>
  639. <xsl:for-each select="$bindingNode/AuthenticateFeature[@authenticate='Yes']">
  640. <Feature name="{@name}" path="{@path}" resource="{@resource}" required="{@access}" description="{@description}"/>
  641. </xsl:for-each>
  642. <xsl:for-each select="$bindingNode/AuthenticateSetting[@include='Yes']">
  643. <Setting path="{@path}" resource="{@resource}" description="{@description}"/>
  644. </xsl:for-each>
  645. </Authenticate>
  646. </xsl:when>
  647. </xsl:choose>
  648. </xsl:template>
  649. <xsl:template name="printUniqueTokens">
  650. <xsl:param name="s"/><!--space delimited string of tokens with space as last char-->
  651. <xsl:param name="enclosingTagName"/>
  652. <xsl:if test="$s!=''">
  653. <xsl:variable name="token" select="substring-before($s, ' ')"/>
  654. <xsl:variable name="suffix" select="substring-after($s, ' ')"/>
  655. <xsl:choose>
  656. <xsl:when test="$token=''"></xsl:when>
  657. <xsl:when test="contains($suffix, $token)">
  658. <xsl:call-template name="printUniqueTokens">
  659. <xsl:with-param name="s" select="$suffix"/>
  660. <xsl:with-param name="enclosingTagName" select="$enclosingTagName"/>
  661. </xsl:call-template>
  662. </xsl:when>
  663. <xsl:otherwise>
  664. <xsl:element name="{$enclosingTagName}">
  665. <xsl:value-of select="$token"/>
  666. </xsl:element>
  667. </xsl:otherwise>
  668. </xsl:choose>
  669. </xsl:if>
  670. </xsl:template>
  671. <xsl:template name="message">
  672. <xsl:param name="text"/>
  673. <xsl:choose>
  674. <xsl:when test="function-available('seisint:message')">
  675. <xsl:variable name="dummy" select="seisint:message($text)"/>
  676. </xsl:when>
  677. <xsl:otherwise>
  678. <xsl:message terminate="no">
  679. <xsl:value-of select="$text"/>
  680. </xsl:message>
  681. </xsl:otherwise>
  682. </xsl:choose>
  683. </xsl:template>
  684. <xsl:template match="@defaultBinding" mode="processImportedServiceDefinitions">
  685. <xsl:param name="envBindNode"/>
  686. <xsl:if test="$envBindNode/@defaultForPort!='false'">
  687. <xsl:copy-of select="."/>
  688. </xsl:if>
  689. </xsl:template>
  690. <xsl:template match="*|@*|text()" mode="processImportedServiceDefinitions">
  691. <xsl:copy>
  692. <xsl:apply-templates select="@*|*|text()" mode="processImportedServiceDefinitions"/>
  693. </xsl:copy>
  694. </xsl:template>
  695. </xsl:stylesheet>