SEC-1867: Perform null check on Authentication.getCredentials() prior to calling toString()

This commit is contained in:
Rob Winch
2011-12-30 13:59:04 -06:00
parent 448a42916d
commit 1f835fec43
4 changed files with 29 additions and 2 deletions

View File

@@ -57,7 +57,8 @@ public class RemoteAuthenticationProvider implements AuthenticationProvider, Ini
public Authentication authenticate(Authentication authentication)
throws AuthenticationException {
String username = authentication.getPrincipal().toString();
String password = authentication.getCredentials().toString();
Object credentials = authentication.getCredentials();
String password = credentials == null ? null : credentials.toString();
Collection<? extends GrantedAuthority> authorities = remoteAuthenticationManager.attemptAuthentication(username, password);
return new UsernamePasswordAuthenticationToken(username, password, authorities);