fix hashing 512

This commit is contained in:
Valentin CZERYBA 2022-05-03 22:46:54 +02:00
parent a21210935b
commit 77e473442e
2 changed files with 7 additions and 7 deletions

View File

@ -1,6 +1,5 @@
package com.covas.Entity; package com.covas.Entity;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate; import java.time.LocalDate;
import javax.persistence.Column; import javax.persistence.Column;
@ -39,6 +38,7 @@ public class UsersEntity extends PanacheEntity {
} }
public static void add(String pseudo, String email, String name, String firstName, LocalDate birth, String password, String roles){ public static void add(String pseudo, String email, String name, String firstName, LocalDate birth, String password, String roles){
UsersEntity users = new UsersEntity(); UsersEntity users = new UsersEntity();
users.pseudo = pseudo; users.pseudo = pseudo;
users.email = email; users.email = email;
@ -46,7 +46,7 @@ public class UsersEntity extends PanacheEntity {
users.firstName = firstName; users.firstName = firstName;
users.birth = birth; users.birth = birth;
users.status = false; users.status = false;
users.password = Hash.encryptSHA512(new String(password.getBytes(), StandardCharsets.UTF_8)); users.password = Hash.encryptSHA512(password);
users.roles = roles; users.roles = roles;
users.persist(); users.persist();
} }

View File

@ -53,14 +53,14 @@ public class TokenRessource {
if (jwtCookie == null) { if (jwtCookie == null) {
String[] hash = new String(Base64.decode(auth.split(" ")[1]), StandardCharsets.UTF_8).split(":"); String[] hash = new String(Base64.decode(auth.split(" ")[1]), StandardCharsets.UTF_8).split(":");
String pseudo = hash[0]; String pseudo = hash[0];
LOGGER.info(hash[1].length()); password = Hash.encryptSHA512(hash[1]);
password = Hash.encryptSHA512(Hash.encryptSHA512(hash[1]));
UsersEntity users = UsersEntity.findByPseudo(pseudo); UsersEntity users = UsersEntity.findByPseudo(pseudo);
if(users != null){
}
LOGGER.info(users.password);
LOGGER.info(password);
// Create a JWT token signed using the 'HS256' algorithm // Create a JWT token signed using the 'HS256' algorithm
String newJwtCookie = Jwt.issuer("https://example.com/issuer").upn("Alice").groups(new HashSet<>(Arrays.asList("User"))).sign(); String newJwtCookie = Jwt.issuer("https://example.com/issuer").upn("Alice").groups(new HashSet<>(Arrays.asList("User"))).sign();
// or create a JWT token encrypted using the 'A256KW' algorithm // or create a JWT token encrypted using the 'A256KW' algorithm