upgrade-05-06.xml 3.5 KB

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