Removed unecessary check in additionalAuthenticationChecks() for null credentials in authentication object. Previous line already throws an exception if null is found.

This commit is contained in:
Luke Taylor 2007-11-28 19:20:33 +00:00
parent 88e01624eb
commit 09c588a138
2 changed files with 2 additions and 11 deletions

View File

@ -63,8 +63,7 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication
includeDetailsObject ? userDetails : null);
}
String presentedPassword = authentication.getCredentials() == null ? "" : authentication.getCredentials()
.toString();
String presentedPassword = authentication.getCredentials().toString();
if (!passwordEncoder.isPasswordValid(userDetails.getPassword(), presentedPassword, salt)) {
throw new BadCredentialsException(messages.getMessage(

View File

@ -55,14 +55,6 @@ import java.util.Map;
public class DaoAuthenticationProviderTests extends TestCase {
//~ Methods ========================================================================================================
public static void main(String[] args) {
junit.textui.TestRunner.run(DaoAuthenticationProviderTests.class);
}
public final void setUp() throws Exception {
super.setUp();
}
public void testAuthenticateFailsForIncorrectPasswordCase() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "KOala");
@ -86,7 +78,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken("marissa", null);
try {
provider.authenticate(authenticationToken); // null pointer exception
provider.authenticate(authenticationToken);
fail("Expected BadCredenialsException");
} catch (BadCredentialsException expected) {
assertTrue(true);