mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-14 14:23:30 +00:00
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:
parent
88e01624eb
commit
09c588a138
@ -63,8 +63,7 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication
|
|||||||
includeDetailsObject ? userDetails : null);
|
includeDetailsObject ? userDetails : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
String presentedPassword = authentication.getCredentials() == null ? "" : authentication.getCredentials()
|
String presentedPassword = authentication.getCredentials().toString();
|
||||||
.toString();
|
|
||||||
|
|
||||||
if (!passwordEncoder.isPasswordValid(userDetails.getPassword(), presentedPassword, salt)) {
|
if (!passwordEncoder.isPasswordValid(userDetails.getPassword(), presentedPassword, salt)) {
|
||||||
throw new BadCredentialsException(messages.getMessage(
|
throw new BadCredentialsException(messages.getMessage(
|
||||||
|
@ -55,14 +55,6 @@ import java.util.Map;
|
|||||||
public class DaoAuthenticationProviderTests extends TestCase {
|
public class DaoAuthenticationProviderTests extends TestCase {
|
||||||
//~ Methods ========================================================================================================
|
//~ Methods ========================================================================================================
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
junit.textui.TestRunner.run(DaoAuthenticationProviderTests.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void setUp() throws Exception {
|
|
||||||
super.setUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testAuthenticateFailsForIncorrectPasswordCase() {
|
public void testAuthenticateFailsForIncorrectPasswordCase() {
|
||||||
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "KOala");
|
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa", "KOala");
|
||||||
|
|
||||||
@ -86,7 +78,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
|
|||||||
|
|
||||||
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken("marissa", null);
|
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken("marissa", null);
|
||||||
try {
|
try {
|
||||||
provider.authenticate(authenticationToken); // null pointer exception
|
provider.authenticate(authenticationToken);
|
||||||
fail("Expected BadCredenialsException");
|
fail("Expected BadCredenialsException");
|
||||||
} catch (BadCredentialsException expected) {
|
} catch (BadCredentialsException expected) {
|
||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user