NGrinderAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider { @Transactional public void addNewUserIntoLocal(SecuredUser securedUser) { User user = securedUser.getUser(); user.setAuthProviderClass(securedUser.getUserInfoProviderClass()); user.setCreatedDate(new Date()); User newUser = userService.getOne(user.getUserId()); if (newUser != null) { user = newUser.merge(user); } if (user.getRole() == null) { user.setRole(Role.USER); } User savedUser = userService.save(user); securedUser.setUser(savedUser); } NGrinderAuthenticationProvider(PluginManager pluginManager, DefaultLoginPlugin defaultLoginPlugin, DefaultLdapLoginPlugin defaultLdapLoginPlugin,
										  @Lazy ShaPasswordEncoder passwordEncoder, UserDetailsService userDetailsService, UserService userService); @Transactional void addNewUserIntoLocal(SecuredUser securedUser);  }
@Test public void testAddNewUserIntoLocal() { User user = User.createNew(); user.setEmail("aaa@hello.com"); user.setUserId("new_user"); user.setPassword("new_user"); user.setUserName("new_user"); provider.addNewUserIntoLocal(new SecuredUser(user, null)); UserDetails userDetails = userDetailService.loadUserByUsername(user.getUserId()); assertThat(userDetails.getUsername(), equalTo(user.getUserId())); }