mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-29 15:22:15 +00:00
SEC-327: Add includeDetailsObject property.
This commit is contained in:
parent
f28ce39bde
commit
f0ae6f53a7
@ -44,6 +44,7 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication
|
|||||||
private PasswordEncoder passwordEncoder = new PlaintextPasswordEncoder();
|
private PasswordEncoder passwordEncoder = new PlaintextPasswordEncoder();
|
||||||
private SaltSource saltSource;
|
private SaltSource saltSource;
|
||||||
private UserDetailsService userDetailsService;
|
private UserDetailsService userDetailsService;
|
||||||
|
private boolean includeDetailsObject = true;
|
||||||
|
|
||||||
//~ Methods ========================================================================================================
|
//~ Methods ========================================================================================================
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication
|
|||||||
|
|
||||||
if (!passwordEncoder.isPasswordValid(userDetails.getPassword(), authentication.getCredentials().toString(), salt)) {
|
if (!passwordEncoder.isPasswordValid(userDetails.getPassword(), authentication.getCredentials().toString(), salt)) {
|
||||||
throw new BadCredentialsException(messages.getMessage(
|
throw new BadCredentialsException(messages.getMessage(
|
||||||
"AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"), userDetails);
|
"AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"), includeDetailsObject ? userDetails : null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,4 +121,12 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication
|
|||||||
public void setUserDetailsService(UserDetailsService userDetailsService) {
|
public void setUserDetailsService(UserDetailsService userDetailsService) {
|
||||||
this.userDetailsService = userDetailsService;
|
this.userDetailsService = userDetailsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isIncludeDetailsObject() {
|
||||||
|
return includeDetailsObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIncludeDetailsObject(boolean includeDetailsObject) {
|
||||||
|
this.includeDetailsObject = includeDetailsObject;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,6 +120,7 @@ public class LdapAuthenticationProvider extends AbstractUserDetailsAuthenticatio
|
|||||||
|
|
||||||
private LdapAuthenticator authenticator;
|
private LdapAuthenticator authenticator;
|
||||||
private LdapAuthoritiesPopulator authoritiesPopulator;
|
private LdapAuthoritiesPopulator authoritiesPopulator;
|
||||||
|
private boolean includeDetailsObject = true;
|
||||||
|
|
||||||
//~ Constructors ===================================================================================================
|
//~ Constructors ===================================================================================================
|
||||||
|
|
||||||
@ -159,7 +160,7 @@ public class LdapAuthenticationProvider extends AbstractUserDetailsAuthenticatio
|
|||||||
throws AuthenticationException {
|
throws AuthenticationException {
|
||||||
if (!userDetails.getPassword().equals(authentication.getCredentials().toString())) {
|
if (!userDetails.getPassword().equals(authentication.getCredentials().toString())) {
|
||||||
throw new BadCredentialsException(messages.getMessage(
|
throw new BadCredentialsException(messages.getMessage(
|
||||||
"AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"), userDetails);
|
"AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"), includeDetailsObject ? userDetails : null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,4 +221,13 @@ public class LdapAuthenticationProvider extends AbstractUserDetailsAuthenticatio
|
|||||||
throw new AuthenticationServiceException(ldapAccessFailure.getMessage(), ldapAccessFailure);
|
throw new AuthenticationServiceException(ldapAccessFailure.getMessage(), ldapAccessFailure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isIncludeDetailsObject() {
|
||||||
|
return includeDetailsObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIncludeDetailsObject(boolean includeDetailsObject) {
|
||||||
|
this.includeDetailsObject = includeDetailsObject;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user