org.apache.shiro.crypto.RandomNumberGenerator Java Examples

The following examples show how to use org.apache.shiro.crypto.RandomNumberGenerator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UserServiceImpl.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
 * 新增
 *
 * @param user
 * @return
 */
@Override
public User insert(User user) {
    RandomNumberGenerator rng = new SecureRandomNumberGenerator();
    //密码设置
    String salt = rng.nextBytes().toBase64();
    user.setSalt(salt);
    String hashedPasswordBase64 = new Sha256Hash(user.getPassword(), salt, 1024).toBase64();
    user.setPassword(hashedPasswordBase64);

    dao().insert(user);
    this.updataRelation(user);
    return user;
}
 
Example #2
Source File: UserServiceImpl.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
 * 重置密码
 *
 * @param user
 * @return
 */
@Override
public int resetUserPwd(User user) {
    RandomNumberGenerator rng = new SecureRandomNumberGenerator();
    String salt = rng.nextBytes().toBase64();
    user.setSalt(salt);
    String hashedPasswordBase64 = new Sha256Hash(user.getPassword(), salt, 1024).toBase64();
    user.setPassword(hashedPasswordBase64);
    user.setUpdateTime(new Date());
    return dao().updateIgnoreNull(user);
}
 
Example #3
Source File: Sha256CredentialsHashingStrategy.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
@Override
public ByteSource generateSalt() {
   RandomNumberGenerator rng = new SecureRandomNumberGenerator();
   return rng.nextBytes();
}
 
Example #4
Source File: PasswordHelper.java    From wetech-admin with MIT License 4 votes vote down vote up
public void setRandomNumberGenerator(RandomNumberGenerator randomNumberGenerator) {
    this.randomNumberGenerator = randomNumberGenerator;
}
 
Example #5
Source File: PasswordHelper.java    From cms with Apache License 2.0 4 votes vote down vote up
public void setRandomNumberGenerator(RandomNumberGenerator randomNumberGenerator) {
    this.randomNumberGenerator = randomNumberGenerator;
}
 
Example #6
Source File: PasswordHelper.java    From spring-tutorial with Creative Commons Attribution Share Alike 4.0 International 4 votes vote down vote up
public void setRandomNumberGenerator(RandomNumberGenerator randomNumberGenerator) {
	this.randomNumberGenerator = randomNumberGenerator;
}
 
Example #7
Source File: ShiroPasswordService.java    From EasyReport with Apache License 2.0 4 votes vote down vote up
public void setRandomNumberGenerator(final RandomNumberGenerator randomNumberGenerator) {
    this.randomNumberGenerator = randomNumberGenerator;
}