Added original Authentication.getDetails() to DaoAuthenticationProvider response.
This commit is contained in:
parent
08ee5deaa9
commit
04f4c9881d
|
@ -1,6 +1,8 @@
|
||||||
Changes in version 0.x (2004-xx-xx)
|
Changes in version 0.x (2004-xx-xx)
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
|
* Added additional DaoAuthenticationProvider event when user not found
|
||||||
|
* Added Authentication.getDetails() to DaoAuthenticationProvider response
|
||||||
* Fixed EH-CACHE-based caching implementation behaviour when cache exists
|
* Fixed EH-CACHE-based caching implementation behaviour when cache exists
|
||||||
|
|
||||||
Changes in version 0.6 (2004-08-09)
|
Changes in version 0.6 (2004-08-09)
|
||||||
|
|
|
@ -320,9 +320,15 @@ public class DaoAuthenticationProvider implements AuthenticationProvider,
|
||||||
protected Authentication createSuccessAuthentication(Object principal,
|
protected Authentication createSuccessAuthentication(Object principal,
|
||||||
Authentication authentication, UserDetails user) {
|
Authentication authentication, UserDetails user) {
|
||||||
// Ensure we return the original credentials the user supplied,
|
// Ensure we return the original credentials the user supplied,
|
||||||
// so subsequent attempts are successful even with encoded passwords
|
// so subsequent attempts are successful even with encoded passwords.
|
||||||
return new UsernamePasswordAuthenticationToken(principal,
|
// Also ensure we return the original getDetails(), so that future
|
||||||
authentication.getCredentials(), user.getAuthorities());
|
// authentication events after cache expiry contain the details
|
||||||
|
UsernamePasswordAuthenticationToken result = new UsernamePasswordAuthenticationToken(principal,
|
||||||
|
authentication.getCredentials(), user.getAuthorities());
|
||||||
|
result.setDetails((authentication.getDetails() != null)
|
||||||
|
? authentication.getDetails().toString() : null);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserDetails getUserFromBackend(String username) {
|
private UserDetails getUserFromBackend(String username) {
|
||||||
|
|
|
@ -154,6 +154,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
||||||
public void testAuthenticates() {
|
public void testAuthenticates() {
|
||||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa",
|
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa",
|
||||||
"koala");
|
"koala");
|
||||||
|
token.setDetails("192.168.0.1");
|
||||||
|
|
||||||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
|
||||||
provider.setAuthenticationDao(new MockAuthenticationDaoUserMarissa());
|
provider.setAuthenticationDao(new MockAuthenticationDaoUserMarissa());
|
||||||
|
@ -171,6 +172,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
||||||
assertEquals("koala", castResult.getCredentials());
|
assertEquals("koala", castResult.getCredentials());
|
||||||
assertEquals("ROLE_ONE", castResult.getAuthorities()[0].getAuthority());
|
assertEquals("ROLE_ONE", castResult.getAuthorities()[0].getAuthority());
|
||||||
assertEquals("ROLE_TWO", castResult.getAuthorities()[1].getAuthority());
|
assertEquals("ROLE_TWO", castResult.getAuthorities()[1].getAuthority());
|
||||||
|
assertEquals("192.168.0.1", castResult.getDetails());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAuthenticatesASecondTime() {
|
public void testAuthenticatesASecondTime() {
|
||||||
|
|
Loading…
Reference in New Issue