]> git.mxchange.org Git - addressbook-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Sat, 22 Apr 2017 20:04:26 +0000 (22:04 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 22 Apr 2017 20:58:25 +0000 (22:58 +0200)
- Let's always call super constructor (not the default one, of course), maybe
  one day there will be something added
- sorted members a bit
- some constructors still contain EJB-lookup code, moved to init()
  (@PostConstruct) method

Signed-off-by: Roland Häder <roland@mxchange.org>
31 files changed:
src/java/org/mxchange/addressbook/beans/BaseAddressbookController.java
src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebSessionBean.java
src/java/org/mxchange/addressbook/beans/confirmlink/AddressbookConfirmationLinkWebRequestBean.java
src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java
src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java
src/java/org/mxchange/addressbook/beans/contact/phone/AddressbookAdminContactPhoneWebRequestBean.java
src/java/org/mxchange/addressbook/beans/contact/phone/AddressbookContactPhoneWebSessionBean.java
src/java/org/mxchange/addressbook/beans/contact/phone/AddressbookContactPhoneWebSessionController.java
src/java/org/mxchange/addressbook/beans/country/AddressbookAdminCountryWebRequestBean.java
src/java/org/mxchange/addressbook/beans/country/AddressbookCountryWebApplicationBean.java
src/java/org/mxchange/addressbook/beans/email_address/AddressbookEmailChangeWebSessionBean.java
src/java/org/mxchange/addressbook/beans/features/AddressbookFeatureWebApplicationBean.java
src/java/org/mxchange/addressbook/beans/gender/AddressbookGenderWebApplicationBean.java
src/java/org/mxchange/addressbook/beans/helper/AddressbookWebRequestHelperBean.java
src/java/org/mxchange/addressbook/beans/localization/AddressbookLocalizationSessionBean.java
src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java [deleted file]
src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionController.java [deleted file]
src/java/org/mxchange/addressbook/beans/login/user/AddressbookUserLoginWebSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/addressbook/beans/login/user/AddressbookUserLoginWebSessionController.java [new file with mode: 0644]
src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookAdminMobileProviderWebRequestBean.java
src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookMobileProviderWebRequestBean.java
src/java/org/mxchange/addressbook/beans/phone/AddressbookAdminPhoneWebRequestBean.java
src/java/org/mxchange/addressbook/beans/phone/AddressbookPhoneWebApplicationBean.java
src/java/org/mxchange/addressbook/beans/profile/AddressbookUserProfileWebRequestBean.java
src/java/org/mxchange/addressbook/beans/profilemode/AddressbookProfileModeWebApplicationBean.java
src/java/org/mxchange/addressbook/beans/register/AddressbookUserRegisterWebSessionBean.java
src/java/org/mxchange/addressbook/beans/resendlink/AddressbookResendLinkWebSessionBean.java
src/java/org/mxchange/addressbook/beans/shares/AddressbookSharesWebSessionBean.java
src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebRequestBean.java
src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java
src/java/org/mxchange/addressbook/beans/user/password/AddressbookUserPasswordWebRequestBean.java

index 1b73639279285ba50ef97eeecd66f3f3341bb02a..fe6b533e764214ee011ef216f63bbdfc9bf90cb0 100644 (file)
 package org.mxchange.addressbook.beans;
 
 import java.io.Serializable;
+import java.security.Principal;
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
 import javax.faces.application.FacesMessage;
 import javax.faces.context.FacesContext;
+import org.mxchange.jusercore.model.user.UserUtils;
 
 /**
  * A general controller
@@ -32,6 +38,35 @@ public abstract class BaseAddressbookController implements Serializable {
         */
        private static final long serialVersionUID = 50_837_597_127_567_140L;
 
+       /**
+        * Protected constructor
+        */
+       protected BaseAddressbookController () {
+       }
+
+       /**
+        * Determines principal's name or returns null if no principal (security) is
+        * set.
+        * <p>
+        * @return Principal's name or null
+        */
+       protected String determinePrincipalName () {
+               // Get principal
+               Principal userPrincipal = FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal();
+
+               // Init with null
+               String principalName = null;
+
+               // Is the principal set?
+               if (userPrincipal instanceof Principal) {
+                       // Get principal's name
+                       principalName = userPrincipal.getName();
+               }
+
+               // Return it
+               return principalName;
+       }
+
        /**
         * Returns given property key or throws an exception if not found.
         * <p>
@@ -66,7 +101,7 @@ public abstract class BaseAddressbookController implements Serializable {
                // Is it null?
                if (null == contextValue) {
                        // Throw NPE
-                       throw new NullPointerException("parameterKey=" + parameterKey + " is not set.");
+                       throw new NullPointerException(MessageFormat.format("parameterKey={0} is not set.", parameterKey)); //NOI18N
                }
 
                // Return it
@@ -91,21 +126,45 @@ public abstract class BaseAddressbookController implements Serializable {
                }
 
                // Try to get context parameter
-               String contextParameter = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(String.format("is_debug_%s_enabled", controllerName)); //NOI18N
+               String contextParameter = this.getStringContextParameter(String.format("is_debug_%s_enabled", controllerName)); //NOI18N
 
                // Is it set and true?
-               boolean isEnabled = ((contextParameter instanceof String) && (contextParameter.equals("true"))); //NOI18N
+               boolean isEnabled = (Boolean.parseBoolean(contextParameter) == Boolean.TRUE);
 
                // Return it
                return isEnabled;
        }
 
+       /**
+        * Checks if given password is to weak to be used
+        * <p>
+        * @param password Clear-text password
+        * <p>
+        * @return Whether the entered password is to weak
+        */
+       protected boolean isWeakPassword (final String password) {
+               // Is parameter set?
+               if (null == password) {
+                       // Throw NPE
+                       throw new NullPointerException("password is null"); //NOI18N
+               }
+
+               // Get score value
+               double passwordScore = UserUtils.calculatePasswordScore(password);
+
+               // Is the score within range?
+               boolean isWeak = (passwordScore <= this.getIntegerContextParameter("min_user_password_score")); //NOI18N
+
+               // Return it
+               return isWeak;
+       }
+
        /**
         * Shows a faces message for given causing exception. The message from the
         * exception is being inserted into the message.
         * <p>
         * @param clientId Client id to send message to
-        * @param cause    Causing exception
+        * @param cause Causing exception
         */
        protected void showFacesMessage (final String clientId, final Throwable cause) {
                // Get context and add message
@@ -113,12 +172,47 @@ public abstract class BaseAddressbookController implements Serializable {
        }
 
        /**
-        * Shows a faces message with given message.
+        * Shows a faces message with given message (i18n) key.
         * <p>
         * @param clientId Client id to send message to
-        * @param message Causing exception
+        * @param i18nKey Message key
+        * <p>
+        * @throws NullPointerException If clientId or i18nKey is null
+        * @throws IllegalArgumentException If clientId or i18nKey is empty
         */
-       protected void showFacesMessage (final String clientId, final String message) {
+       protected void showFacesMessage (final String clientId, final String i18nKey) throws NullPointerException, IllegalArgumentException {
+               // Both parameter must be valid
+               if (null == clientId) {
+                       // Throw NPE
+                       throw new NullPointerException("clientId is null"); //NOI18N
+               } else if (clientId.isEmpty()) {
+                       // Is empty
+                       throw new IllegalArgumentException("clientId is null"); //NOI18N
+               } else if (null == i18nKey) {
+                       // Throw NPE
+                       throw new NullPointerException("i18nKey is null"); //NOI18N
+               } else if (i18nKey.isEmpty()) {
+                       // Is empty
+                       throw new IllegalArgumentException("i18nKey is null"); //NOI18N
+               }
+
+               // Get current locale
+               Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
+
+               // Get bundle bundle
+               ResourceBundle bundle = ResourceBundle.getBundle("org.mxchange.localization.bundle", locale);
+
+               // Default is i18nKey
+               String message = i18nKey;
+
+               // Try it
+               try {
+                       // Get message
+                       message = bundle.getString(i18nKey);
+               } catch (final MissingResourceException ex) {
+                       // Did not find it, ignored
+               }
+
                // Get context and add message
                FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(message));
        }
index 967e2cb131c2c173de811449dc85ae7d307781db..6a6b9fc2e0dd797a0c0bf9aff38b52efeec257db 100644 (file)
@@ -36,7 +36,7 @@ import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
+import org.mxchange.addressbook.beans.login.user.AddressbookUserLoginWebSessionController;
 import org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote;
 import org.mxchange.jaddressbookcore.events.addressbook.AddressbookLoadedEvent;
 import org.mxchange.jaddressbookcore.events.addressbook.ObservableAddressbookLoadedEvent;
@@ -119,6 +119,9 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme
         * Default constructor
         */
        public AddressbookWebSessionBean () {
+               // Call super constructor
+               super();
+
                // Init list
                AddressbookWebSessionBean.countSharesList = new ConcurrentHashMap<>(0);
        }
index ea05dcf6ca31482f07e02bc3a5a59c7c03e782ec..d82c75ff35f2ffc182f24d68691f475f70106fef 100644 (file)
@@ -31,6 +31,7 @@ import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.addressbook.beans.BaseAddressbookController;
+import org.mxchange.addressbook.beans.helper.AddressbookWebRequestHelperController;
 import org.mxchange.addressbook.beans.user.AddressbookUserWebSessionController;
 import org.mxchange.jcoreee.utils.FacesUtils;
 import org.mxchange.jusercore.events.confirmation.ObservableUserConfirmedAccountEvent;
@@ -40,7 +41,6 @@ import org.mxchange.jusercore.exceptions.UserStatusLockedException;
 import org.mxchange.jusercore.model.user.User;
 import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
 import org.mxchange.jusercore.model.user.status.UserAccountStatus;
-import org.mxchange.addressbook.beans.helper.AddressbookWebRequestHelperController;
 
 /**
  * A web request bean for confirmation link handling
@@ -73,22 +73,34 @@ public class AddressbookConfirmationLinkWebRequestBean extends BaseAddressbookCo
        private UserSessionBeanRemote userBean;
 
        /**
-        * User controller
+        * Event being fired when a user has confirmed the account
         */
        @Inject
-       private AddressbookUserWebSessionController userController;
+       @Any
+       private Event<ObservableUserConfirmedAccountEvent> userConfirmedEvent;
 
        /**
-        * Event being fired when a user has confirmed the account
+        * User controller
         */
        @Inject
-       @Any
-       private Event<ObservableUserConfirmedAccountEvent> userConfirmedEvent;
+       private AddressbookUserWebSessionController userController;
 
        /**
         * Default constructor
         */
        public AddressbookConfirmationLinkWebRequestBean () {
+               // Call super constructor
+               super();
+       }
+
+       @Override
+       public String getConfirmationKey () {
+               return this.confirmationKey;
+       }
+
+       @Override
+       public void setConfirmationKey (final String confirmationKey) {
+               this.confirmationKey = confirmationKey;
        }
 
        /**
@@ -109,16 +121,6 @@ public class AddressbookConfirmationLinkWebRequestBean extends BaseAddressbookCo
                }
        }
 
-       @Override
-       public String getConfirmationKey () {
-               return this.confirmationKey;
-       }
-
-       @Override
-       public void setConfirmationKey (final String confirmationKey) {
-               this.confirmationKey = confirmationKey;
-       }
-
        @Override
        public void maybeConfirmUserAccount () {
                // Is the confirmation key set?
index 9314278c06aeb693af8dff2c221875cb2d305a9d..91a8c59f7639db033b1b67c70338d74aab9acd62 100644 (file)
@@ -247,6 +247,8 @@ public class AddressbookAdminContactWebRequestBean extends BaseAddressbookContro
         * Default constructor
         */
        public AddressbookAdminContactWebRequestBean () {
+               // Call super constructor
+               super();
        }
 
        @Override
index 2bc2ef61571dc1d4654ace10a701ddadc2325b08..82dcded2a9341a8eb32f8657fbd101cf5d8a5943 100644 (file)
@@ -33,7 +33,7 @@ import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
+import org.mxchange.addressbook.beans.login.user.AddressbookUserLoginWebSessionController;
 import org.mxchange.addressbook.beans.user.AddressbookUserWebSessionController;
 import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
@@ -234,6 +234,9 @@ public class AddressbookContactWebSessionBean extends BaseAddressbookController
         * Default constructor
         */
        public AddressbookContactWebSessionBean () {
+               // Call super constructor
+               super();
+
                // Init lists/maps
                this.contactList = new LinkedList<>();
                this.emailAddressList = new LinkedList<>();
index 188970820d34f4a5708dc6b49969e66f65008b57..676c7c6b2b2ac77872f28cfa753850bb496161b1 100644 (file)
@@ -17,6 +17,7 @@
 package org.mxchange.addressbook.beans.contact.phone;
 
 import java.text.MessageFormat;
+import javax.annotation.PostConstruct;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Event;
 import javax.enterprise.event.Observes;
@@ -140,20 +141,11 @@ public class AddressbookAdminContactPhoneWebRequestBean extends BaseAddressbookC
         * Default constructor
         */
        public AddressbookAdminContactPhoneWebRequestBean () {
+               // Call super constructor
+               super();
+
                // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[3].getClassName(), Thread.currentThread().getStackTrace()[3].getMethodName());
                // System.out.println(MessageFormat.format("{0}: Constructed, caller: {1}", this.getClass().getSimpleName(), caller));
-
-               // Try it
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup the beans
-                       this.adminPhoneBean = (AdminContactsPhoneSessionBeanRemote) context.lookup("java:global/addressbook-ejb/adminContactPhone!org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote"); //NOI18N
-               } catch (final NamingException e) {
-                       // Throw again
-                       throw new FaceletException(e);
-               }
        }
 
        /**
@@ -414,6 +406,24 @@ public class AddressbookAdminContactPhoneWebRequestBean extends BaseAddressbookC
                return "admin_show_contact"; //NOI18N
        }
 
+       /**
+        * Post-construction method
+        */
+       @PostConstruct
+       public void init () {
+               // Try it
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup the beans
+                       this.adminPhoneBean = (AdminContactsPhoneSessionBeanRemote) context.lookup("java:global/addressbook-ejb/adminContactPhone!org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote"); //NOI18N
+               } catch (final NamingException e) {
+                       // Throw again
+                       throw new FaceletException(e);
+               }
+       }
+
        @Override
        public String unlinkFaxContactData () {
                // Is all data set
index faebb4a68507b203d384fea69e3296790b95ee30..fda02239b5ed98e7dbd786a8f749051160bacd18 100644 (file)
@@ -22,22 +22,23 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
-import javax.annotation.PostConstruct;
 import javax.enterprise.context.SessionScoped;
 import javax.enterprise.event.Observes;
-import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
 import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.addressbook.beans.BaseAddressbookController;
 import org.mxchange.addressbook.beans.contact.AddressbookContactWebSessionController;
-import org.mxchange.addressbook.beans.phone.AddressbookAdminPhoneWebRequestController;
+import org.mxchange.addressbook.beans.helper.AddressbookWebRequestHelperController;
 import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
 import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
-import org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote;
+import org.mxchange.jcontacts.events.fax.unlinked.ObservableAdminUnlinkedFaxNumberEvent;
+import org.mxchange.jcontacts.events.landline.unlinked.ObservableAdminUnlinkedLandLineNumberEvent;
+import org.mxchange.jcontacts.events.mobile.unlinked.ObservableAdminUnlinkedMobileNumberEvent;
+import org.mxchange.jphone.phonenumbers.DialableNumber;
+import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
 import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
 
 /**
@@ -55,15 +56,10 @@ public class AddressbookContactPhoneWebSessionBean extends BaseAddressbookContro
        private static final long serialVersionUID = 542_145_347_916L;
 
        /**
-        * Remote EJB for phone number (administrative)
-        */
-       private AdminPhoneSessionBeanRemote adminPhoneBean;
-
-       /**
-        * Administrative phone controller
+        * Bean helper
         */
        @Inject
-       private AddressbookAdminPhoneWebRequestController adminPhoneController;
+       private AddressbookWebRequestHelperController beanHelper;
 
        /**
         * General contact controller
@@ -72,15 +68,19 @@ public class AddressbookContactPhoneWebSessionBean extends BaseAddressbookContro
        private AddressbookContactWebSessionController contactController;
 
        /**
-        * "Cache" for contact lists, mostly only one is assigned. So this cache
-        * shouldn't grow beyond control.
+        * "Cache" for contact's mobile, land-line and fax numbers. Currently one
+        * per each type is supported. Maybe later this will change into a OneToMany
+        * relationship (one contact, many numbers).
         */
-       private final Map<Long, List<Contact>> contacts;
+       private final Map<DialableNumber, List<Contact>> contacts;
 
        /**
         * Default constructor
         */
        public AddressbookContactPhoneWebSessionBean () {
+               // Call super constructor
+               super();
+
                // Init lists/maps
                this.contacts = new HashMap<>(10);
        }
@@ -104,7 +104,7 @@ public class AddressbookContactPhoneWebSessionBean extends BaseAddressbookContro
                        throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
                } else if (event.getAddedContact().getContactId() < 1) {
                        // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N
+                       throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
                }
 
                // Clear this bean
@@ -112,7 +112,7 @@ public class AddressbookContactPhoneWebSessionBean extends BaseAddressbookContro
        }
 
        /**
-        * Event observer for newly added users by adminstrator
+        * Event observer for newly added users by administrator
         * <p>
         * @param event Event being fired
         */
