upgrade-080-090.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <html>
  2. <head>
  3. <title>Acegi Security - Upgrading from version 0.8.0 to 0.9.0</title>
  4. </head>
  5. <body>
  6. <h1>Upgrading from 0.8.0 to 0.9.0</h1>
  7. <p>
  8. The following should help most casual users of the project update their
  9. applications:
  10. <ul>
  11. <li>The most significant change in 0.9.0 is that <code>ContextHolder</code> and all of its
  12. related classes have been removed. This significant change was made for the sake of consistency
  13. with the core Spring project's approach of a single <code>ThreadLocal</code> per use case,
  14. instead of a shared <code>ThreadLocal</code> for multiple use cases as the previous
  15. <code>ContextHolder</code> allowed. <b>This is an important change in 0.9.0.</b> Many applications
  16. will need to modify their code (and possibly web views) if they directly interact with the old
  17. <code>ContextHolder</code>. The replacement security <code>ThreadLocal</code> is called
  18. <a href="../multiproject/acegi-security/xref/net/sf/acegisecurity/context/SecurityContextHolder.html">
  19. SecurityContextHolder</a> and provides a single getter/setter for a
  20. <a href="../multiproject/acegi-security/xref/net/sf/acegisecurity/context/SecurityContextHolder.html">SecurityContext</a>.
  21. <code>SecurityContextHolder</code> guarantees to never return a <code>null</code> <code>SecurityContext</code>.
  22. <code>SecurityContext</code> provides single getter/setter for <code>Authentication</code>.<BR><BR>
  23. To migrate, simply modify all your code that previously worked with <code>ContextHolder</code>,
  24. <code>SecureContext</code> and <code>Context</code> to directly call <code>SecurityContextHolder</code>
  25. and work with the <code>SecurityContext</code> (instead of the now removed <code>Context</code>
  26. and <code>SecureContext</code> interfaces).<br><br>
  27. For example, change:<br>
  28. <code>
  29. SecureContext ctx = SecureContextUtils.getSecureContext();<br>
  30. </code>
  31. to:<br>
  32. <code>
  33. SecurityContext ctx = SecurityContextHolder.getContext();<br>
  34. </code>
  35. <br>
  36. and change:<br>
  37. <code>
  38. &lt;bean id="httpSessionContextIntegrationFilter" class="net.sf.acegisecurity.context.HttpSessionContextIntegrationFilter"><br>
  39. &lt;property name="context">&lt;value>net.sf.acegisecurity.context.security.SecureContextImpl&lt;/value>&lt;/property><br>
  40. &lt;/bean><br>
  41. </code>
  42. to:<br>
  43. <code>
  44. &lt;bean id="httpSessionContextIntegrationFilter" class="net.sf.acegisecurity.context.HttpSessionContextIntegrationFilter"><br>
  45. &lt;property name="context">&lt;value>net.sf.acegisecurity.context.SecurityContextImpl&lt;/value>&lt;/property><br>
  46. &lt;/bean><br>
  47. </code>
  48. <br>
  49. We apologise for the inconvenience, but on a more positive note this means you receive strict
  50. type checking, you no longer need to mess around with casting to and from <code>Context</code>
  51. implementations, your applications no longer need to perform checking of <code>null</code> and
  52. unexpected <code>Context</code> implementation types.<br><br></li>
  53. <li><code>AbstractProcessingFilter</code> has changed its getter/setter approach used for customised
  54. authentication exception directions. See the <a href="../multiproject/acegi-security/xref/net/sf/acegisecurity/ui/AbstractProcessingFilter.html">
  55. <code>AbstractProcessingFilter</code> JavaDocs</a> to learn more.<br><br></li>
  56. <li><code>AnonymousProcessingFilter</code> now has a <code>removeAfterRequest</code> property, which defaults to <code>true</code>. This
  57. will cause the anonymous authentication token to be set to null at the end of each request, thus
  58. avoiding the expense of creating a <code>HttpSession</code> in <code>HttpSessionContextIntegrationFilter</code>. You may
  59. set this property to false if you would like the anoymous authentication token to be preserved,
  60. which would be an unusual requirement.<br><br></li>
  61. <li>Event publishing has been refactored. New event classes have been added, and the location of
  62. <code>LoggerListener</code> has changed. See the <code>net.sf.acegisecurity.event package</code>.<BR>
  63. <br>
  64. For example, change:<br>
  65. <code>
  66. &lt;bean id="loggerListener" class="net.sf.acegisecurity.providers.dao.event.LoggerListener"/><br>
  67. </code>
  68. to:<br>
  69. <code>
  70. &lt;bean id="loggerListener" class="net.sf.acegisecurity.event.authentication.LoggerListener"/>
  71. </code><br><br>
  72. </li>
  73. <li>Users of the <code>&lt;authz:authentication></code> JSP tag will generally need to set the <code>operation</code>
  74. property equal to "username", as reflection is now used to retrieve the property displayed.<br><br></li>
  75. <li>
  76. Users of <code>net.sf.acegisecurity.wrapper.ContextHolderAwareRequestFilter</code> should note that it has been
  77. renamed to <code>net.sf.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter</code>.<br><br>
  78. </li>
  79. <li>
  80. The concurrent session support handling has changed. Please refer to the Reference Guide to
  81. review the new configuration requirements.<br><br>
  82. </li>
  83. </ul>
  84. </body>
  85. </html>