diff --git a/core/src/main/java/org/springframework/security/providers/dao/DaoAuthenticationProvider.java b/core/src/main/java/org/springframework/security/providers/dao/DaoAuthenticationProvider.java index ee22b39894..8da96d46e1 100644 --- a/core/src/main/java/org/springframework/security/providers/dao/DaoAuthenticationProvider.java +++ b/core/src/main/java/org/springframework/security/providers/dao/DaoAuthenticationProvider.java @@ -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( diff --git a/core/src/test/java/org/springframework/security/providers/dao/DaoAuthenticationProviderTests.java b/core/src/test/java/org/springframework/security/providers/dao/DaoAuthenticationProviderTests.java index 36b0450f54..5c76f9ed24 100644 --- a/core/src/test/java/org/springframework/security/providers/dao/DaoAuthenticationProviderTests.java +++ b/core/src/test/java/org/springframework/security/providers/dao/DaoAuthenticationProviderTests.java @@ -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);