]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java
updated JNDI names
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / user / PizzaAdminUserWebRequestBean.java
1 /*
2  * Copyright (C) 2016, 2017 Roland Häder
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Affero General Public License as
6  * published by the Free Software Foundation, either version 3 of the
7  * License, or (at your option) any later version.
8  *
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 Affero General Public License for more details.
13  *
14  * You should have received a copy of the GNU Affero General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.pizzaapplication.beans.user;
18
19 import java.text.MessageFormat;
20 import java.util.Objects;
21 import javax.annotation.PostConstruct;
22 import javax.enterprise.context.RequestScoped;
23 import javax.enterprise.event.Event;
24 import javax.enterprise.event.Observes;
25 import javax.enterprise.inject.Any;
26 import javax.faces.FacesException;
27 import javax.faces.view.facelets.FaceletException;
28 import javax.inject.Inject;
29 import javax.inject.Named;
30 import javax.naming.Context;
31 import javax.naming.InitialContext;
32 import javax.naming.NamingException;
33 import org.mxchange.jcontacts.contact.Contact;
34 import org.mxchange.jcoreee.utils.FacesUtils;
35 import org.mxchange.jusercore.container.login.UserLoginContainer;
36 import org.mxchange.jusercore.events.registration.ObservableUserRegisteredEvent;
37 import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
38 import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
39 import org.mxchange.jusercore.events.user.delete.AdminDeletedUserEvent;
40 import org.mxchange.jusercore.events.user.delete.ObservableAdminDeletedUserEvent;
41 import org.mxchange.jusercore.events.user.linked.AdminLinkedUserEvent;
42 import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
43 import org.mxchange.jusercore.events.user.locked.AdminLockedUserEvent;
44 import org.mxchange.jusercore.events.user.locked.ObservableAdminLockedUserEvent;
45 import org.mxchange.jusercore.events.user.unlocked.AdminUnlockedUserEvent;
46 import org.mxchange.jusercore.events.user.unlocked.ObservableAdminUnlockedUserEvent;
47 import org.mxchange.jusercore.events.user.update.AdminUpdatedUserDataEvent;
48 import org.mxchange.jusercore.events.user.update.ObservableAdminUpdatedUserDataEvent;
49 import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
50 import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
51 import org.mxchange.jusercore.exceptions.UserNotFoundException;
52 import org.mxchange.jusercore.exceptions.UserPasswordRepeatMismatchException;
53 import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
54 import org.mxchange.jusercore.exceptions.UserStatusLockedException;
55 import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
56 import org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote;
57 import org.mxchange.jusercore.model.user.LoginUser;
58 import org.mxchange.jusercore.model.user.User;
59 import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
60 import org.mxchange.jusercore.model.user.UserUtils;
61 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
62 import org.mxchange.jusercore.model.user.status.UserAccountStatus;
63 import org.mxchange.pizzaapplication.beans.BasePizzaController;
64 import org.mxchange.pizzaapplication.beans.contact.PizzaAdminContactWebRequestController;
65 import org.mxchange.pizzaapplication.beans.contact.PizzaContactWebSessionController;
66 import org.mxchange.pizzaapplication.beans.helper.PizzaWebRequestHelperController;
67 import org.mxchange.pizzaapplication.beans.localization.PizzaLocalizationSessionController;
68
69 /**
70  * Administrative user bean (controller)
71  * <p>
72  * @author Roland Häder<roland@mxchange.org>
73  */
74 @Named ("adminUserController")
75 @RequestScoped
76 public class PizzaAdminUserWebRequestBean extends BasePizzaController implements PizzaAdminUserWebRequestController {
77
78         /**
79          * Serial number
80          */
81         private static final long serialVersionUID = 542_145_347_916L;
82
83         /**
84          * An event fired when the administrator has added a new user
85          */
86         @Inject
87         @Any
88         private Event<ObservableAdminAddedUserEvent> addedUserEvent;
89
90         /**
91          * Regular contact controller
92          */
93         @Inject
94         private PizzaAdminContactWebRequestController adminContactController;
95
96         /**
97          * Administrative user EJB
98          */
99         private AdminUserSessionBeanRemote adminUserBean;
100
101         /**
102          * Bean helper
103          */
104         @Inject
105         private PizzaWebRequestHelperController beanHelper;
106
107         /**
108          * Regular contact controller
109          */
110         @Inject
111         private PizzaContactWebSessionController contactController;
112
113         /**
114          * Event being fired when admin has deleted user
115          */
116         @Inject
117         @Any
118         private Event<ObservableAdminDeletedUserEvent> deleteUserEvent;
119
120         /**
121          * Localization controller
122          */
123         @Inject
124         private PizzaLocalizationSessionController localizationController;
125
126         /**
127          * An event fired when the administrator has updated a new user
128          */
129         @Inject
130         @Any
131         private Event<ObservableAdminUpdatedUserDataEvent> updatedUserDataEvent;
132
133         /**
134          * General user EJB
135          */
136         private UserSessionBeanRemote userBean;
137
138         /**
139          * Regular user controller
140          */
141         @Inject
142         private PizzaUserWebSessionController userController;
143
144         /**
145          * Delete reason
146          */
147         private String userDeleteReason;
148
149         /**
150          * An event fired when the administrator has linked a user with existing
151          * contact data.
152          */
153         @Inject
154         @Any
155         private Event<ObservableAdminLinkedUserEvent> userLinkedEvent;
156
157         /**
158          * User lock reason
159          */
160         private String userLockReason;
161
162         /**
163          * Event being fired when an administrator has locked a user
164          */
165         @Inject
166         @Any
167         private Event<ObservableAdminLockedUserEvent> userLockedEvent;
168
169         /**
170          * Flag whether user must change password after login
171          */
172         private Boolean userMustChangePassword;
173
174         /**
175          * User name
176          */
177         private String userName;
178
179         /**
180          * User password (clear-text from web form)
181          */
182         private String userPassword;
183
184         /**
185          * User password repeated (clear-text from web form)
186          */
187         private String userPasswordRepeat;
188
189         /**
190          * Event being fired when admin unlocks an account
191          */
192         @Inject
193         @Any
194         private Event<ObservableAdminUnlockedUserEvent> userUnlockedEvent;
195
196         /**
197          * Default constructor
198          */
199         public PizzaAdminUserWebRequestBean () {
200                 // Call super constructor
201                 super();
202         }
203
204         @Override
205         public String addUser () {
206                 // As the form cannot validate the data (required="true"), check it here
207                 if (this.getUserName() == null) {
208                         // Throw NPE
209                         throw new NullPointerException("userName is null"); //NOI18N
210                 } else if (this.getUserName().isEmpty()) {
211                         // Is empty
212                         throw new IllegalArgumentException("userName is null"); //NOI18N
213                 } else if (this.beanHelper.getContact() == null) {
214                         // No contact instance set, so test required fields: gender, first name and family name
215                         if (this.contactController.getPersonalTitle() == null) {
216                                 // Throw NPE again
217                                 throw new NullPointerException("contactController.gender is null"); //NOI18N
218                         } else if (this.contactController.getFirstName() == null) {
219                                 // ... and again
220                                 throw new NullPointerException("contactController.firstName is null"); //NOI18N
221                         } else if (this.adminContactController.getFirstName().isEmpty()) {
222                                 // ... and again
223                                 throw new IllegalArgumentException("contactController.firstName is empty"); //NOI18N
224                         } else if (this.adminContactController.getFamilyName() == null) {
225                                 // ... and again
226                                 throw new NullPointerException("contactController.familyName is null"); //NOI18N
227                         } else if (this.contactController.getFamilyName().isEmpty()) {
228                                 // ... and again
229                                 throw new IllegalArgumentException("contactController.familyName is empty"); //NOI18N
230                         } else if (this.adminContactController.getEmailAddress() == null) {
231                                 // ... and again
232                                 throw new NullPointerException("contactController.emailAddress is null"); //NOI18N
233                         } else if (this.adminContactController.getEmailAddress().isEmpty()) {
234                                 // ... and again
235                                 throw new IllegalArgumentException("contactController.emailAddress is empty"); //NOI18N
236                         }
237                 }
238
239                 // Create new user instance
240                 User user = new LoginUser();
241
242                 // Set user name, CONFIRMED and INVISIBLE
243                 user.setUserName(this.getUserName());
244                 user.setUserMustChangePassword(this.getUserMustChangePassword());
245                 user.setUserAccountStatus(UserAccountStatus.CONFIRMED);
246                 user.setUserProfileMode(ProfileMode.INVISIBLE);
247
248                 // Init instance
249                 Contact contact;
250
251                 // Is a contact instance in helper set?
252                 if (this.beanHelper.getContact() instanceof Contact) {
253                         // Then use it for contact linking
254                         contact = this.beanHelper.getContact();
255                 } else {
256                         // Create contact instance
257                         contact = this.contactController.createContactInstance();
258                 }
259
260                 // Set contact in user
261                 user.setUserContact(contact);
262
263                 // Init variable for password
264                 String password = null;
265
266                 // Is the user name or email address used already?
267                 // @TODO Add password length check
268                 if (this.userController.isUserNameRegistered(user)) {
269                         // User name is already used
270                         throw new FaceletException(new UserNameAlreadyRegisteredException(user));
271                 } else if ((this.beanHelper.getContact() == null) && (this.contactController.isEmailAddressRegistered(user.getUserContact()))) {
272                         // Email address is already used
273                         this.showFacesMessage("admin_add_user:emailAddress", "ERROR_EMAIL_ADDRESS_ALREADY_USED"); //NOI18N
274
275                         // Always clear password
276                         this.setUserPassword(null);
277                         this.setUserPasswordRepeat(null);
278
279                         // Skip it
280                         return ""; //NOI18N
281                 } else if ((this.getUserPassword() == null && (this.getUserPasswordRepeat() == null)) || ((this.getUserPassword().isEmpty()) && (this.getUserPasswordRepeat().isEmpty()))) {
282                         // Empty password entered, then generate one
283                         password = UserUtils.createRandomPassword(PizzaUserWebSessionController.MINIMUM_PASSWORD_LENGTH);
284                 } else if (!this.isSamePasswordEntered()) {
285                         // Both passwords don't match
286                         throw new FaceletException(new UserPasswordRepeatMismatchException(user));
287                 } else {
288                         // Both match, so get it from this bean
289                         password = this.getUserPassword();
290                 }
291
292                 // The password should not be null and at least 5 characters long
293                 assert (password != null) : "password is null"; //NOI18N
294                 assert (password.length() >= PizzaUserWebSessionController.MINIMUM_PASSWORD_LENGTH) : "Password is not long enough."; //NOI18N
295
296                 // Encrypt password and set it
297                 user.setUserEncryptedPassword(UserUtils.encryptPassword(password));
298
299                 try {
300                         // Now, that all is set, call EJB
301                         if (this.beanHelper.getContact() instanceof Contact) {
302                                 // Link contact with this user
303                                 User updatedUser = this.adminUserBean.linkUser(user);
304
305                                 // Fire event
306                                 this.userLinkedEvent.fire(new AdminLinkedUserEvent(updatedUser));
307
308                                 // Remove contact instance
309                                 this.beanHelper.setContact(null);
310                         } else {
311                                 // Add new contact
312                                 User updatedUser = this.adminUserBean.addUser(user);
313
314                                 // Fire event
315                                 this.addedUserEvent.fire(new AdminAddedUserEvent(updatedUser));
316                         }
317                 } catch (final UserNameAlreadyRegisteredException | EmailAddressAlreadyRegisteredException ex) {
318                         // Throw again
319                         throw new FaceletException(ex);
320                 }
321
322                 // Clear helper
323                 this.beanHelper.setContact(null);
324
325                 // Clear this bean
326                 this.clear();
327
328                 // Return to user list (for now)
329                 return "admin_list_user"; //NOI18N
330         }
331
332         /**
333          * Event observer for new user registrations
334          * <p>
335          * @param event User registration event
336          */
337         public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent event) {
338                 // event should not be null
339                 if (null == event) {
340                         // Throw NPE
341                         throw new NullPointerException("event is null"); //NOI18N
342                 } else if (event.getRegisteredUser() == null) {
343                         // Throw NPE again
344                         throw new NullPointerException("event.user is null"); //NOI18N
345                 } else if (event.getRegisteredUser().getUserId() == null) {
346                         // userId is null
347                         throw new NullPointerException("event.user.userId is null"); //NOI18N
348                 } else if (event.getRegisteredUser().getUserId() < 1) {
349                         // Not avalid id
350                         throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
351                 }
352
353                 // Get user instance
354                 User registeredUser = event.getRegisteredUser();
355
356                 // @TODO Nothing to do with the user here?
357                 // Clear all data
358                 this.clear();
359         }
360
361         @Override
362         public String deleteUserData (final User user) {
363                 // Is the user instance valid and CONFIRMED?
364                 if (null == user) {
365                         // Throw NPE
366                         throw new NullPointerException("user is null"); //NOI18N
367                 } else if (user.getUserId() == null) {
368                         // Throw again
369                         throw new NullPointerException("user.userId is null"); //NOI18N
370                 } else if (user.getUserId() < 1) {
371                         // Invalid id number
372                         throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
373                 }
374
375                 try {
376                         // All fine, delete it
377                         this.adminUserBean.deleteUser(user, this.getUserDeleteReason());
378                 } catch (final UserNotFoundException ex) {
379                         // Should not happen, so throw again
380                         throw new FaceletException(ex);
381                 }
382
383                 // Fire event
384                 this.deleteUserEvent.fire(new AdminDeletedUserEvent(user, this.getUserDeleteReason()));
385
386                 // Redirect
387                 return "admin_list_user"; //NOI18N
388         }
389
390         @Override
391         public String editUserData () {
392                 // Get user instance
393                 User user = this.beanHelper.getUser();
394
395                 // Null password means not setting it
396                 String encryptedPassword = null;
397
398                 // Check if user instance is in helper and valid
399                 if (null == user) {
400                         // Throw NPE
401                         throw new NullPointerException("beanHelper.user is null"); //NOI18N
402                 } else if (user.getUserId() == null) {
403                         // Throw NPE again
404                         throw new NullPointerException("beanHelper.user.userId is null"); //NOI18N
405                 } else if (user.getUserId() < 1) {
406                         // Invalid id
407                         throw new IllegalStateException(MessageFormat.format("beanHelper.user.userId={0} is invalid", user.getUserId())); //NOI18N
408                 } else if (this.getUserName() == null) {
409                         // Not all required fields are set
410                         throw new NullPointerException("this.userName is null"); //NOI18N
411                 } else if (this.getUserName().isEmpty()) {
412                         // Not all required fields are set
413                         throw new IllegalArgumentException("this.userName is empty"); //NOI18N
414                 } else if (((!this.getUserPassword().isEmpty()) || (!this.getUserPasswordRepeat().isEmpty())) && (!this.isSamePasswordEntered())) {
415                         // Clear password fields
416                         this.setUserPassword(null);
417                         this.setUserPasswordRepeat(null);
418
419                         // Not same password entered
420                         this.showFacesMessage("form_edit_user:userPassword", "ADMIN_USER_PASSWORD_REPEAT_DIFFERENT"); //NOI18N
421                         return ""; //NOI18N
422                 } else if ((!Objects.equals(user.getUserName(), this.getUserName())) && (this.userBean.ifUserNameExists(this.getUserName()))) {
423                         // Clear all fields
424                         this.clear();
425
426                         // User name already exists
427                         this.showFacesMessage("form_edit_user:userName", "ADMIN_USER_NAME_ALREADY_EXISTS"); //NOI18N
428                         return ""; //NOI18N
429                 } else if (this.isSamePasswordEntered()) {
430                         // Same password entered, create container
431                         if ((Objects.equals(user.getUserMustChangePassword(), this.getUserMustChangePassword())) && (UserUtils.ifPasswordMatches(new UserLoginContainer(user, this.getUserPassword())))) {
432                                 // Clear password fields
433                                 this.setUserPassword(null);
434                                 this.setUserPasswordRepeat(null);
435
436                                 // Same password entered
437                                 this.showFacesMessage("form_edit_user:userPassword", "ADMIN_USER_ENTERED_SAME_AS_OLD_PASSWORD"); //NOI18N
438                                 return ""; //NOI18N
439                         }
440
441                         // Encrypt password
442                         encryptedPassword = UserUtils.encryptPassword(this.getUserPassword());
443                 }
444
445                 // Set user name and flag
446                 user.setUserName(this.getUserName());
447                 user.setUserMustChangePassword(this.getUserMustChangePassword());
448
449                 // Is a password set?
450                 if (encryptedPassword != null) {
451                         // Set it as well
452                         user.setUserEncryptedPassword(encryptedPassword);
453                 }
454
455                 // Call EJB for updating user data
456                 User updatedUser = this.userBean.updateUserData(user);
457
458                 // Fire event
459                 this.updatedUserDataEvent.fire(new AdminUpdatedUserDataEvent(updatedUser));
460
461                 // Return to user list (for now)
462                 return "admin_list_user"; //NOI18N
463         }
464
465         @Override
466         public String getUserDeleteReason () {
467                 return this.userDeleteReason;
468         }
469
470         @Override
471         public void setUserDeleteReason (final String userDeleteReason) {
472                 this.userDeleteReason = userDeleteReason;
473         }
474
475         @Override
476         public String getUserLockReason () {
477                 return this.userLockReason;
478         }
479
480         @Override
481         public void setUserLockReason (final String userLockReason) {
482                 this.userLockReason = userLockReason;
483         }
484
485         @Override
486         public Boolean getUserMustChangePassword () {
487                 return this.userMustChangePassword;
488         }
489
490         @Override
491         public void setUserMustChangePassword (final Boolean userMustChangePassword) {
492                 this.userMustChangePassword = userMustChangePassword;
493         }
494
495         @Override
496         public String getUserName () {
497                 return this.userName;
498         }
499
500         @Override
501         public void setUserName (final String userName) {
502                 this.userName = userName;
503         }
504
505         @Override
506         public String getUserPassword () {
507                 return this.userPassword;
508         }
509
510         @Override
511         public void setUserPassword (final String userPassword) {
512                 this.userPassword = userPassword;
513         }
514
515         @Override
516         public String getUserPasswordRepeat () {
517                 return this.userPasswordRepeat;
518         }
519
520         @Override
521         public void setUserPasswordRepeat (final String userPasswordRepeat) {
522                 this.userPasswordRepeat = userPasswordRepeat;
523         }
524
525         /**
526          * Post-construction method
527          */
528         @PostConstruct
529         public void init () {
530                 // Try it
531                 try {
532                         // Get initial context
533                         Context context = new InitialContext();
534
535                         // Try to lookup
536                         this.userBean = (UserSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
537                         this.adminUserBean = (AdminUserSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/adminUser!org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote"); //NOI18N
538                 } catch (final NamingException e) {
539                         // Throw again
540                         throw new FaceletException(e);
541                 }
542         }
543
544         @Override
545         public String lockUserAccount (final User user) {
546                 // Is the user instance valid and CONFIRMED?
547                 if (null == user) {
548                         // Throw NPE
549                         throw new NullPointerException("user is null"); //NOI18N
550                 } else if (user.getUserId() == null) {
551                         // Throw again
552                         throw new NullPointerException("user.userId is null"); //NOI18N
553                 } else if (user.getUserId() < 1) {
554                         // Invalid id number
555                         throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
556                 } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) {
557                         // User account is locked
558                         throw new FacesException(new UserStatusLockedException(user));
559                 } else if (user.getUserAccountStatus() == UserAccountStatus.UNCONFIRMED) {
560                         // User account is locked
561                         throw new FaceletException(new UserStatusUnconfirmedException(user));
562                 } else if (this.getUserLockReason() == null) {
563                         // Throw NPE again
564                         throw new NullPointerException("this.userLockReason is null"); //NOI18N
565                 } else if (this.getUserLockReason().isEmpty()) {
566                         // Empty lock reason
567                         throw new IllegalArgumentException("this.userLockReason is empty"); //NOI18N
568                 }
569
570                 // Init updated user instance
571                 User updatedUser;
572
573                 try {
574                         // Get base URL
575                         String baseUrl = FacesUtils.generateBaseUrl();
576
577                         // Call EJB to lock account
578                         updatedUser = this.adminUserBean.lockUserAccount(user, this.getUserLockReason(), baseUrl);
579                 } catch (final UserStatusLockedException | UserStatusUnconfirmedException | UserNotFoundException ex) {
580                         // Throw again
581                         throw new FaceletException(ex);
582                 }
583
584                 // Fire event
585                 this.userLockedEvent.fire(new AdminLockedUserEvent(updatedUser));
586
587                 // Clear bean
588                 this.clear();
589
590                 // Should go fine at this point, redirect to user profile
591                 return "admin_show_user"; //NOI18N
592         }
593
594         @Override
595         public String unlockUserAccount (final User user) {
596                 // Is the user instance valid and CONFIRMED?
597                 if (null == user) {
598                         // Throw NPE
599                         throw new NullPointerException("user is null"); //NOI18N
600                 } else if (user.getUserId() == null) {
601                         // Throw again
602                         throw new NullPointerException("user.userId is null"); //NOI18N
603                 } else if (user.getUserId() < 1) {
604                         // Invalid id number
605                         throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
606                 } else if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) {
607                         // User account is locked
608                         throw new FacesException(new UserStatusConfirmedException(user));
609                 } else if (user.getUserAccountStatus() == UserAccountStatus.UNCONFIRMED) {
610                         // User account is locked
611                         throw new FaceletException(new UserStatusUnconfirmedException(user));
612                 }
613
614                 // Init updated user instance
615                 User updatedUser;
616
617                 try {
618                         // Get base URL
619                         String baseUrl = FacesUtils.generateBaseUrl();
620
621                         // Call EJB to unlock account
622                         updatedUser = this.adminUserBean.unlockUserAccount(user, baseUrl);
623                 } catch (final UserStatusConfirmedException | UserStatusUnconfirmedException | UserNotFoundException ex) {
624                         // Throw again
625                         throw new FaceletException(ex);
626                 }
627
628                 // Fire event
629                 this.userUnlockedEvent.fire(new AdminUnlockedUserEvent(updatedUser));
630
631                 // Clear bean
632                 this.clear();
633
634                 // Should go fine at this point, redirect to user profile
635                 return "admin_show_user"; //NOI18N
636         }
637
638         /**
639          * Clears this bean
640          */
641         private void clear () {
642                 // Clear all data
643                 // - other data
644                 this.setUserName(null);
645                 this.setUserPassword(null);
646                 this.setUserPasswordRepeat(null);
647                 this.setUserMustChangePassword(null);
648         }
649
650         /**
651          * Checks if same password is entered and that they are not empty.
652          * <p>
653          * @return Whether the same password was entered
654          */
655         private boolean isSamePasswordEntered () {
656                 return ((!this.getUserPassword().isEmpty()) && (Objects.equals(this.getUserPassword(), this.getUserPasswordRepeat())));
657         }
658
659 }