From e98f2ca788965850fd3bf6257d8aa4d6314d596d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 12 Jul 2017 21:26:18 +0200 Subject: [PATCH] re-added from juser-core as this is login relevant MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../ObservableUpdatedUserPasswordEvent.java | 36 ++++++++++ .../UpdatedUserPasswordEvent.java | 69 +++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 src/org/mxchange/juserlogincore/events/user/password_change/ObservableUpdatedUserPasswordEvent.java create mode 100644 src/org/mxchange/juserlogincore/events/user/password_change/UpdatedUserPasswordEvent.java diff --git a/src/org/mxchange/juserlogincore/events/user/password_change/ObservableUpdatedUserPasswordEvent.java b/src/org/mxchange/juserlogincore/events/user/password_change/ObservableUpdatedUserPasswordEvent.java new file mode 100644 index 0000000..27faacf --- /dev/null +++ b/src/org/mxchange/juserlogincore/events/user/password_change/ObservableUpdatedUserPasswordEvent.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * 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 . + */ +package org.mxchange.juserlogincore.events.user.password_change; + +import java.io.Serializable; +import org.mxchange.jusercore.model.user.password_history.PasswordHistory; + +/** + * An interface for events being fired when a user updates personal data. + *

+ * @author Roland Häder + */ +public interface ObservableUpdatedUserPasswordEvent extends Serializable { + + /** + * Getter for password history entry + *

+ * @return Password history entry + */ + PasswordHistory getPasswordHistory (); + +} diff --git a/src/org/mxchange/juserlogincore/events/user/password_change/UpdatedUserPasswordEvent.java b/src/org/mxchange/juserlogincore/events/user/password_change/UpdatedUserPasswordEvent.java new file mode 100644 index 0000000..d669b28 --- /dev/null +++ b/src/org/mxchange/juserlogincore/events/user/password_change/UpdatedUserPasswordEvent.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * 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 . + */ +package org.mxchange.juserlogincore.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 + *

+ * @author Roland Häder + */ +public class UpdatedUserPasswordEvent implements ObservableUpdatedUserPasswordEvent { + + /** + * 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 + *

+ * @param passwordHistory Updated user instance + */ + public UpdatedUserPasswordEvent (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; + } + +} -- 2.39.5