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