encryptConnectionPasswords.xslt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ps
  5. (C) Copyright IBM Corp. 2005, 2013
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <xsl:stylesheet version="1.0" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  13. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  14. <xsl:key name="env-param" match="/root/env/param" use="@name"/>
  15. <xsl:template match="/">
  16. <xts:sequence>
  17. <!-- deal with the password fields -->
  18. <xsl:if test="(key('env-param','m_connection_password') != '' or key('env-param','test_password') !='') and not(key('env-param','passwordEncrypted')) or key('env-param','passwordEncrypted') = ''">
  19. <xts:delete select="/root/env/param[@name='passwordEncrypted']"/>
  20. <xts:append select="/root/env">
  21. <param name="passwordEncrypted">
  22. <xsl:choose>
  23. <xsl:when test="key('env-param','test_password') !='' and key('env-param','test_password')/@format='encrypted'">
  24. <xsl:value-of select="key('env-param','test_password')"/>
  25. </xsl:when>
  26. <xsl:when test="key('env-param','m_connection_password') !='' and key('env-param','m_connection_password')/@format='encrypted'">
  27. <xsl:value-of select="key('env-param','m_connection_password')"/>
  28. </xsl:when>
  29. <xsl:otherwise>
  30. <xts:encrypt>
  31. <xts:param name="provider">cognos.cam</xts:param>
  32. <xts:param name="source">
  33. <xsl:choose>
  34. <xsl:when test="key('env-param','test_password') != ''">
  35. <xsl:value-of select="key('env-param','test_password')"/>
  36. </xsl:when>
  37. <xsl:otherwise>
  38. <xsl:value-of select="key('env-param','m_connection_password')"/>
  39. </xsl:otherwise>
  40. </xsl:choose>
  41. </xts:param>
  42. </xts:encrypt>
  43. </xsl:otherwise>
  44. </xsl:choose>
  45. </param>
  46. </xts:append>
  47. <xts:delete select="/root/env/param[@name='m_connection_password' or @name='m_connection_confirm_password' or @name='test_password']"/>
  48. </xsl:if>
  49. <!-- deal with the proxy password fields -->
  50. <xsl:if test="(key('env-param','m_connection_proxy_password') != '')">
  51. <xts:delete select="/root/env/param[@name='proxyPasswordEncrypted']"/>
  52. <xts:append select="/root/env">
  53. <param name="proxyPasswordEncrypted">
  54. <xsl:if test="key('env-param','m_connection_proxy_password')/@format='encrypted'">
  55. <xsl:value-of select="key('env-param','m_connection_proxy_password')"/>
  56. </xsl:if>
  57. </param>
  58. </xts:append>
  59. <xts:delete select="/root/env/param[@name='m_connection_proxy_password']"/>
  60. </xsl:if>
  61. <!-- deal with the cube password -->
  62. <xsl:if test="(key('env-param','test_cube_password')!= '' or key('env-param','m_cube_password') != '') and (not(key('env-param','cubePasswordEncrypted')) or key('env-param','cubePasswordEncrypted') = '')">
  63. <xts:delete select="/root/env/param[@name='cubePasswordEncrypted']"/>
  64. <xts:append select="/root/env">
  65. <param name="cubePasswordEncrypted">
  66. <xsl:choose>
  67. <xsl:when test="key('env-param','test_cube_password') !='' and key('env-param','test_cube_password')/@format='encrypted'">
  68. <xsl:value-of select="key('env-param','test_cube_password')"/>
  69. </xsl:when>
  70. <xsl:when test="key('env-param','m_cube_password') !='' and key('env-param','m_cube_password')/@format='encrypted'">
  71. <xsl:value-of select="key('env-param','m_cube_password')"/>
  72. </xsl:when>
  73. <xsl:otherwise>
  74. <xts:encrypt>
  75. <xts:param name="provider">cognos.cam</xts:param>
  76. <xts:param name="source">
  77. <xsl:choose>
  78. <xsl:when test="key('env-param','test_cube_password') != ''">
  79. <xsl:value-of select="key('env-param','test_cube_password')"/>
  80. </xsl:when>
  81. <xsl:otherwise>
  82. <xsl:value-of select="key('env-param','m_cube_password')"/>
  83. </xsl:otherwise>
  84. </xsl:choose>
  85. </xts:param>
  86. </xts:encrypt>
  87. </xsl:otherwise>
  88. </xsl:choose>
  89. </param>
  90. </xts:append>
  91. <xts:delete select="/root/env/param[@name='m_cube_password' or @name='test_cube_password' or @name='m_cube_confirm_password']"/>
  92. </xsl:if>
  93. </xts:sequence>
  94. </xsl:template>
  95. </xsl:stylesheet>