From: Roland Häder Date: Wed, 3 Aug 2016 09:03:18 +0000 (+0200) Subject: Continued a bit: (please cherry-pick) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8e92787a43d2feca60559d174804e9d491aab03e;p=jfinancials-war.git Continued a bit: (please cherry-pick) - added retrival of user's password history for current user (not admin) - added getter in interface Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java index 224255aa..a9012f25 100644 --- a/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java @@ -17,6 +17,8 @@ package org.mxchange.addressbook.beans.login; import java.text.MessageFormat; +import java.util.Collections; +import java.util.List; import java.util.Objects; import javax.enterprise.context.SessionScoped; import javax.enterprise.event.Event; @@ -43,6 +45,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; @@ -87,7 +91,7 @@ public class AddressbookUserLoginWebSessionBean extends BaseAddressbookControlle private User loggedInUser; /** - * Remote register session bean + * EJB for user-login */ private UserLoginSessionBeanRemote loginBean; @@ -123,6 +127,16 @@ public class AddressbookUserLoginWebSessionBean extends BaseAddressbookControlle @Any private Event userLogoutEvent; + /** + * User's password history + */ + private List userPasswordHistory; + + /** + * EJB for user's password history + */ + private UserPasswordHistorySessionBeanRemote userPasswordHistoryBean; + /** * Default constructor */ @@ -134,6 +148,9 @@ public class AddressbookUserLoginWebSessionBean extends BaseAddressbookControlle // Try to lookup this.loginBean = (UserLoginSessionBeanRemote) context.lookup("java:global/addressbook-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) { @@ -175,6 +192,9 @@ public class AddressbookUserLoginWebSessionBean extends BaseAddressbookControlle // 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 @@ -255,6 +275,11 @@ public class AddressbookUserLoginWebSessionBean extends BaseAddressbookControlle this.loggedInUser = loggedInUser; } + @Override + public List getUserPasswordHistory () { + return Collections.unmodifiableList(this.userPasswordHistory); + } + @Override public boolean ifCurrentPasswordMatches () { // The current password must be set and not empty diff --git a/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionController.java b/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionController.java index 826c6a21..ff4b487a 100644 --- a/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionController.java +++ b/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionController.java @@ -17,13 +17,17 @@ 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 *

* @author Roland Haeder */ +@Local public interface AddressbookUserLoginWebSessionController extends Serializable { /** @@ -112,11 +116,18 @@ public interface AddressbookUserLoginWebSessionController 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. *

* @return If current password matches */ boolean ifCurrentPasswordMatches (); + /** + * Getter for user's password history + *

+ * @return User's password history + */ + List getUserPasswordHistory (); + }