acegi-web.xsl 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. | XSL Sheet used by the web.xml to acegi-security beans converter
  4. | to create the new acegified web.xml.
  5. | $Id$
  6. -->
  7. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  8. <!-- The CAS proxy url (left empty if not to be used) -->
  9. <xsl:param name="cas-proxy-url"/>
  10. <!-- The acegi context file name - used in the -->
  11. <xsl:param name="acegi-security-context-file" select="'applicationContext-acegi-security.xml'"/>
  12. <xsl:output doctype-public="-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
  13. doctype-system="http://java.sun.com/dtd/web-app_2_3.dtd"
  14. indent="yes"/>
  15. <!-- Identity template which we override for specific cases -->
  16. <xsl:template match="@*|node()">
  17. <xsl:copy>
  18. <xsl:apply-templates select="@*|node()"/>
  19. </xsl:copy>
  20. </xsl:template>
  21. <xsl:template match="web-app">
  22. <web-app>
  23. <xsl:apply-templates select="icon|display-name|description|distributable"/>
  24. <xsl:apply-templates select="context-param"/>
  25. <xsl:call-template name="insert-spring-context-param"/>
  26. <xsl:if test="$cas-proxy-url">
  27. <!-- Required for CAS ProxyTicketReceptor servlet. This is the
  28. URL to CAS' "proxy" actuator, where a PGT and TargetService can
  29. be presented to obtain a new proxy ticket. THIS CAN BE
  30. REMOVED IF THE APPLICATION DOESN'T NEED TO ACT AS A PROXY -->
  31. <context-param>
  32. <param-name>edu.yale.its.tp.cas.proxyUrl</param-name>
  33. <param-value><xsl:value-of select="$cas-proxy-url"/></param-value>
  34. </context-param>
  35. </xsl:if>
  36. <filter>
  37. <filter-name>Acegi Filter Chain Proxy</filter-name>
  38. <filter-class>net.sf.acegisecurity.util.FilterToBeanProxy</filter-class>
  39. <init-param>
  40. <param-name>targetClass</param-name>
  41. <param-value>net.sf.acegisecurity.util.FilterChainProxy</param-value>
  42. </init-param>
  43. </filter>
  44. <xsl:apply-templates select="filter"/>
  45. <filter-mapping>
  46. <filter-name>Acegi Filter Chain Proxy</filter-name>
  47. <url-pattern>/*</url-pattern>
  48. </filter-mapping>
  49. <xsl:apply-templates select="filter-mapping"/>
  50. <listener>
  51. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  52. </listener>
  53. <xsl:apply-templates select="listener"/>
  54. <!-- Run any remaining non-security elements through the identity template -->
  55. <xsl:apply-templates select="servlet|servlet-mapping|session-config|mime-mapping|welcome-file-list|error-page|taglib|resource-env-ref|resource-ref|env-entry|ejb-ref|ejb-local-ref"/>
  56. </web-app>
  57. </xsl:template>
  58. <!--
  59. | Looks for the case where we have an existing Spring context and appends
  60. | the acegi file to the list of app. context files. Otherwise just copies the contents.
  61. -->
  62. <xsl:template match="context-param">
  63. <context-param>
  64. <xsl:choose>
  65. <xsl:when test="./param-name = 'contextConfigLocation'">
  66. <param-name>contextConfigLocation</param-name>
  67. <param-value>
  68. <xsl:value-of select="./param-value"/>
  69. <xsl:value-of select="concat(' /WEB-INF/',$acegi-security-context-file)"/><xsl:text>&#xA; </xsl:text>
  70. </param-value>
  71. </xsl:when>
  72. <xsl:otherwise>
  73. <xsl:apply-templates />
  74. </xsl:otherwise>
  75. </xsl:choose>
  76. </context-param>
  77. </xsl:template>
  78. <!--
  79. | Inserts a Spring config location context-param if one doesn't already exist.
  80. | If there is one, do nothing as it will be handled by the context-param template above.
  81. -->
  82. <xsl:template name="insert-spring-context-param">
  83. <xsl:if test="not(./context-param/param-name[string() = 'contextConfigLocation'])">
  84. <context-param>
  85. <param-name>contextConfigLocation</param-name>
  86. <param-value>
  87. <xsl:value-of select="concat('/WEB-INF/',$acegi-security-context-file)"/><xsl:text>&#xA;</xsl:text>
  88. </param-value>
  89. </context-param>
  90. </xsl:if>
  91. </xsl:template>
  92. </xsl:stylesheet>