]> git.mxchange.org Git - juser-login-core.git/commitdiff
Continued a bit:
authorRoland Häder <roland@mxchange.org>
Sun, 30 Jul 2017 19:50:14 +0000 (21:50 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 30 Jul 2017 19:50:14 +0000 (21:50 +0200)
- also the clear-text password can be transfered to observers

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/juserlogincore/events/user/password_change/ObservableUpdatedUserPasswordEvent.java
src/org/mxchange/juserlogincore/events/user/password_change/UpdatedUserPasswordEvent.java

index 27faacf7d05ef4047a3a3616a0ff60180fb92c15..5f49c8173277b2f2c05b1ec95fa09456f31ba9e3 100644 (file)
@@ -33,4 +33,11 @@ public interface ObservableUpdatedUserPasswordEvent extends Serializable {
         */
        PasswordHistory getPasswordHistory ();
 
+       /**
+        * Getter for user password
+        * <p>
+        * @return User password
+        */
+       String getUserPassword ();
+
 }
index d669b28c5efd386a39664894c903f0f01a166724..2315abc4f460868d26d47fb344fcbf5777d53d71 100644 (file)
@@ -36,12 +36,18 @@ public class UpdatedUserPasswordEvent implements ObservableUpdatedUserPasswordEv
         */
        private final PasswordHistory passwordHistory;
 
+       /**
+        * User password
+        */
+       private final String userPassword;
+
        /**
         * Constructor with updated user instance
         * <p>
         * @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;
+       }
+
 }