upgrade-05-06.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <html>
  2. <head>
  3. <title>Acegi Security - Upgrading from version 0.3 to 0.4</title>
  4. </head>
  5. <body>
  6. <h1>Upgrading from 0.5 to 0.6</h1>
  7. <p>
  8. The following should help most casual users of the project update their
  9. applications:
  10. <ul>
  11. <li>
  12. Locate and remove all property references to
  13. DaoAuthenticationProvider.key and
  14. DaoAuthenticationProvider.refreshTokenInterval.</li>
  15. <li>If you are using DaoAuthenticationProvider and either (i) you are using
  16. container adapters or (ii) your code relies on the Authentication object
  17. having its getPrincipal() return a String, you must set the new
  18. DaoAuthenticationProvider property, forcePrincipalAsString, to true.
  19. By default DaoAuthenticationProvider returns an Authentication object
  20. containing the relevant User, which allows access to additional properties.
  21. Where possible, we recommend you change your code to something like this,
  22. so that you can leave forcePrincipalAsString to the false default:<br><br>
  23. <code>
  24. String username = authentication.getPrincipal();<br>
  25. if (authentication.getPrincipal() instanceof User) {<br>
  26. username = ((User) authentication.getPrincipal()).getUsername();<br>
  27. }</br>
  28. </code><br>
  29. </li>
  30. <li>The signature of AuthenticationDaos have changed. In concrete
  31. implementations, modify the User to UserDetails, as shown below:<br><br>
  32. <code>
  33. public User loadUserByUsername(String username)<br>
  34. throws UsernameNotFoundException, DataAccessException {<br><br>
  35. to:<br><br>
  36. public UserDetails loadUserByUsername(String username)<br>
  37. throws UsernameNotFoundException, DataAccessException {<br><br>
  38. </code>
  39. Existing concrete implementations would be returning User, which implements
  40. UserDetails, so no further code changes should be required.
  41. </li>
  42. <li>Similar signature changes (User -> UserDetails) are also required to any
  43. custom implementations of UserCache and SaltSource.</li>
  44. <li>Any custom event listeners relying on AuthenticationEvent should note a
  45. UserDetails is now provided in the AuthenticationEvent (not a User).</li>
  46. <li>CAS users should note the CasAuthoritiesPopulator interface signature has
  47. changed. Most CAS users will be using DaoCasAuthoritiesPopulator, so this
  48. change is unlikely to require any action.</li>
  49. <li>Please check your web.xml for whether you are using AutoIntegrationFilter.
  50. Previously this class was loaded directly by web.xml as a filter. It is
  51. now recommended to load it via FilterToBeanProxy and define it as a
  52. bean in your application context. This usually involves making the entry
  53. in web.xml match the following:<br><br>
  54. <code>
  55. &lt;filter&gt;<br>
  56. &lt;filter-name&gt;Acegi Security System for Spring Auto Integration Filter&lt;/filter-name&gt;<br>
  57. &lt;filter-class&gt;net.sf.acegisecurity.util.FilterToBeanProxy&lt;/filter-class&gt;<br>
  58. &lt;init-param&gt;<br>
  59. &lt;param-name&gt;targetClass&lt;/param-name&gt;<br>
  60. &lt;param-value&gt;net.sf.acegisecurity.ui.AutoIntegrationFilter&lt;/param-value&gt;<br>
  61. &lt;/init-param&gt;<br>
  62. &lt;/filter&gt;<br>
  63. </code>
  64. <br><br>
  65. Then add the following to applicationContext.xml: <br><br>
  66. <code>
  67. &lt;bean id="autoIntegrationFilter" class="net.sf.acegisecurity.ui.AutoIntegrationFilter"/&gt;<br>
  68. </code>
  69. </li>
  70. </ul>
  71. </body>
  72. </html>