upgrade-080-090.xml 5.2 KB

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