*/
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
} 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
return this.passwordHistory;
}
+ @Override
+ public String getUserPassword () {
+ return this.userPassword;
+ }
+
}