use of org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder in project spring-security by spring-projects.
the class DaoAuthenticationProviderTests method testGettersSetters.
@Test
public void testGettersSetters() {
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setPasswordEncoder(new BCryptPasswordEncoder());
assertThat(provider.getPasswordEncoder().getClass()).isEqualTo(BCryptPasswordEncoder.class);
provider.setUserCache(new SpringCacheBasedUserCache(mock(Cache.class)));
assertThat(provider.getUserCache().getClass()).isEqualTo(SpringCacheBasedUserCache.class);
assertThat(provider.isForcePrincipalAsString()).isFalse();
provider.setForcePrincipalAsString(true);
assertThat(provider.isForcePrincipalAsString()).isTrue();
}
use of org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder in project OsmAnd-tools by osmandapp.
the class WebSecurityConfiguration method passwordEncoder.
@Bean
public PasswordEncoder passwordEncoder() {
DelegatingPasswordEncoder delegatingPasswordEncoder = (DelegatingPasswordEncoder) PasswordEncoderFactories.createDelegatingPasswordEncoder();
delegatingPasswordEncoder.setDefaultPasswordEncoderForMatches(new BCryptPasswordEncoder());
return delegatingPasswordEncoder;
}
use of org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder in project fw-cloud-framework by liuweijw.
the class UserController method modify.
/**
* 修改用户密码
*/
@RequestMapping(value = "/modify", method = RequestMethod.POST)
@PrePermissions(value = Functional.UPD)
public R<Boolean> modify(HttpServletRequest request, @RequestBody UserForm userForm) {
if (null == userForm.getUsername())
return new R<Boolean>().failure("用户名不存在");
if (null == userForm.getPassword())
return new R<Boolean>().failure("请输入旧密码");
if (null == userForm.getNewpassword())
return new R<Boolean>().failure("请输入新密码");
User user = this.userService.findUserByUsername(userForm.getUsername().trim(), false);
if (null == user)
return new R<Boolean>().failure("用户名不存在");
if (!new BCryptPasswordEncoder().matches(userForm.getPassword().trim(), user.getPassword()))
return new R<Boolean>().failure("旧密码输入错误!");
user.setPassword(new BCryptPasswordEncoder().encode(userForm.getNewpassword().trim()));
boolean r = this.userService.updateUser(user);
return new R<Boolean>().data(r);
}
Aggregations