@@ -136,6 +136,90 @@ public class AddressbookContactPhoneWebSessionBean extends BaseAddressbookContro
                this.clear();
        }
 
+       /**
+        * Event observer for unlinked fax contact by administrators
+        * <p>
+        * @param event Unlinked fax contact event
+        */
+       public void afterAdminUnlinkedFaxContactDataEvent (@Observes final ObservableAdminUnlinkedFaxNumberEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getUnlinkedFaxNumber() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.unlinkedFaxNumber is null"); //NOI18N
+               } else if (event.getUnlinkedFaxNumber().getPhoneId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.unlinkedFaxNumber.contactId is null"); //NOI18N
+               } else if (event.getUnlinkedFaxNumber().getPhoneId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUnlinkedFaxNumber(), event.getUnlinkedFaxNumber().getPhoneId())); //NOI18N
+               }
+
+               // Remove it from list
+               this.contacts.remove(event.getUnlinkedFaxNumber());
+
+               // Clear all data
+               this.clear();
+       }
+
+       /**
+        * Event observer for unlinked land-line contact by administrators
+        * <p>
+        * @param event Unlinked land-line contact event
+        */
+       public void afterAdminUnlinkedLandLineContactDataEvent (@Observes final ObservableAdminUnlinkedLandLineNumberEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getUnlinkedLandLineNumber() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.unlinkedLandLineNumber is null"); //NOI18N
+               } else if (event.getUnlinkedLandLineNumber().getPhoneId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.unlinkedLandLineNumber.contactId is null"); //NOI18N
+               } else if (event.getUnlinkedLandLineNumber().getPhoneId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUnlinkedLandLineNumber(), event.getUnlinkedLandLineNumber().getPhoneId())); //NOI18N
+               }
+
+               // Remove it from list
+               this.contacts.remove(event.getUnlinkedLandLineNumber());
+
+               // Clear all data
+               this.clear();
+       }
+
+       /**
+        * Event observer for unlinked mobile contact by administrators
+        * <p>
+        * @param event Unlinked mobile contact event
+        */
+       public void afterAdminUnlinkedMobileContactDataEvent (@Observes final ObservableAdminUnlinkedMobileNumberEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getUnlinkedMobileNumber() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.unlinkedMobileNumber is null"); //NOI18N
+               } else if (event.getUnlinkedMobileNumber().getPhoneId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.unlinkedMobileNumber.contactId is null"); //NOI18N
+               } else if (event.getUnlinkedMobileNumber().getPhoneId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUnlinkedMobileNumber(), event.getUnlinkedMobileNumber().getPhoneId())); //NOI18N
+               }
+
+               // Remove it from list
+               this.contacts.remove(event.getUnlinkedMobileNumber());
+
+               // Clear all data
+               this.clear();
+       }
+
        /**
         * Event observer for updated contact data by administrators
         * <p>
@@ -156,17 +240,20 @@ public class AddressbookContactPhoneWebSessionBean extends BaseAddressbookContro
                        // Not avalid id
                        throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
                }
+
+               // Clear all data
+               this.clear();
        }
 
        @Override
-       public List<Contact> allMobileContacts () {
+       public List<Contact> allFaxNumberContacts () {
                // Get id
-               Long phoneId = this.adminPhoneController.getMobileNumber().getPhoneId();
+               DialableFaxNumber faxNumber = this.beanHelper.getFaxNumber();
 
                // Is cache there?
-               if (this.contacts.containsKey(phoneId)) {
+               if (this.contacts.containsKey(faxNumber)) {
                        // Return cached version
-                       return this.contacts.get(phoneId);
+                       return this.contacts.get(faxNumber);
                } else {
                        // Ask bean
                        List<Contact> list = new LinkedList<>();
@@ -174,32 +261,77 @@ public class AddressbookContactPhoneWebSessionBean extends BaseAddressbookContro
                        // "Walk" through all contacts
                        for (final Contact contact : this.contactController.allContacts()) {
                                // Is mobile instance the same?
-                               if (Objects.equals(contact.getContactMobileNumber(), this.adminPhoneController.getMobileNumber())) {
+                               if (Objects.equals(contact.getContactFaxNumber(), this.beanHelper.getFaxNumber())) {
                                        // Found one
                                        list.add(contact);
                                }
                        }
 
                        // Store result in cache
-                       this.contacts.put(phoneId, list);
+                       this.contacts.put(faxNumber, list);
 
                        // Return now-cached list
                        return list;
                }
        }
 
-       @PostConstruct
-       public void init () {
-               // Try it
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup the beans
-                       this.adminPhoneBean = (AdminPhoneSessionBeanRemote) context.lookup("java:global/addressbook-ejb/adminphone!org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote"); //NOI18N
-               } catch (final NamingException e) {
-                       // Throw again
-                       throw new FaceletException(e);
+       @Override
+       public List<Contact> allLandLineNumberContacts () {
+               // Get id
+               DialableLandLineNumber landLineNumber = this.beanHelper.getLandLineNumber();
+
+               // Is cache there?
+               if (this.contacts.containsKey(landLineNumber)) {
+                       // Return cached version
+                       return this.contacts.get(landLineNumber);
+               } else {
+                       // Ask bean
+                       List<Contact> list = new LinkedList<>();
+
+                       // "Walk" through all contacts
+                       for (final Contact contact : this.contactController.allContacts()) {
+                               // Is mobile instance the same?
+                               if (Objects.equals(contact.getContactLandLineNumber(), this.beanHelper.getLandLineNumber())) {
+                                       // Found one
+                                       list.add(contact);
+                               }
+                       }
+
+                       // Store result in cache
+                       this.contacts.put(landLineNumber, list);
+
+                       // Return now-cached list
+                       return list;
+               }
+       }
+
+       @Override
+       public List<Contact> allMobileNumberContacts () {
+               // Get id
+               DialableMobileNumber mobileNumber = this.beanHelper.getMobileNumber();
+
+               // Is cache there?
+               if (this.contacts.containsKey(mobileNumber)) {
+                       // Return cached version
+                       return this.contacts.get(mobileNumber);
+               } else {
+                       // Ask bean
+                       List<Contact> list = new LinkedList<>();
+
+                       // "Walk" through all contacts
+                       for (final Contact contact : this.contactController.allContacts()) {
+                               // Is mobile instance the same?
+                               if (Objects.equals(contact.getContactMobileNumber(), this.beanHelper.getMobileNumber())) {
+                                       // Found one
+                                       list.add(contact);
+                               }
+                       }
+
+                       // Store result in cache
+                       this.contacts.put(mobileNumber, list);
+
+                       // Return now-cached list
+                       return list;
                }
        }
 
index d6ced2f70c9af5c7bbc8178e947b77d6c3f80a7e..c22353d7c43ece72045c72d9a14296a897bd75f2 100644 (file)
@@ -30,15 +30,24 @@ import org.mxchange.jcontacts.contact.Contact;
 public interface AddressbookContactPhoneWebSessionController extends Serializable {
 
        /**
-        * Minimum password length
+        * Getter for all contacts having current fax number linked
+        * <p>
+        * @return List of all linked contacts
+        */
+       List<Contact> allFaxNumberContacts ();
+
+       /**
+        * Getter for all contacts having current land-line number linked
+        * <p>
+        * @return List of all linked contacts
         */
