当前位置: 首页>>代码示例>>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;未经允许,请勿转载。