getsession.xts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cpscrn
  5. (C) Copyright IBM Corp. 2005, 2014
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <xts:morphlet version="1.0" xmlns:xts="http://developer.cognos.com/schemas/xts/" messageBase="/cps4/portlets/nav/messages/cpsnavmsgs.xml">
  9. <xts:block id="getconfig" type="exec" mode="interpret" processor="XSLT">
  10. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  11. <xsl:template match="/">
  12. <xts:sequence>
  13. <xts:append>
  14. <xts:function name="getConfiguration">
  15. <xts:param name="CPSPropagatePassport"/>
  16. </xts:function>
  17. </xts:append>
  18. </xts:sequence>
  19. </xsl:template>
  20. </xsl:stylesheet>
  21. </xts:block>
  22. <xts:block id="render" type="exec" mode="output" processor="XSLT" mimeType="text/html" dependency="getconfig">
  23. <xsl:stylesheet version="1.0" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xts="http://developer.cognos.com/schemas/xts/">
  24. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
  25. <xsl:template match="/">
  26. <xsl:variable name="context" select="/root/env/param[@name='context']"/>
  27. <xsl:variable name="sinfo" select="xtsext:javascriptencode(/root/env/param[@name='sinfo'])"/>
  28. <xsl:variable name="target" select="/root/env/param[@name='target']"/>
  29. <xsl:variable name="is-target-valid" select="xtsext:cafaction('checkurlhostdomain_null', $target) = 'true'"/>
  30. <xsl:variable name="cookies">
  31. <xsl:for-each select="/root/cookies/cookie">
  32. <xsl:if test="position() > 1">
  33. <xsl:text>,</xsl:text>
  34. </xsl:if>
  35. <xsl:choose>
  36. <xsl:when test="/root/configuration/property[@name='CPSPropagatePassport'] = 'true'">
  37. <xsl:if test="@name != 'cam_passport'">
  38. <xsl:value-of select="@name"/>
  39. <xsl:text>=</xsl:text>
  40. <xsl:value-of select="xtsext:javascriptencode(.)"/>
  41. </xsl:if>
  42. </xsl:when>
  43. <xsl:otherwise>
  44. <xsl:value-of select="@name"/>
  45. <xsl:text>=</xsl:text>
  46. <xsl:value-of select="xtsext:javascriptencode(.)"/>
  47. </xsl:otherwise>
  48. </xsl:choose>
  49. </xsl:for-each>
  50. </xsl:variable>
  51. <html>
  52. <head>
  53. <meta name="Copyright" content="(C) Copyright IBM Corp. 2005, 2014"/>
  54. <meta name="Trademark" content="Licensed Material - Property of IBM Corp. IBM, the IBM logo, and Cognos are trademarks of IBM Corp., registered in many jurisdictions worldwide."/>
  55. <title></title>
  56. <script language="javascript">
  57. function loaded(){
  58. <xsl:choose>
  59. <xsl:when test="$sinfo">
  60. <xsl:if test="$context">
  61. if (window.parent) {
  62. var context = window.parent["<xsl:value-of select="xtsext:javascriptencode($context)"/>"];
  63. <!-- communication session result -->
  64. if (context){
  65. context.sessionInfo = "<xsl:value-of select="xtsext:javascriptencode($sinfo)"/>";
  66. }
  67. }
  68. </xsl:if>
  69. </xsl:when>
  70. <xsl:otherwise>
  71. <!-- retrieve session info and send it to the trusted target -->
  72. <xsl:choose>
  73. <xsl:when test="$is-target-valid">
  74. var formElement = document.createElement("form");
  75. formElement.setAttribute("method","POST");
  76. formElement.setAttribute("action","<xsl:value-of select="xtsext:javascriptencode($target)"/>");
  77. hiddenElement = document.createElement("input");
  78. hiddenElement.setAttribute("type","hidden");
  79. hiddenElement.setAttribute("name","sinfo");
  80. hiddenElement.setAttribute("value","<xsl:value-of select="xtsext:javascriptencode($cookies)"/>");
  81. formElement.appendChild(hiddenElement);
  82. document.body.appendChild(formElement);
  83. formElement.submit();
  84. document.body.removeChild(formElement);
  85. formElement = null;
  86. </xsl:when>
  87. <xsl:otherwise>
  88. alert("<xts:string id="IDS_DOMAIN_NOT_TRUSTED"/>");
  89. </xsl:otherwise>
  90. </xsl:choose>
  91. </xsl:otherwise>
  92. </xsl:choose>
  93. }
  94. </script>
  95. </head>
  96. <body onload="loaded()">
  97. </body>
  98. </html>
  99. </xsl:template>
  100. </xsl:stylesheet>
  101. </xts:block>
  102. </xts:morphlet>