-       public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
+       List<Contact> allLandLineNumberContacts ();
 
        /**
-        * Getter for all contacts having current cellphone instance linked
+        * Getter for all contacts having current mobile number linked
         * <p>
         * @return List of all linked contacts
         */
-       List<Contact> allMobileContacts ();
+       List<Contact> allMobileNumberContacts ();
 
 }
index 3ed5fb321c76a087a8b4fb50efcee2b8db592ca8..2012ce69cb06f74ab2fd14c37b755233d9dea383 100644 (file)
@@ -103,6 +103,8 @@ public class AddressbookAdminCountryWebRequestBean extends BaseAddressbookContro
         * Default constructor
         */
        public AddressbookAdminCountryWebRequestBean () {
+               // Call super constructor
+               super();
        }
 
        @Override
index 68366ba028d77b1161ed2025a3f52e9e9f9be79c..34f2ecc3475b68af4de72f03c8e43667ec335431 100644 (file)
@@ -59,6 +59,8 @@ public class AddressbookCountryWebApplicationBean extends BaseAddressbookControl
         * Default constructor
         */
        public AddressbookCountryWebApplicationBean () {
+               // Call super constructor
+               super();
        }
 
        /**
index ea0b5217338fca2a0f181f0307ce707d398d250a..4af4b189cde6f901866bec512f4c87e50b9f834b 100644 (file)
@@ -29,7 +29,7 @@ import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.addressbook.beans.BaseAddressbookController;
 import org.mxchange.addressbook.beans.features.AddressbookFeaturesWebApplicationController;
-import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
+import org.mxchange.addressbook.beans.login.user.AddressbookUserLoginWebSessionController;
 import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jcoreee.utils.FacesUtils;
 import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
@@ -88,6 +88,8 @@ public class AddressbookEmailChangeWebSessionBean extends BaseAddressbookControl
         * Default constructor
         */
        public AddressbookEmailChangeWebSessionBean () {
+               // Call super constructor
+               super();
        }
 
        @Override
