當前位置: 首頁>>代碼示例>>Java>>正文


Java PasswordEncoder.encode方法代碼示例

本文整理匯總了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;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:14,代碼來源:JdbcPasswordManagementService.java

示例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));
}
 
開發者ID:damingerdai,項目名稱:web-qq,代碼行數:10,代碼來源:PasswordEncoderTest.java

示例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));
}
 
開發者ID:JerryNiu,項目名稱:cloud,代碼行數:8,代碼來源:SimpleTest.java

示例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();
}
 
開發者ID:2DV603NordVisaProject,項目名稱:nordvisa_calendar,代碼行數:32,代碼來源:User.java

示例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;
}
 
開發者ID:xtianus,項目名稱:yadaframework,代碼行數:14,代碼來源:YadaUserCredentials.java

示例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);
}
 
開發者ID:2DV603NordVisaProject,項目名稱:nordvisa_calendar,代碼行數:9,代碼來源:User.java

示例7: encryptPassword

import org.springframework.security.crypto.password.PasswordEncoder; //導入方法依賴的package包/類
public static String encryptPassword(String rawPassword) {

      PasswordEncoder passwordEncoder = createPasswordEncoder();
      return passwordEncoder.encode(rawPassword);

   }
 
開發者ID:chen0040,項目名稱:spring-boot-slingshot,代碼行數:7,代碼來源:SpringUserServiceImpl.java


注:本文中的org.springframework.security.crypto.password.PasswordEncoder.encode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。