From 77e473442e8f896bb492e9d4b675003b369669c7 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Tue, 3 May 2022 22:46:54 +0200 Subject: [PATCH] fix hashing 512 --- src/main/java/com/covas/Entity/UsersEntity.java | 4 ++-- src/main/java/com/covas/Resources/TokenRessource.java | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/covas/Entity/UsersEntity.java b/src/main/java/com/covas/Entity/UsersEntity.java index e7be035..ce0b8d7 100644 --- a/src/main/java/com/covas/Entity/UsersEntity.java +++ b/src/main/java/com/covas/Entity/UsersEntity.java @@ -1,6 +1,5 @@ package com.covas.Entity; -import java.nio.charset.StandardCharsets; import java.time.LocalDate; 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){ + UsersEntity users = new UsersEntity(); users.pseudo = pseudo; users.email = email; @@ -46,7 +46,7 @@ public class UsersEntity extends PanacheEntity { users.firstName = firstName; users.birth = birth; users.status = false; - users.password = Hash.encryptSHA512(new String(password.getBytes(), StandardCharsets.UTF_8)); + users.password = Hash.encryptSHA512(password); users.roles = roles; users.persist(); } diff --git a/src/main/java/com/covas/Resources/TokenRessource.java b/src/main/java/com/covas/Resources/TokenRessource.java index 4f895c2..1b36835 100644 --- a/src/main/java/com/covas/Resources/TokenRessource.java +++ b/src/main/java/com/covas/Resources/TokenRessource.java @@ -53,14 +53,14 @@ public class TokenRessource { if (jwtCookie == null) { String[] hash = new String(Base64.decode(auth.split(" ")[1]), StandardCharsets.UTF_8).split(":"); String pseudo = hash[0]; - LOGGER.info(hash[1].length()); - password = Hash.encryptSHA512(Hash.encryptSHA512(hash[1])); + password = Hash.encryptSHA512(hash[1]); UsersEntity users = UsersEntity.findByPseudo(pseudo); + if(users != null){ + + } - LOGGER.info(users.password); - LOGGER.info(password); - + // 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(); // or create a JWT token encrypted using the 'A256KW' algorithm