From f2e5a9f1ae6f972ba6774dccd1e25ff7d71bece3 Mon Sep 17 00:00:00 2001 From: Jan Vales Date: Tue, 3 Apr 2018 22:51:02 +0200 Subject: [PATCH] hash password! --- .../main/java/dst/ass1/jpa/model/impl/Participant.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Participant.java b/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Participant.java index c983eda..df3088a 100644 --- a/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Participant.java +++ b/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Participant.java @@ -6,6 +6,8 @@ import dst.ass1.jpa.model.IParticipant; import dst.ass1.jpa.util.Constants; import javax.persistence.*; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Collection; @@ -46,6 +48,7 @@ public class Participant extends Person implements IParticipant { this.email = email; } + // FIXME: This makes no sense. set(get()) - is broken. -> checkPW()? @Override public byte[] getPassword() { return password; @@ -53,7 +56,11 @@ public class Participant extends Person implements IParticipant { @Override public void setPassword(byte[] password) { - this.password = password; + try { + this.password = MessageDigest.getInstance("SHA-1").digest(password); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } } @Override -- 2.43.0