Add User/UserBuilder in UserDetailsManagerConfigurer

Fixes gh-4679
This commit is contained in:
Rob Winch 2017-10-23 12:50:45 -05:00
parent 1ea10a1e89
commit 7c95c88601
1 changed files with 31 additions and 0 deletions

View File

@ -43,6 +43,8 @@ public class UserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>, C
private final List<UserDetailsBuilder> userBuilders = new ArrayList<UserDetailsBuilder>();
private final List<UserDetails> users = new ArrayList<>();
protected UserDetailsManagerConfigurer(UserDetailsManager userDetailsManager) {
super(userDetailsManager);
}
@ -57,6 +59,35 @@ public class UserDetailsManagerConfigurer<B extends ProviderManagerBuilder<B>, C
for (UserDetailsBuilder userBuilder : userBuilders) {
getUserDetailsService().createUser(userBuilder.build());
}
for (UserDetails userDetails : this.users) {
getUserDetailsService().createUser(userDetails);
}
}
/**
* Allows adding a user to the {@link UserDetailsManager} that is being created. This
* method can be invoked multiple times to add multiple users.
*
* @param userDetails the user to add. Cannot be null.
* @return
*/
@SuppressWarnings("unchecked")
public final C withUser(UserDetails userDetails) {
this.users.add(userDetails);
return (C) this;
}
/**
* Allows adding a user to the {@link UserDetailsManager} that is being created. This
* method can be invoked multiple times to add multiple users.
*
* @param userBuilder the user to add. Cannot be null.
* @return
*/
@SuppressWarnings("unchecked")
public final C withUser(User.UserBuilder userBuilder) {
this.users.add(userBuilder.build());
return (C) this;
}
/**