index 09ddd617de8742025c6eb47603dc035add66d611..68d085ca52289aee03f918f6be013874ab5c10c7 100644 (file)
@@ -39,6 +39,8 @@ public class AddressbookFeatureWebApplicationBean extends BaseAddressbookControl
         * Default constructor
         */
        public AddressbookFeatureWebApplicationBean () {
+               // Call super constructor
+               super();
        }
 
        /**
index 5e6c65c488e3316a9aaff1a17300022c9efcfa19..381b86f69b7a32a754fceeb07fcba103a2abb30e 100644 (file)
@@ -42,6 +42,8 @@ public class AddressbookGenderWebApplicationBean extends BaseAddressbookControll
         * Default constructor
         */
        public AddressbookGenderWebApplicationBean () {
+               // Call super constructor
+               super();
        }
 
        @Override
index a7aa605cefe9cb45773b4af26479149ef149c61d..704b770ae74e27ba85cff1b0db094ec381e48b11 100644 (file)
@@ -102,6 +102,9 @@ public class AddressbookWebRequestHelperBean implements AddressbookWebRequestHel
         * Default constructor
         */
        public AddressbookWebRequestHelperBean () {
+               // Call super constructor
+               super();
+
                // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[3].getClassName(), Thread.currentThread().getStackTrace()[3].getMethodName());
                // System.out.println(MessageFormat.format("{0}: Constructed, caller: {1}", this.getClass().getSimpleName(), caller));
        }
