2 * Copyright (C) 2016, 2017 Free Software Foundation
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.juserlogincore.events.user.password_change;
19 import java.text.MessageFormat;
20 import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
23 * An event being fired when the user has updated personal data
25 * @author Roland Häder<roland@mxchange.org>
27 public class UpdatedUserPasswordEvent implements ObservableUpdatedUserPasswordEvent {
32 private static final long serialVersionUID = 14_785_787_174_676_290L;
35 * Updated user instance
37 private final PasswordHistory passwordHistory;
42 private final String userPassword;
45 * Constructor with updated user instance
47 * @param passwordHistory Updated user instance
48 * @param userPassword Clear-text user password
50 public UpdatedUserPasswordEvent (final PasswordHistory passwordHistory, final String userPassword) {
51 // Is the user instance valid?
52 if (null == passwordHistory) {
54 throw new NullPointerException("passwordHistory is null"); //NOI18N
55 } else if (passwordHistory.getUserPasswordHistoryUser() == null) {
57 throw new NullPointerException("passwordHistory.userPasswordHistoryUser is null"); //NOI18N
58 } else if (passwordHistory.getUserPasswordHistoryUser().getUserId() == null) {
60 throw new NullPointerException("passwordHistory.userPasswordHistoryUser.userId is null"); //NOI18N
61 } else if (passwordHistory.getUserPasswordHistoryUser().getUserId() < 1) {
63 throw new IllegalArgumentException(MessageFormat.format("passwordHistory.userPasswordHistoryUser.userId={0} is invalid.", passwordHistory.getUserPasswordHistoryUser().getUserId())); //NOI18N
64 } else if (null == userPassword) {
66 throw new NullPointerException("userPassword is null");
67 } else if (userPassword.isEmpty()) {
69 throw new IllegalArgumentException("userPassword is empty");
73 this.passwordHistory = passwordHistory;
74 this.userPassword = userPassword;
78 public PasswordHistory getPasswordHistory () {
79 return this.passwordHistory;
83 public String getUserPassword () {
84 return this.userPassword;