Compare commits
1 commit
3877b8f466
...
ce70e4affe
Author | SHA1 | Date | |
---|---|---|---|
ce70e4affe |
2 changed files with 3 additions and 5 deletions
|
@ -15,8 +15,6 @@ import jakarta.persistence.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "player")
|
@Table(name = "player")
|
||||||
public class Player {
|
public class Player {
|
||||||
public static final int PASSWORD_SALT_BYTE_LENGTH = 16;
|
|
||||||
public static final int PASSWORD_HASH_BYTE_LENGTH = 64;
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
private Long id;
|
private Long id;
|
||||||
|
@ -26,10 +24,10 @@ public class Player {
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = PASSWORD_HASH_BYTE_LENGTH, max = PASSWORD_HASH_BYTE_LENGTH)
|
@Size(min = 64, max = 64)
|
||||||
private byte[] passwordHash;
|
private byte[] passwordHash;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(min = PASSWORD_SALT_BYTE_LENGTH, max = PASSWORD_SALT_BYTE_LENGTH)
|
@Size(min = 16, max = 16)
|
||||||
private byte[] passwordSalt;
|
private byte[] passwordSalt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class PlayerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPassword(Player player, String password) throws NoSuchAlgorithmException {
|
public void setPassword(Player player, String password) throws NoSuchAlgorithmException {
|
||||||
byte[] salt = new byte[Player.PASSWORD_SALT_BYTE_LENGTH];
|
byte[] salt = new byte[16];
|
||||||
this.random.nextBytes(salt);
|
this.random.nextBytes(salt);
|
||||||
|
|
||||||
byte[] passwordHash = hashPassword(
|
byte[] passwordHash = hashPassword(
|
||||||
|
|
Loading…
Add table
Reference in a new issue