index 89008aaa9873a3972302c830aa451790edc4a4bd..121f097e0c680c91292eb008f508c5804266bca3 100644 (file)
@@ -53,6 +53,8 @@ public class AddressbookLocalizationSessionBean extends BaseAddressbookControlle
         * Default constructor
         */
        public AddressbookLocalizationSessionBean () {
+               // Call super constructor
+               super();
        }
 
        /**
diff --git a/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java
deleted file mode 100644 (file)
index 6d6baf1..0000000
+++ /dev/null
@@ -1,445 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.beans.login;
-
-import java.text.MessageFormat;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.SessionScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Any;
-import javax.faces.context.FacesContext;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.user.AddressbookUserWebSessionController;
-import org.mxchange.jusercore.container.login.LoginContainer;
-import org.mxchange.jusercore.container.login.UserLoginContainer;
-import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent;
-import org.mxchange.jusercore.events.login.UserLoggedInEvent;
-import org.mxchange.jusercore.events.logout.ObservableUserLogoutEvent;
-import org.mxchange.jusercore.events.logout.UserLogoutEvent;
-import org.mxchange.jusercore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
-import org.mxchange.jusercore.exceptions.UserNotFoundException;
-import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
-import org.mxchange.jusercore.exceptions.UserStatusLockedException;
-import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
-import org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.UserUtils;
-import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
-import org.mxchange.jusercore.model.user.password_history.UserPasswordHistorySessionBeanRemote;
-import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
-import org.mxchange.jusercore.model.user.status.UserAccountStatus;
-
-/**
- * A web bean for user registration
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("userLoginController")
-@SessionScoped
-public class AddressbookUserLoginWebSessionBean extends BaseAddressbookController implements AddressbookUserLoginWebSessionController {
-
-       /**
-        * Path name for guest base template
-        */
-       private static final String GUEST_BASE_TEMPLATE_NAME = "guest/guest";
-
-       /**
-        * Path name for logged-in user base template
-        */
-       private static final String USER_BASE_TEMPLATE_NAME = "login/user/user";
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 47_828_986_719_691_592L;
-
-       /**
-        * Template type for pages that might be displayed in guest area and login
-        * area.
-        */
-       private String baseTemplatePathName;
-
-       /**
-        * Logged-in user instance
-        */
-       private User loggedInUser;
-
-       /**
-        * Event fired when user has logged in
-        */
-       @Inject
-       @Any
-       private Event<ObservableUserLoggedInEvent> loginEvent;
-
-       /**
-        * User controller
-        */
-       @Inject
-       private AddressbookUserWebSessionController userController;
-
-       /**
-        * Current password
-        */
-       private String userCurrentPassword;
-
-       /**
-        * Flag whether the user has logged-in, set only from inside
-        */
-       private boolean userLoggedIn;
-
-       /**
-        * Remote register session-scoped bean
-        */
-       private UserLoginSessionBeanRemote userLoginBean;
-
-       /**
-        * Event fired when user has logged in
-        */
-       @Inject
-       @Any
-       private Event<ObservableUserLoggedInEvent> userLoginEvent;
-
-       /**
-        * Event fired when user has logged out
-        */
-       @Inject
-       @Any
-       private Event<ObservableUserLogoutEvent> userLogoutEvent;
-
-       /**
-        * User's password history
-        */
-       private List<PasswordHistory> userPasswordHistory;
-
-       /**
-        * EJB for user's password history
-        */
-       private UserPasswordHistorySessionBeanRemote userPasswordHistoryBean;
-
-       /**
-        * Default constructor
-        */
-       public AddressbookUserLoginWebSessionBean () {
-               // Defaul template is guest
-               this.baseTemplatePathName = GUEST_BASE_TEMPLATE_NAME;
-       }
-
-       /**
-        * Method being call after user's password has been updated (and history
-        * entry has been created).
-        * <p>
-        * @param event Event being observed
-        */
-       public void afterUserUpdatedPasswordEvent (@Observes final ObservableUpdatedUserPasswordEvent event) {
-               // Check parameter
-               if (null == event) {
-                       // Throw NPE
-                       throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getPasswordHistory() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("event.passwordHistory is null"); //NOI18N
-               } else if (event.getPasswordHistory().getUserPasswordHistoryId() == null) {
-                       // ... and again
-                       throw new NullPointerException("event.passwordHistory.userPasswordHistoryId is null"); //NOI18N
-               } else if (event.getPasswordHistory().getUserPasswordHistoryId() < 1) {
-                       // Invalid value
-                       throw new IllegalArgumentException(MessageFormat.format("event.passwordHistory.userPasswordHistoryId={0} is in valid", event.getPasswordHistory().getUserPasswordHistoryId())); //NOI18N
-               }
-
-               // All fine, so update list
-               this.updatePasswordHistory(event.getPasswordHistory());
-       }
-
-       @Override
-       public String doAdminLogout () {
-               // Is a user logged-in?
-               if (this.isUserLoggedIn()) {
-                       // Call other logout
-                       return this.doUserLogout();
-               }
-
-               // Invalidate session
-               FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
-
-               // Set template type to guest
-               this.setBaseTemplatePathName(GUEST_BASE_TEMPLATE_NAME); //NOI18N
-
-               // Redirect to index
-               return "index?faces-redirect=true"; //NOI18N
-       }
-
-       @Override
-       public String doUserLogin () {
-               // Get user instance
-               User user = this.userController.createUserLogin();
-
-               // Create login container
-               LoginContainer container = new UserLoginContainer(user, this.userController.getUserPassword());
-
-               try {
-                       // Call bean
-                       User confirmedUser = this.userLoginBean.validateUserAccountStatus(container);
-
-                       // All fine here so set it here
-                       this.setLoggedInUser(confirmedUser);
-
-                       // Retrieve user's password list
-                       this.userPasswordHistory = this.userPasswordHistoryBean.getUserPasswordHistory(confirmedUser);
-
-                       // Set template to "login"
-                       this.setBaseTemplatePathName(USER_BASE_TEMPLATE_NAME); //NOI18N
-
-                       // Fire event away. Keep this last before return statement.
-                       this.userLoginEvent.fire(new UserLoggedInEvent(confirmedUser));
-
-                       // Clear this bean
-                       this.clear();
-
-                       // All fine
-                       return "login_user"; //NOI18N
-               } catch (final UserNotFoundException ex) {
-                       // Show JSF message
-                       this.showFacesMessage("form_user_login:userName", "ERROR_USER_NOT_FOUND"); //NOI18N
-                       return ""; //NOI18N
-               } catch (final UserStatusLockedException ex) {
-                       this.showFacesMessage("form_user_login:userName", "ERROR_USER_STATUS_LOCKED"); //NOI18N
-                       return ""; //NOI18N
-               } catch (final UserStatusUnconfirmedException ex) {
-                       this.showFacesMessage("form_user_login:userName", "ERROR_USER_STATUS_UNCONFIRMED"); //NOI18N
-                       return ""; //NOI18N
-               } catch (final UserPasswordMismatchException ex) {
-                       // Show JSF message
-                       this.showFacesMessage("form_user_login:userPassword", "ERROR_USER_PASSWORD_MISMATCH"); //NOI18N
-                       return ""; //NOI18N
-               }
-       }
-
-       @Override
-       public String doUserLogout () {
-               // Is loggedInUser set?
-               if (this.getLoggedInUser() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("this.loggedInUser is null"); //NOI18N
-               } else if (this.getLoggedInUser().getUserId() == null) {
-                       // Throw again
-                       throw new NullPointerException("this.loggedInUser.userId is null"); //NOI18N
-               } else if (this.getLoggedInUser().getUserId() < 1) {
-                       // Invalid user id
-                       throw new IllegalStateException(MessageFormat.format("this.loggedInUser.userId={0} is not valid.", this.getLoggedInUser().getUserId())); //NOI18N
-               }
-
-               // Fire event
-               this.userLogoutEvent.fire(new UserLogoutEvent(this.getLoggedInUser()));
-
-               // Invalidate session
-               FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
-
-               // Unset any user instances
-               this.setLoggedInUser(null);
-               this.setBaseTemplatePathName(GUEST_BASE_TEMPLATE_NAME); //NOI18N
-
-               // Redirect to index
-               return "index"; //NOI18N
-       }
-
-       @Override
-       public String getBaseTemplatePathName () {
-               return this.baseTemplatePathName;
-       }
-
-       @Override
-       public void setBaseTemplatePathName (final String baseTemplatePathName) {
-               this.baseTemplatePathName = baseTemplatePathName;
-       }
-
-       @Override
-       public User getLoggedInUser () {
-               return this.loggedInUser;
-       }
-
-       @Override
-       public void setLoggedInUser (final User loggedInUser) {
-               this.loggedInUser = loggedInUser;
-       }
-
-       @Override
-       public String getUserCurrentPassword () {
-               return this.userCurrentPassword;
-       }
-
-       @Override
-       public void setUserCurrentPassword (final String userCurrentPassword) {
-               this.userCurrentPassword = userCurrentPassword;
-       }
-
-       @Override
-       public List<PasswordHistory> getUserPasswordHistory () {
-               return Collections.unmodifiableList(this.userPasswordHistory);
-       }
-
-       @Override
-       public boolean ifCurrentPasswordMatches () {
-               // The current password must be set and not empty
-               if (this.getUserCurrentPassword() == null) {
-                       // Is not set
-                       throw new NullPointerException("this.userCurrentPassword is null"); //NOI18N
-               } else if (this.getUserCurrentPassword().isEmpty()) {
-                       // Is set empty
-                       throw new IllegalStateException("this.userCurrentPassword is empty."); //NOI18N
-               }
-
-               // Create "container"
-               LoginContainer container = new UserLoginContainer(this.getLoggedInUser(), this.getUserCurrentPassword());
-
-               // Now check if it matches
-               return UserUtils.ifPasswordMatches(container, this.getLoggedInUser());
-       }
-
-       @Override
-       public boolean ifUserMustChangePassword () {
-               return ((this.isUserLoggedIn()) && (Objects.equals(this.getLoggedInUser().getUserMustChangePassword(), Boolean.TRUE)));
-       }
-
-       /**
-        * Post-construction method
-        */
-       @PostConstruct
-       public void init () {
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup
-                       this.userLoginBean = (UserLoginSessionBeanRemote) context.lookup("java:global/addressbook-ejb/login!org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote"); //NOI18N
-
-                       // Also find this
-                       this.userPasswordHistoryBean = (UserPasswordHistorySessionBeanRemote) context.lookup("java:global/addressbook-ejb/userPasswordHistory!org.mxchange.jusercore.model.user.password_history.UserPasswordHistorySessionBeanRemote"); //NOI18N
-
-                       // Defaul template is guest
-                       this.baseTemplatePathName = GUEST_BASE_TEMPLATE_NAME;
-               } catch (final NamingException ex) {
-                       // Continue to throw
-                       throw new FaceletException(ex);
-               }
-       }
-
-       @Override
-       public boolean isInvisible () {
-               // Check on login
-               if (!this.isUserLoggedIn()) {
-                       // Not logged in!
-                       throw new IllegalStateException("isInvisible() has been invoked for a guest."); //NOI18N
-               }
-
-               // Check logged-in first, then invisibility
-               return Objects.equals(this.getLoggedInUser().getUserProfileMode(), ProfileMode.INVISIBLE);
-       }
-
-       @Override
-       public boolean isPasswordInHistory (final String userPassword) {
-               // Default is not found
-               boolean isPasswordInHistory = false;
-
-               // Init variables
-               int count = 1;
-               int maxEntries = this.getIntegerContextParameter("max_user_password_history"); //NOI18N
-
-               // Check all passwords
-               for (final PasswordHistory entry : this.getUserPasswordHistory()) {
-                       // Is password the same?
-                       if (UserUtils.ifPasswordMatches(userPassword, entry.getUserPasswordHistoryUser())) {
-                               // Yes, found it
-                               isPasswordInHistory = true;
-                               break;
-                       } else if (count == maxEntries) {
-                               // Maximum reached
-                               break;
-                       }
-
-                       // Count up
-                       count++;
-               }
-
-               // Return status
-               return isPasswordInHistory;
-       }
-
-       @Override
-       public boolean isUserLoggedIn () {
-               // Compare instance
-               this.userLoggedIn = ((this.getLoggedInUser() instanceof User) && (Objects.equals(this.getLoggedInUser().getUserAccountStatus(), UserAccountStatus.CONFIRMED)));
-
-               // Return it
-               return this.userLoggedIn;
-       }
-
-       /**
-        * Clears this bean
-        */
-       private void clear () {
-               // Clear all fields
-               this.setUserCurrentPassword(null);
-       }
-
-       /**
-        * Updates password history by adding given entry to it as long as it is not
-        * there.
-        * <p>
-        * @param passwordHistory Password history entry
-        */
-       private void updatePasswordHistory (final PasswordHistory passwordHistory) {
-               if (null == passwordHistory) {
-                       // Throw NPE
-                       throw new NullPointerException("passwordHistory is null"); //NOI18N
-               } else if (passwordHistory.getUserPasswordHistoryId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("passwordHistory.userPasswordHistoryId is null"); //NOI18N
-               } else if (passwordHistory.getUserPasswordHistoryId() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("passwordHistory.userPasswordHistoryId={0} is not valid.", passwordHistory.getUserPasswordHistoryId())); //NOI18N
-               }
-
-               // Is it there?
-               if (this.userPasswordHistory.contains(passwordHistory)) {
-                       // Excact copy found
-                       return;
-               }
-
-               // Check all entries
-               for (final PasswordHistory entry : this.userPasswordHistory) {
-                       // Is same id number?
-                       if (Objects.equals(entry.getUserPasswordHistoryId(), passwordHistory.getUserPasswordHistoryId())) {
-                               // Found it
-                               return;
-                       }
-               }
-
-               // Not found, so add it
-               this.userPasswordHistory.add(passwordHistory);
-       }
-
-}
diff --git a/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionController.java b/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionController.java
deleted file mode 100644 (file)
index 04276da..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.beans.login;
-
-import java.io.Serializable;
-import java.util.List;
-import javax.ejb.Local;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
-
-/**
- * An interface for registration web controllers
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Local
-public interface AddressbookUserLoginWebSessionController extends Serializable {
-
-       /**
-        * Checks whether given clear-text password is in user's password history.
-        * <p>
-        * @param userPassword Clear-text password
-        * <p>
-        * @return Whether clear-text password is in user's password history
-        */
-       boolean isPasswordInHistory (final String userPassword);
-
-       /**
-        * Getter for base template type
-        * <p>
-        * @return Template type
-        */
-       String getBaseTemplatePathName ();
-
-       /**
-        * Setter for base template type
-        * <p>
-        * @param baseTemplatePathName Template type
-        */
-       void setBaseTemplatePathName (final String baseTemplatePathName);
-
-       /**
-        * Logout for administrator area. If a logged-in user instance exists, it is
-        * being logged-out, too.
-        * <p>
-        * @return Outcome (should be redirected)
-        */
-       String doAdminLogout ();
-
-       /**
-        * Logins the user, if the account is found, confirmed and unlocked.
-        * <p>
-        * @return Redirect target
-        */
-       String doUserLogin ();
-
-       /**
-        * Logout for current user by invalidating the current session.
-        * <p>
-        * @return Outcome (should be redirected)
-        */
-       String doUserLogout ();
-
-       /**
-        * Getter for logged-in user instance
-        * <p>
-        * @return Logged-in user instance
-        */
-       User getLoggedInUser ();
-
-       /**
-        * Setter for logged-in user instance
-        * <p>
-        * @param loggedInUser Logged-in user instance
-        */
-       void setLoggedInUser (final User loggedInUser);
-
-       /**
-        * Checks whether the user is logged-in
-        * <p>
-        * @return Whether the user is logged-in
-        */
-       boolean isUserLoggedIn ();
-
-       /**
-        * Checks whether the user needs to change password
-        * <p>
-        * @return Whether the user needs to change password
-        */
-       boolean ifUserMustChangePassword ();
-
-       /**
-        * Whether the currently logged-in user is invisible
-        * <p>
-        * @return Whether the currently logged-in user is invisible
-        */
-       boolean isInvisible ();
-
-       /**
-        * Setter for current password (clear text)
-        * <p>
-        * @param userCurrentPassword Current password
-        */
-       void setUserCurrentPassword (final String userCurrentPassword);
-
-       /**
-        * Getter for current password (clear text)
-        * <p>
-        * @return Current password
-        */
-       String getUserCurrentPassword ();
-
-       /**
-        * Checks whether the (previously entered) current password matches with
-        * from the user instance.
-        * <p>
-        * @return If current password matches
-        */
-       boolean ifCurrentPasswordMatches ();
-
-       /**
-        * Getter for user's password history
-        * <p>
-        * @return User's password history
-        */
-       List<PasswordHistory> getUserPasswordHistory ();
-
-}
diff --git a/src/java/org/mxchange/addressbook/beans/login/user/AddressbookUserLoginWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/login/user/AddressbookUserLoginWebSessionBean.java
new file mode 100644 (file)
index 0000000..44e3c1e
--- /dev/null
@@ -0,0 +1,448 @@
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.beans.login.user;
+
+import java.text.MessageFormat;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+import javax.faces.context.FacesContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.addressbook.beans.BaseAddressbookController;
+import org.mxchange.addressbook.beans.user.AddressbookUserWebSessionController;
+import org.mxchange.jusercore.container.login.LoginContainer;
+import org.mxchange.jusercore.container.login.UserLoginContainer;
+import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent;
+import org.mxchange.jusercore.events.login.UserLoggedInEvent;
+import org.mxchange.jusercore.events.logout.ObservableUserLogoutEvent;
+import org.mxchange.jusercore.events.logout.UserLogoutEvent;
+import org.mxchange.jusercore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
+import org.mxchange.jusercore.exceptions.UserNotFoundException;
+import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
+import org.mxchange.jusercore.exceptions.UserStatusLockedException;
+import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
+import org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.UserUtils;
+import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
+import org.mxchange.jusercore.model.user.password_history.UserPasswordHistorySessionBeanRemote;
+import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
+import org.mxchange.jusercore.model.user.status.UserAccountStatus;
+
+/**
+ * A web bean for user registration
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("userLoginController")
+@SessionScoped
+public class AddressbookUserLoginWebSessionBean extends BaseAddressbookController implements AddressbookUserLoginWebSessionController {
+
+       /**
+        * Path name for guest base template
+        */
+       private static final String GUEST_BASE_TEMPLATE_NAME = "guest/guest";
+
+       /**
+        * Path name for logged-in user base template
+        */
+       private static final String USER_BASE_TEMPLATE_NAME = "login/user/user";
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 47_828_986_719_691_592L;
+
+       /**
+        * Template type for pages that might be displayed in guest area and login
+        * area.
+        */
+       private String baseTemplatePathName;
+
+       /**
+        * Logged-in user instance
+        */
+       private User loggedInUser;
+
+       /**
+        * Event fired when user has logged in
+        */
+       @Inject
+       @Any
+       private Event<ObservableUserLoggedInEvent> loginEvent;
+
+       /**
+        * User controller
+        */
+       @Inject
+       private AddressbookUserWebSessionController userController;
+
+       /**
+        * Current password
+        */
+       private String userCurrentPassword;
+
+       /**
+        * Flag whether the user has logged-in, set only from inside
+        */
+       private boolean userLoggedIn;
+
+       /**
+        * Remote register session-scoped bean
+        */
+       private UserLoginSessionBeanRemote userLoginBean;
+
+       /**
+        * Event fired when user has logged in
+        */
+       @Inject
+       @Any
+       private Event<ObservableUserLoggedInEvent> userLoginEvent;
+
+       /**
+        * Event fired when user has logged out
+        */
+       @Inject
+       @Any
+       private Event<ObservableUserLogoutEvent> userLogoutEvent;
+
+       /**
+        * User's password history
+        */
+       private List<PasswordHistory> userPasswordHistory;
+
+       /**
+        * EJB for user's password history
+        */
+       private UserPasswordHistorySessionBeanRemote userPasswordHistoryBean;
+
+       /**
+        * Default constructor
+        */
+       public AddressbookUserLoginWebSessionBean () {
+               // Call super constructor
+               super();
+
+               // Defaul template is guest
+               this.baseTemplatePathName = GUEST_BASE_TEMPLATE_NAME;
+       }
+
+       /**
+        * Method being call after user's password has been updated (and history
+        * entry has been created).
+        * <p>
+        * @param event Event being observed
+        */
+       public void afterUserUpdatedPasswordEvent (@Observes final ObservableUpdatedUserPasswordEvent event) {
+               // Check parameter
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getPasswordHistory() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.passwordHistory is null"); //NOI18N
+               } else if (event.getPasswordHistory().getUserPasswordHistoryId() == null) {
+                       // ... and again
+                       throw new NullPointerException("event.passwordHistory.userPasswordHistoryId is null"); //NOI18N
+               } else if (event.getPasswordHistory().getUserPasswordHistoryId() < 1) {
+                       // Invalid value
+                       throw new IllegalArgumentException(MessageFormat.format("event.passwordHistory.userPasswordHistoryId={0} is in valid", event.getPasswordHistory().getUserPasswordHistoryId())); //NOI18N
+               }
+
+               // All fine, so update list
+               this.updatePasswordHistory(event.getPasswordHistory());
+       }
+
+       @Override
+       public String doAdminLogout () {
+               // Is a user logged-in?
+               if (this.isUserLoggedIn()) {
+                       // Call other logout
+                       return this.doUserLogout();
+               }
+
+               // Invalidate session
+               FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
+
+               // Set template type to guest
+               this.setBaseTemplatePathName(GUEST_BASE_TEMPLATE_NAME); //NOI18N
+
+               // Redirect to index
+               return "index?faces-redirect=true"; //NOI18N
+       }
+
+       @Override
+       public String doUserLogin () {
+               // Get user instance
+               User user = this.userController.createUserLogin();
+
+               // Create login container
+               LoginContainer container = new UserLoginContainer(user, this.userController.getUserPassword());
+
+               try {
+                       // Call bean
+                       User confirmedUser = this.userLoginBean.validateUserAccountStatus(container);
+
+                       // All fine here so set it here
+                       this.setLoggedInUser(confirmedUser);
+
+                       // Retrieve user's password list
+                       this.userPasswordHistory = this.userPasswordHistoryBean.getUserPasswordHistory(confirmedUser);
+
+                       // Set template to "login"
+                       this.setBaseTemplatePathName(USER_BASE_TEMPLATE_NAME); //NOI18N
+
+                       // Fire event away. Keep this last before return statement.
+                       this.userLoginEvent.fire(new UserLoggedInEvent(confirmedUser));
+
+                       // Clear this bean
+                       this.clear();
+
+                       // All fine
+                       return "login_user"; //NOI18N
+               } catch (final UserNotFoundException ex) {
+                       // Show JSF message
+                       this.showFacesMessage("form_user_login:userName", "ERROR_USER_NOT_FOUND"); //NOI18N
+                       return ""; //NOI18N
+               } catch (final UserStatusLockedException ex) {
+                       this.showFacesMessage("form_user_login:userName", "ERROR_USER_STATUS_LOCKED"); //NOI18N
+                       return ""; //NOI18N
+               } catch (final UserStatusUnconfirmedException ex) {
+                       this.showFacesMessage("form_user_login:userName", "ERROR_USER_STATUS_UNCONFIRMED"); //NOI18N
+                       return ""; //NOI18N
+               } catch (final UserPasswordMismatchException ex) {
+                       // Show JSF message
+                       this.showFacesMessage("form_user_login:userPassword", "ERROR_USER_PASSWORD_MISMATCH"); //NOI18N
+                       return ""; //NOI18N
+               }
+       }
+
+       @Override
+       public String doUserLogout () {
+               // Is loggedInUser set?
+               if (this.getLoggedInUser() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("this.loggedInUser is null"); //NOI18N
+               } else if (this.getLoggedInUser().getUserId() == null) {
+                       // Throw again
+                       throw new NullPointerException("this.loggedInUser.userId is null"); //NOI18N
+               } else if (this.getLoggedInUser().getUserId() < 1) {
+                       // Invalid user id
+                       throw new IllegalStateException(MessageFormat.format("this.loggedInUser.userId={0} is not valid.", this.getLoggedInUser().getUserId())); //NOI18N
+               }
+
+               // Fire event
+               this.userLogoutEvent.fire(new UserLogoutEvent(this.getLoggedInUser()));
+
+               // Invalidate session
+               FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
+
+               // Unset any user instances
+               this.setLoggedInUser(null);
+               this.setBaseTemplatePathName(GUEST_BASE_TEMPLATE_NAME); //NOI18N
+
+               // Redirect to index
+               return "index"; //NOI18N
+       }
+
+       @Override
+       public String getBaseTemplatePathName () {
+               return this.baseTemplatePathName;
+       }
+
+       @Override
+       public void setBaseTemplatePathName (final String baseTemplatePathName) {
+               this.baseTemplatePathName = baseTemplatePathName;
+       }
+
+       @Override
+       public User getLoggedInUser () {
+               return this.loggedInUser;
+       }
+
+       @Override
+       public void setLoggedInUser (final User loggedInUser) {
+               this.loggedInUser = loggedInUser;
+       }
+
+       @Override
+       public String getUserCurrentPassword () {
+               return this.userCurrentPassword;
+       }
+
+       @Override
+       public void setUserCurrentPassword (final String userCurrentPassword) {
+               this.userCurrentPassword = userCurrentPassword;
+       }
+
+       @Override
+       public List<PasswordHistory> getUserPasswordHistory () {
+               return Collections.unmodifiableList(this.userPasswordHistory);
+       }
+
+       @Override
+       public boolean ifCurrentPasswordMatches () {
+               // The current password must be set and not empty
+               if (this.getUserCurrentPassword() == null) {
+                       // Is not set
+                       throw new NullPointerException("this.userCurrentPassword is null"); //NOI18N
+               } else if (this.getUserCurrentPassword().isEmpty()) {
+                       // Is set empty
+                       throw new IllegalStateException("this.userCurrentPassword is empty."); //NOI18N
+               }
+
+               // Create "container"
+               LoginContainer container = new UserLoginContainer(this.getLoggedInUser(), this.getUserCurrentPassword());
+
+               // Now check if it matches
+               return UserUtils.ifPasswordMatches(container, this.getLoggedInUser());
+       }
+
+       @Override
+       public boolean ifUserMustChangePassword () {
+               return ((this.isUserLoggedIn()) && (Objects.equals(this.getLoggedInUser().getUserMustChangePassword(), Boolean.TRUE)));
+       }
+
+       /**
+        * Post-construction method
+        */
+       @PostConstruct
+       public void init () {
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup
+                       this.userLoginBean = (UserLoginSessionBeanRemote) context.lookup("java:global/addressbook-ejb/login!org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote"); //NOI18N
+
+                       // Also find this
+                       this.userPasswordHistoryBean = (UserPasswordHistorySessionBeanRemote) context.lookup("java:global/addressbook-ejb/userPasswordHistory!org.mxchange.jusercore.model.user.password_history.UserPasswordHistorySessionBeanRemote"); //NOI18N
+
+                       // Defaul template is guest
+                       this.baseTemplatePathName = GUEST_BASE_TEMPLATE_NAME;
+               } catch (final NamingException ex) {
+                       // Continue to throw
+                       throw new FaceletException(ex);
+               }
+       }
+
+       @Override
+       public boolean isInvisible () {
+               // Check on login
+               if (!this.isUserLoggedIn()) {
+                       // Not logged in!
+                       throw new IllegalStateException("isInvisible() has been invoked for a guest."); //NOI18N
+               }
+
+               // Check logged-in first, then invisibility
+               return Objects.equals(this.getLoggedInUser().getUserProfileMode(), ProfileMode.INVISIBLE);
+       }
+
+       @Override
+       public boolean isPasswordInHistory (final String userPassword) {
+               // Default is not found
+               boolean isPasswordInHistory = false;
+
+               // Init variables
+               int count = 1;
+               int maxEntries = this.getIntegerContextParameter("max_user_password_history"); //NOI18N
+
+               // Check all passwords
+               for (final PasswordHistory entry : this.getUserPasswordHistory()) {
+                       // Is password the same?
+                       if (UserUtils.ifPasswordMatches(userPassword, entry.getUserPasswordHistoryUser())) {
+                               // Yes, found it
+                               isPasswordInHistory = true;
+                               break;
+                       } else if (count == maxEntries) {
+                               // Maximum reached
+                               break;
+                       }
+
+                       // Count up
+                       count++;
+               }
+
+               // Return status
+               return isPasswordInHistory;
+       }
+
+       @Override
+       public boolean isUserLoggedIn () {
+               // Compare instance
+               this.userLoggedIn = ((this.getLoggedInUser() instanceof User) && (Objects.equals(this.getLoggedInUser().getUserAccountStatus(), UserAccountStatus.CONFIRMED)));
+
+               // Return it
+               return this.userLoggedIn;
+       }
+
+       /**
+        * Clears this bean
+        */
+       private void clear () {
+               // Clear all fields
+               this.setUserCurrentPassword(null);
+       }
+
+       /**
+        * Updates password history by adding given entry to it as long as it is not
+        * there.
+        * <p>
+        * @param passwordHistory Password history entry
+        */
+       private void updatePasswordHistory (final PasswordHistory passwordHistory) {
+               if (null == passwordHistory) {
+                       // Throw NPE
+                       throw new NullPointerException("passwordHistory is null"); //NOI18N
+               } else if (passwordHistory.getUserPasswordHistoryId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("passwordHistory.userPasswordHistoryId is null"); //NOI18N
+               } else if (passwordHistory.getUserPasswordHistoryId() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("passwordHistory.userPasswordHistoryId={0} is not valid.", passwordHistory.getUserPasswordHistoryId())); //NOI18N
+               }
+
+               // Is it there?
+               if (this.userPasswordHistory.contains(passwordHistory)) {
+                       // Excact copy found
+                       return;
+               }
+
+               // Check all entries
+               for (final PasswordHistory entry : this.userPasswordHistory) {
+                       // Is same id number?
+                       if (Objects.equals(entry.getUserPasswordHistoryId(), passwordHistory.getUserPasswordHistoryId())) {
+                               // Found it
+                               return;
+                       }
+               }
+
+               // Not found, so add it
+               this.userPasswordHistory.add(passwordHistory);
+       }
+
+}
diff --git a/src/java/org/mxchange/addressbook/beans/login/user/AddressbookUserLoginWebSessionController.java b/src/java/org/mxchange/addressbook/beans/login/user/AddressbookUserLoginWebSessionController.java
new file mode 100644 (file)
index 0000000..25f80a7
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.beans.login.user;
+
+import java.io.Serializable;
+import java.util.List;
+import javax.ejb.Local;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
+
+/**
+ * An interface for registration web controllers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Local
+public interface AddressbookUserLoginWebSessionController extends Serializable {
+
+       /**
+        * Checks whether given clear-text password is in user's password history.
+        * <p>
+        * @param userPassword Clear-text password
+        * <p>
+        * @return Whether clear-text password is in user's password history
+        */
+       boolean isPasswordInHistory (final String userPassword);
+
+       /**
+        * Getter for base template type
+        * <p>
+        * @return Template type
+        */
+       String getBaseTemplatePathName ();
+
+       /**
+        * Setter for base template type
+        * <p>
+        * @param baseTemplatePathName Template type
+        */
+       void setBaseTemplatePathName (final String baseTemplatePathName);
+
+       /**
+        * Logout for administrator area. If a logged-in user instance exists, it is
+        * being logged-out, too.
+        * <p>
+        * @return Outcome (should be redirected)
+        */
+       String doAdminLogout ();
+
+       /**
+        * Logins the user, if the account is found, confirmed and unlocked.
+        * <p>
+        * @return Redirect target
+        */
+       String doUserLogin ();
+
+       /**
+        * Logout for current user by invalidating the current session.
+        * <p>
+        * @return Outcome (should be redirected)
+        */
+       String doUserLogout ();
+
+       /**
+        * Getter for logged-in user instance
+        * <p>
+        * @return Logged-in user instance
+        */
+       User getLoggedInUser ();
+
+       /**
+        * Setter for logged-in user instance
+        * <p>
+        * @param loggedInUser Logged-in user instance
+        */
+       void setLoggedInUser (final User loggedInUser);
+
+       /**
+        * Checks whether the user is logged-in
+        * <p>
+        * @return Whether the user is logged-in
+        */
+       boolean isUserLoggedIn ();
+
+       /**
+        * Checks whether the user needs to change password
+        * <p>
+        * @return Whether the user needs to change password
+        */
+       boolean ifUserMustChangePassword ();
+
+       /**
+        * Whether the currently logged-in user is invisible
+        * <p>
+        * @return Whether the currently logged-in user is invisible
+        */
+       boolean isInvisible ();
+
+       /**
+        * Setter for current password (clear text)
+        * <p>
+        * @param userCurrentPassword Current password
+        */
+       void setUserCurrentPassword (final String userCurrentPassword);
+
+       /**
+        * Getter for current password (clear text)
+        * <p>
+        * @return Current password
+        */
+       String getUserCurrentPassword ();
+
+       /**
+        * Checks whether the (previously entered) current password matches with
+        * from the user instance.
+        * <p>
+        * @return If current password matches
+        */
+       boolean ifCurrentPasswordMatches ();
+
+       /**
+        * Getter for user's password history
+        * <p>
+        * @return User's password history
+        */
+       List<PasswordHistory> getUserPasswordHistory ();
+
+}
index 3cdee2aab3a854738193aca843a866e0410c02ad..02b7be90ea7b5b27260442fdf70efc4ed89c43ff 100644 (file)
@@ -94,6 +94,8 @@ public class AddressbookAdminMobileProviderWebRequestBean extends BaseAddressboo
         * Default constructor
         */
        public AddressbookAdminMobileProviderWebRequestBean () {
+               // Call super constructor
+               super();
        }
 
        @Override
