set_session.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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, 2015
  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:xsl="http://www.w3.org/1999/XSL/Transform"
  13. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  14. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  15. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  16. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  17. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
  18. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  19. <xsl:key name="env-param" match="/root/env/param" use="@name"/>
  20. <xsl:variable name="portal.protectSessionCookies" select="string(/root/configProps/param[@name='cc']/property[@name='portal.protectSessionCookies']) = 'true'"/>
  21. <xsl:template match="/root">
  22. <xts:sequence>
  23. <!-- In a "pure" SOAP request to XTS the setCookieVars element may not exist. If not, we will need to create one. -->
  24. <xsl:if test="not(/root/output/*[local-name() = 'protocolHeader']/*[local-name() = 'param' and @name = 'setSoapHeader']/*[local-name() = 'Header']/*[local-name() = 'biBusHeader']/*[local-name() = 'hdrSession']/*[local-name() = 'setCookieVars'])">
  25. <xts:append select="/root/output/*[local-name() = 'protocolHeader']/*[local-name() = 'param' and @name = 'setSoapHeader']/*[local-name() = 'Header']/*[local-name() = 'biBusHeader']/*[local-name() = 'hdrSession']">
  26. <bus:setCookieVars xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:setCookieVar[]"/>
  27. </xts:append>
  28. </xsl:if>
  29. <xts:append select="/root/output/*[local-name() = 'protocolHeader']/*[local-name() = 'param' and @name = 'setSoapHeader']/*[local-name() = 'Header']/*[local-name() = 'biBusHeader']/*[local-name() = 'hdrSession']/*[local-name() = 'setCookieVars']">
  30. <item xsi:type="bus:setCookieVar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  31. <name xsi:type="xsd:string">cc_session</name>
  32. <value xsi:type="xsd:string">
  33. <xsl:variable name="d1" select="system/param[@name = 'delimiters']/@d1"/>
  34. <xsl:variable name="d2" select="system/param[@name = 'delimiters']/@d2"/>
  35. <xsl:variable name="cc_session_cookie">
  36. <xsl:variable name="cc_session_value">
  37. <xsl:for-each select="/root/session/*[ not( @name='ssshsh' or starts-with(@name,'b_') or @name = 'edit' or @name = 'debug' or @name = 'us' or @type='CRN' or @type='NOPATH') ]">
  38. <xsl:if test="position() != 1">
  39. <xsl:value-of select="$d1"/>
  40. </xsl:if>
  41. <xsl:value-of select="@name"/><xsl:value-of select="$d2"/>
  42. <xsl:choose>
  43. <!-- Encode these values since they may contain none-ascii chars. -->
  44. <xsl:when test="starts-with(@name, 'e_')">
  45. <xsl:value-of select="xtsext:encodeCCSessionValue(string(.))"/>
  46. </xsl:when>
  47. <xsl:otherwise>
  48. <xsl:value-of select="."/>
  49. </xsl:otherwise>
  50. </xsl:choose>
  51. </xsl:for-each>
  52. </xsl:variable>
  53. <xsl:choose>
  54. <xsl:when test="$portal.protectSessionCookies">
  55. <!-- Note: Will switch to xtsext:protectCCSessionCookie() call in main -->
  56. <xsl:variable name="signed" select="string(xtsext:validator('prepare','cc_session',$cc_session_value))"/>
  57. <xsl:variable name="hash" select="substring-before(string($signed),'|')"/>
  58. <xsl:variable name="hash_ccSessionEncoded" select="xtsext:encodeCCSessionValue(string($hash))"/>
  59. <xsl:value-of select="'ssshsh'"/>
  60. <xsl:value-of select="$d2"/>
  61. <xsl:value-of select="$hash_ccSessionEncoded"/>
  62. <xsl:value-of select="'|'"/>
  63. <xsl:value-of select="$cc_session_value"/>
  64. </xsl:when>
  65. <xsl:otherwise>
  66. <xsl:value-of select="$cc_session_value"/>
  67. </xsl:otherwise>
  68. </xsl:choose>
  69. </xsl:variable>
  70. <xsl:value-of select="$cc_session_cookie"/>
  71. </value>
  72. <maxAge xsi:type="xsd:int">0</maxAge>
  73. </item>
  74. <!-- MVC -->
  75. <!-- Build a server-independent cookie to indicate mvc is enabled. This is used to in authentication, goHome, etc... functionalities -->
  76. <xsl:for-each select="/root/session/*[@type='NOPATH']">
  77. <item xsi:type="bus:setCookieVar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  78. <name xsi:type="xsd:string"><xsl:value-of select="@name"/></name>
  79. <value xsi:type="xsd:string"></value>
  80. <path xsi:type="xsd:string">/</path>
  81. <maxAge xsi:type="xsd:int">0</maxAge>
  82. </item>
  83. </xsl:for-each>
  84. <!-- Delete any cookie(s) if requested -->
  85. <xsl:for-each select="/root/deleteCookies/cookies/cookie">
  86. <item xsi:type="bus:setCookieVar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  87. <name xsi:type="xsd:string"><xsl:value-of select="@name"/></name>
  88. <value xsi:type="xsd:string"></value>
  89. <maxAge xsi:type="xsd:int">-1</maxAge>
  90. </item>
  91. </xsl:for-each>
  92. </xts:append>
  93. </xts:sequence>
  94. </xsl:template>
  95. </xsl:stylesheet>