From ee3031e2445c637a4d975e1df90f3edaeb3f6527 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 30 Jul 2017 21:50:14 +0200 Subject: [PATCH] Continued a bit: - also the clear-text password can be transfered to observers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../ObservableUpdatedUserPasswordEvent.java | 7 ++++++ .../UpdatedUserPasswordEvent.java | 22 +++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/org/mxchange/juserlogincore/events/user/password_change/ObservableUpdatedUserPasswordEvent.java b/src/org/mxchange/juserlogincore/events/user/password_change/ObservableUpdatedUserPasswordEvent.java index 27faacf..5f49c81 100644 --- a/src/org/mxchange/juserlogincore/events/user/password_change/ObservableUpdatedUserPasswordEvent.java +++ b/src/org/mxchange/juserlogincore/events/user/password_change/ObservableUpdatedUserPasswordEvent.java @@ -33,4 +33,11 @@ public interface ObservableUpdatedUserPasswordEvent extends Serializable { */ PasswordHistory getPasswordHistory (); + /** + * Getter for user password + *

+ * @return User password + */ + String getUserPassword (); + } diff --git a/src/org/mxchange/juserlogincore/events/user/password_change/UpdatedUserPasswordEvent.java b/src/org/mxchange/juserlogincore/events/user/password_change/UpdatedUserPasswordEvent.java index d669b28..2315abc 100644 --- a/src/org/mxchange/juserlogincore/events/user/password_change/UpdatedUserPasswordEvent.java +++ b/src/org/mxchange/juserlogincore/events/user/password_change/UpdatedUserPasswordEvent.java @@ -36,12 +36,18 @@ public class UpdatedUserPasswordEvent implements ObservableUpdatedUserPasswordEv */ private final PasswordHistory passwordHistory; + /** + * User password + */ + private final String userPassword; + /** * Constructor with updated user instance *

* @param passwordHistory Updated user instance + * @param userPassword Clear-text user password */ - public UpdatedUserPasswordEvent (final PasswordHistory passwordHistory) { + public UpdatedUserPasswordEvent (final PasswordHistory passwordHistory, final String userPassword) { // Is the user instance valid? if (null == passwordHistory) { // Throw NPE @@ -55,10 +61,17 @@ public class UpdatedUserPasswordEvent implements ObservableUpdatedUserPasswordEv } else if (passwordHistory.getUserPasswordHistoryUser().getUserId() < 1) { // Invalid id number throw new IllegalArgumentException(MessageFormat.format("passwordHistory.userPasswordHistoryUser.userId={0} is invalid.", passwordHistory.getUserPasswordHistoryUser().getUserId())); //NOI18N + } else if (null == userPassword) { + // Throw NPE here + throw new NullPointerException("userPassword is null"); + } else if (userPassword.isEmpty()) { + // Throw NPE here + throw new IllegalArgumentException("userPassword is empty"); } - // Set it here + // Set both here this.passwordHistory = passwordHistory; + this.userPassword = userPassword; } @Override @@ -66,4 +79,9 @@ public class UpdatedUserPasswordEvent implements ObservableUpdatedUserPasswordEv return this.passwordHistory; } + @Override + public String getUserPassword () { + return this.userPassword; + } + } -- 2.39.5