本文整理汇总了Java中org.springframework.security.crypto.password.PasswordEncoder.encode方法的典型用法代码示例。如果您正苦于以下问题:Java PasswordEncoder.encode方法的具体用法?Java PasswordEncoder.encode怎么用?Java PasswordEncoder.encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.security.crypto.password.PasswordEncoder
的用法示例。
在下文中一共展示了PasswordEncoder.encode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: change
import org.springframework.security.crypto.password.PasswordEncoder; //导入方法依赖的package包/类
@Audit(action = "CHANGE_PASSWORD",
actionResolverName = "CHANGE_PASSWORD_ACTION_RESOLVER",
resourceResolverName = "CHANGE_PASSWORD_RESOURCE_RESOLVER")
@Override
public boolean change(final Credential credential, final PasswordChangeBean bean) {
Assert.notNull(credential, "Credential cannot be null");
Assert.notNull(bean, "PasswordChangeBean cannot be null");
final UsernamePasswordCredential c = (UsernamePasswordCredential) credential;
final PasswordEncoder encoder = Beans.newPasswordEncoder(passwordManagementProperties.getJdbc().getPasswordEncoder());
final String password = encoder.encode(bean.getPassword());
final int count = this.jdbcTemplate.update(passwordManagementProperties.getJdbc().getSqlChangePassword(), password, c.getId());
return count > 0;
}
示例2: testStandardPasswordEncoder
import org.springframework.security.crypto.password.PasswordEncoder; //导入方法依赖的package包/类
@Test
public void testStandardPasswordEncoder(){
PasswordEncoder passwordEncoder = new StandardPasswordEncoder("web_qq");
String password1 = passwordEncoder.encode("12345");
String password2 = passwordEncoder.encode("mingguobin4");
System.out.println("password1:"+password1);
System.out.println("password2:"+password2);
System.out.println(passwordEncoder.matches("mingguobin4",password1));
}
示例3: testGenPwd
import org.springframework.security.crypto.password.PasswordEncoder; //导入方法依赖的package包/类
public void testGenPwd() {
String pwd = "nevergiveupnevergivein";
PasswordEncoder pe = new BCryptPasswordEncoder();
String genPwd = pe.encode(pwd);
System.out.println(genPwd);
System.out.println(pe.matches(pwd, genPwd));
}
示例4: User
import org.springframework.security.crypto.password.PasswordEncoder; //导入方法依赖的package包/类
/**
* Constructor used during registration. It fills in the nessecary parts of the User.
*
* @param dto A DTO used to receive registration data.
*/
User(RegistrationDTO dto) {
PasswordEncoder encoder = new BCryptPasswordEncoder();
this.email = dto.getEmail();
this.password = encoder.encode(dto.getPassword());
this.role = "USER";
this.resetPasswordLink = new AuthenticationLink("", 0);
this.validateEmailLink = new AuthenticationLink("", 0);
this.createdAt = DateTime.now().getMillis();
this.updatedAt = DateTime.now().getMillis();
this.organization = new Organization();
if(dto.getOrganization().equals("")) {
this.organization.setChangePending("_");
}
else {
this.organization.setChangePending(dto.getOrganization());
}
this.organization.setApproved(false);
this.emailChange = dto.getEmail();
}
示例5: changePassword
import org.springframework.security.crypto.password.PasswordEncoder; //导入方法依赖的package包/类
/**
* Setta la password e anche il suo timestamp e cancella il flag di change password
* @param password
*/
public void changePassword(String password, PasswordEncoder encoder) {
if (encoder!=null) {
password=encoder.encode(password);
}
this.password = password;
this.passwordDate = new Date();
this.changePassword = false;
this.failedAttempts = 0;
}
示例6: setPassword
import org.springframework.security.crypto.password.PasswordEncoder; //导入方法依赖的package包/类
/**
* Setter
* @param password New unencoded password of the User
*/
void setPassword(String password) {
PasswordEncoder encoder = new BCryptPasswordEncoder();
this.password = encoder.encode(password);
}
示例7: encryptPassword
import org.springframework.security.crypto.password.PasswordEncoder; //导入方法依赖的package包/类
public static String encryptPassword(String rawPassword) {
PasswordEncoder passwordEncoder = createPasswordEncoder();
return passwordEncoder.encode(rawPassword);
}