mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-27 14:22:47 +00:00
Improved detection of invalid parameters in constructors.
This commit is contained in:
parent
3179f5f1e7
commit
489c941101
@ -46,17 +46,24 @@ public class User {
|
|||||||
* @param authorities the authorities that should be granted to the caller
|
* @param authorities the authorities that should be granted to the caller
|
||||||
* if they presented the correct username and password and the user
|
* if they presented the correct username and password and the user
|
||||||
* is enabled
|
* is enabled
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException if a <code>null</code> value was passed
|
||||||
*/
|
*/
|
||||||
public User(String username, String password, boolean enabled,
|
public User(String username, String password, boolean enabled,
|
||||||
GrantedAuthority[] authorities) {
|
GrantedAuthority[] authorities) throws IllegalArgumentException {
|
||||||
|
if ((username == null) || (password == null) || (authorities == null)) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"Cannot pass null values to constructor");
|
||||||
|
}
|
||||||
|
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
this.authorities = authorities;
|
this.authorities = authorities;
|
||||||
}
|
}
|
||||||
|
|
||||||
private User() {
|
protected User() {
|
||||||
super();
|
throw new IllegalArgumentException("Cannot use default constructor");
|
||||||
}
|
}
|
||||||
|
|
||||||
//~ Methods ================================================================
|
//~ Methods ================================================================
|
||||||
|
Loading…
x
Reference in New Issue
Block a user