]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Continued a bit: (please cherry-pick)
authorRoland Häder <roland@mxchange.org>
Wed, 3 Aug 2016 09:03:18 +0000 (11:03 +0200)
committerRoland Haeder <roland@mxchange.org>
Sat, 6 Aug 2016 19:51:24 +0000 (21:51 +0200)
- added retrival of user's password history for current user (not admin)
- added getter in interface

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionBean.java
src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionController.java

index d7f75db77851ac318adc0e03ec44ae185ca5c672..fccf1755a989218a18ba646615a490b78295113c 100644 (file)
@@ -16,6 +16,8 @@
  */
 package org.mxchange.pizzaapplication.beans.login;
 
+import java.util.Collections;
+import java.util.List;
 import java.util.Objects;
 import javax.enterprise.context.SessionScoped;
 import javax.enterprise.event.Event;
@@ -40,6 +42,8 @@ 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;
 import org.mxchange.pizzaapplication.beans.BasePizzaController;
@@ -86,7 +90,7 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements
        private User loggedInUser;
 
        /**
-        * Remote register session bean
+        * EJB for user-login
         */
        private UserLoginSessionBeanRemote loginBean;
 
@@ -122,6 +126,16 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements
        @Any
        private Event<ObserveableUserLogoutEvent> userLogoutEvent;
 
+       /**
+        * User's password history
+        */
+       private List<PasswordHistory> userPasswordHistory;
+
+       /**
+        * EJB for user's password history
+        */
+       private UserPasswordHistorySessionBeanRemote userPasswordHistoryBean;
+
        /**
         * Default constructor
         */
@@ -133,6 +147,9 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements
                        // Try to lookup
                        this.loginBean = (UserLoginSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/login!org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote"); //NOI18N
 
+                       // Also find this
+                       this.userPasswordHistoryBean = (UserPasswordHistorySessionBeanRemote) context.lookup(""); //NOI18N
+
                        // Defaul template is guest
                        this.baseTemplatePathName = GUEST_BASE_TEMPLATE_NAME;
                } catch (final NamingException ex) {
@@ -174,6 +191,9 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements
                        // 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
 
@@ -196,11 +216,6 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements
                }
        }
 
-       @Override
-       public void setBaseTemplatePathName (final String baseTemplatePathName) {
-               this.baseTemplatePathName = baseTemplatePathName;
-       }
-
        @Override
        public String doUserLogout () {
                // Fire event
@@ -216,6 +231,16 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements
                return "index?faces-redirect=true"; //NOI18N
        }
 
+       @Override
+       public String getBaseTemplatePathName () {
+               return this.baseTemplatePathName;
+       }
+
+       @Override
+       public void setBaseTemplatePathName (final String baseTemplatePathName) {
+               this.baseTemplatePathName = baseTemplatePathName;
+       }
+
        @Override
        public String getCurrentPassword () {
                return this.currentPassword;
@@ -237,8 +262,8 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements
        }
 
        @Override
-       public String getBaseTemplatePathName () {
-               return this.baseTemplatePathName;
+       public List<PasswordHistory> getUserPasswordHistory () {
+               return Collections.unmodifiableList(this.userPasswordHistory);
        }
 
        @Override
index 71af8157bb099598c5baaa09e19a1eadce0196d8..b4fd092bc4e151152e1bdb54bdc88d5e0bd41294 100644 (file)
 package org.mxchange.pizzaapplication.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 Haeder<roland@mxchange.org>
  */
+@Local
 public interface PizzaUserLoginWebSessionController extends Serializable {
 
        /**
@@ -112,11 +116,18 @@ public interface PizzaUserLoginWebSessionController extends Serializable {
        String getCurrentPassword ();
 
        /**
-        * Checks whether the (previously entered) current password matches with from
-        * the user instance.
+        * 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 ();
+
 }