本文整理匯總了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);
}