index 2b2f8b54321dcfdc78a043c3377402d49db1c992..14947e55ee16696af2f72df3c88b35206e073eb6 100644 (file)
@@ -59,6 +59,8 @@ public class AddressbookMobileProviderWebRequestBean extends BaseAddressbookCont
         * Default constructor
         */
        public AddressbookMobileProviderWebRequestBean () {
+               // Call super constructor
+               super();
        }
 
        /**
index ee93f4880a648a02505eb8bc970522d0a9713a86..59d7da763d6016a70b4900ee3ce3bdea6dd0bde8 100644 (file)
@@ -196,6 +196,9 @@ public class AddressbookAdminPhoneWebRequestBean extends BaseAddressbookControll
         * Default constructor
         */
        public AddressbookAdminPhoneWebRequestBean () {
+               // Call super constructor
+               super();
+
                // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[3].getClassName(), Thread.currentThread().getStackTrace()[3].getMethodName());
                // System.out.println(MessageFormat.format("{0}: Constructed, caller: {1}", this.getClass().getSimpleName(), caller));
        }
index 080d5be81d7bb877c7f1adbe4ba5f3efd1209fe0..f205319b502484d871c6914de63fd3a58d3a4854 100644 (file)
@@ -85,17 +85,8 @@ public class AddressbookPhoneWebApplicationBean extends BaseAddressbookControlle
         * Default constructor
         */
        public AddressbookPhoneWebApplicationBean () {
-               // Try it
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup the beans
-                       this.phoneBean = (PhoneSessionBeanRemote) context.lookup("java:global/addressbook-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N
-               } catch (final NamingException e) {
-                       // Throw it again
-                       throw new FaceletException(e);
-               }
+               // Call super constructor
+               super();
 
                // Init all lists
                this.mobileNumbers = new LinkedList<>();
@@ -450,6 +441,18 @@ public class AddressbookPhoneWebApplicationBean extends BaseAddressbookControlle
         */
        @PostConstruct
        public void init () {
+               // Try it
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup the beans
+                       this.phoneBean = (PhoneSessionBeanRemote) context.lookup("java:global/addressbook-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N
+               } catch (final NamingException e) {
+                       // Throw it again
+                       throw new FaceletException(e);
+               }
+
                // All phone numbers
                this.allMobileNumbers().addAll(this.phoneBean.allMobileNumbers());
                this.allFaxNumbers().addAll(this.phoneBean.allFaxNumbers());
index 1aae30fc7c9cad02a300d1c43ba35ac64f7215db..494f73cf9970847197d2a096350a8f2609199d84 100644 (file)
@@ -23,7 +23,7 @@ import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
 import javax.inject.Named;
 import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
+import org.mxchange.addressbook.beans.login.user.AddressbookUserLoginWebSessionController;
 import org.mxchange.addressbook.beans.user.AddressbookUserWebSessionController;
 import org.mxchange.jusercore.exceptions.UserNotFoundException;
 import org.mxchange.jusercore.model.user.User;
@@ -59,6 +59,8 @@ public class AddressbookUserProfileWebRequestBean extends BaseAddressbookControl
         * Default constructor
         */
        public AddressbookUserProfileWebRequestBean () {
+               // Call super constructor
+               super();
        }
 
        /**
index b0ee1649c24e7646bfbee062118b349cd75a89c1..01ab494bc6ce2748ff1be000eebe55f77b2c3f7f 100644 (file)
@@ -40,6 +40,8 @@ public class AddressbookProfileModeWebApplicationBean extends BaseAddressbookCon
         * Default constructor
         */
        public AddressbookProfileModeWebApplicationBean () {
+               // Call super constructor
+               super();
        }
 
        @Override
index 5a273fee8c0f079bc1562ac41c142e62cee2cc76..adc73ed1f1037e597019a50f986c702bee40c2f8 100644 (file)
@@ -83,22 +83,24 @@ public class AddressbookUserRegisterWebSessionBean extends BaseAddressbookContro
        private UserRegistrationSessionBeanRemote registerBean;
 
        /**
-        * An en event fireable when a new user has registered
+        * User controller
         */
        @Inject
-       @Any
-       private Event<ObservableUserRegisteredEvent> registeredEvent;
+       private AddressbookUserWebSessionController userController;
 
        /**
-        * User controller
+        * An en event fireable when a new user has registered
         */
        @Inject
-       private AddressbookUserWebSessionController userController;
+       @Any
+       private Event<ObservableUserRegisteredEvent> userRegisteredEvent;
 
        /**
         * Default constructor
         */
        public AddressbookUserRegisterWebSessionBean () {
+               // Call super constructor
+               super();
        }
 
        @Override
@@ -165,7 +167,7 @@ public class AddressbookUserRegisterWebSessionBean extends BaseAddressbookContro
                        assert (registeredUser.getUserId() instanceof Long) : "registeredUser.userId is null after registerUser() was called."; //NOI18N
 
                        // Fire event
-                       this.registeredEvent.fire(new UserRegisteredEvent(registeredUser));
+                       this.userRegisteredEvent.fire(new UserRegisteredEvent(registeredUser));
 
                        // All fine, redirect to proper page
                        return "register_done"; //NOI18N
index bf1cfe4aaef364b2bb0031a0d7feafef156a503b..ea1837bc88615b497b14c94616c37d8b1577d570 100644 (file)
@@ -54,17 +54,17 @@ public class AddressbookResendLinkWebSessionBean extends BaseAddressbookControll
         */
        private String emailAddress;
 
-       /**
-        * EJB for resending confirmation link
-        */
-       private ResendLinkSessionBeanRemote resendLinkBean;
-
        /**
         * Localization controller
         */
        @Inject
        private AddressbookLocalizationSessionController localizationController;
 
+       /**
+        * EJB for resending confirmation link
+        */
+       private ResendLinkSessionBeanRemote resendLinkBean;
+
        /**
         * Regular user controller
         */
@@ -75,6 +75,8 @@ public class AddressbookResendLinkWebSessionBean extends BaseAddressbookControll
         * Default constructor
         */
        public AddressbookResendLinkWebSessionBean () {
+               // Call super constructor
+               super();
        }
 
        @Override
index ea23f50edb602058601c7f673a92b1dba8e9bf0c..eb1210a6e9accc72b0f796a9796958f05a63ed69 100644 (file)
@@ -32,7 +32,7 @@ import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
+import org.mxchange.addressbook.beans.login.user.AddressbookUserLoginWebSessionController;
 import org.mxchange.addressbook.model.shared.SharedAddressbooksSessionBeanRemote;
 import org.mxchange.jaddressbookcore.events.sharing.StartedAddressbookSharingEvent;
 import org.mxchange.jaddressbookcore.events.sharing.type.SharingType;
index 9b4fe504971ccd1e5295ff0b90fbc43a432c3756..e6f1aeb2cabe2321defe112e279cead5e3046f91 100644 (file)
@@ -197,6 +197,8 @@ public class AddressbookAdminUserWebRequestBean extends BaseAddressbookControlle
         * Default constructor
         */
        public AddressbookAdminUserWebRequestBean () {
+               // Call super constructor
+               super();
        }
 
        @Override
index 9768f597c06f3f8881dcddc36fac9b3d0a66eddb..338ae7f0e6d78e753aec493cc511ead04cfd7658 100644 (file)
@@ -35,7 +35,7 @@ import javax.naming.NamingException;
 import org.mxchange.addressbook.beans.BaseAddressbookController;
 import org.mxchange.addressbook.beans.contact.AddressbookContactWebSessionController;
 import org.mxchange.addressbook.beans.features.AddressbookFeaturesWebApplicationController;
-import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
+import org.mxchange.addressbook.beans.login.user.AddressbookUserLoginWebSessionController;
 import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jusercore.events.confirmation.ObservableUserConfirmedAccountEvent;
 import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent;
@@ -149,6 +149,8 @@ public class AddressbookUserWebSessionBean extends BaseAddressbookController imp
         * Default constructor
         */
        public AddressbookUserWebSessionBean () {
+               // Call super constructor
+               super();
        }
 
        /**
index 63e0de0f566245cc242cf8e4487e70e41c576a71..e9b013b668a4f91b4418e68f95fbc5569cef8276 100644 (file)
@@ -29,7 +29,7 @@ import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.addressbook.beans.BaseAddressbookController;
 import org.mxchange.addressbook.beans.features.AddressbookFeaturesWebApplicationController;
-import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
+import org.mxchange.addressbook.beans.login.user.AddressbookUserLoginWebSessionController;
 import org.mxchange.jcoreee.utils.FacesUtils;
 import org.mxchange.jusercore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
 import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
@@ -99,6 +99,8 @@ public class AddressbookUserPasswordWebRequestBean extends BaseAddressbookContro
         * Default constructor
         */
        public AddressbookUserPasswordWebRequestBean () {
+               // Call super constructor
+               super();
        }
 
        @Override