]> git.mxchange.org Git - juser-login-core.git/commitdiff
event for updated user password added. A PasswordHistory class must be given
authorRoland Häder <roland@mxchange.org>
Wed, 3 Aug 2016 13:26:42 +0000 (15:26 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 3 Aug 2016 13:53:10 +0000 (15:53 +0200)
src/org/mxchange/jusercore/events/user/password_change/UpdatedUserPasswordEvent.java [new file with mode: 0644]
src/org/mxchange/jusercore/events/user/password_change/UserUpdatedPasswordEvent.java [new file with mode: 0644]

diff --git a/src/org/mxchange/jusercore/events/user/password_change/UpdatedUserPasswordEvent.java b/src/org/mxchange/jusercore/events/user/password_change/UpdatedUserPasswordEvent.java
new file mode 100644 (file)
index 0000000..600e749
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jusercore.events.user.password_change;
+
+import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
+
+/**
+ * An interface for events being fired when a user updates personal data.
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface UpdatedUserPasswordEvent {
+
+       /**
+        * Getter for password history entry
+        * <p>
+        * @return Password history entry
+        */
+       PasswordHistory getPasswordHistory ();
+
+}
diff --git a/src/org/mxchange/jusercore/events/user/password_change/UserUpdatedPasswordEvent.java b/src/org/mxchange/jusercore/events/user/password_change/UserUpdatedPasswordEvent.java
new file mode 100644 (file)
index 0000000..629f195
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jusercore.events.user.password_change;
+
+import java.text.MessageFormat;
+import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
+
+/**
+ * An event being fired when the user has updated personal data
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public class UserUpdatedPasswordEvent implements UpdatedUserPasswordEvent {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 14_785_787_174_676_290L;
+
+       /**
+        * Updated user instance
+        */
+       private final PasswordHistory passwordHistory;
+
+       /**
+        * Constructor with updated user instance
+        * <p>
+        * @param passwordHistory Updated user instance
+        */
+       public UserUpdatedPasswordEvent (final PasswordHistory passwordHistory) {
+               // Is the user instance valid?
+               if (null == passwordHistory) {
+                       // Throw NPE
+                       throw new NullPointerException("passwordHistory is null"); //NOI18N
+               } else if (passwordHistory.getUserPasswordHistoryUser() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("passwordHistory.userPasswordHistoryUser is null"); //NOI18N
+               } else if (passwordHistory.getUserPasswordHistoryUser().getUserId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("passwordHistory.userPasswordHistoryUser.userId is null"); //NOI18N
+               } else if (passwordHistory.getUserPasswordHistoryUser().getUserId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("passwordHistory.userPasswordHistoryUser.userId={0} is invalid.", passwordHistory.getUserPasswordHistoryUser().getUserId())); //NOI18N
+               }
+
+               // Set it here
+               this.passwordHistory = passwordHistory;
+       }
+
+       @Override
+       public PasswordHistory getPasswordHistory () {
+               return this.passwordHistory;
+       }
+
+}