From 0100b40cbbeb0d5b7581abeb9a5802434aa01add Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 5 Mar 2016 16:09:36 +0100 Subject: [PATCH] Continued with user profile data: - renamed changeFoo() to doChangeFoo() to match with naming convention - added doChangePersonalData() which throws a checked exception - that method does currently only check if the user is logged-in and if the password matches - the resulting error message would be not user-friendly, so better added a validator which outputs a new localizable message - added method ifCurrentPasswordMatches() which uses UserUtils to validate the entered password - renaming interface applied - updated juser-core.jar - added jcoreee.jar --- lib/jcoreee.jar | Bin 0 -> 18591 bytes lib/juser-core.jar | Bin 29575 -> 29575 bytes nbproject/build-impl.xml | 2 + nbproject/faces-config.NavData | 9 +-- nbproject/genfiles.properties | 6 +- nbproject/project.properties | 3 + nbproject/project.xml | 4 + .../country/CountryWebApplicationBean.java | 6 +- .../beans/login/UserLoginWebSessionBean.java | 20 ++++- .../login/UserLoginWebSessionController.java | 8 ++ .../jjobs/beans/user/UserWebSessionBean.java | 14 +++- .../beans/user/UserWebSessionController.java | 9 +++ .../converter/country/CountryConverter.java | 6 +- .../password/UserPasswordValidator.java | 72 ++++++++++++++++++ .../localization/bundle_de_DE.properties | 1 + .../localization/bundle_en_US.properties | 1 + web/WEB-INF/faces-config.xml | 34 +++++---- .../login/login_enter_current_password.tpl | 5 +- web/WEB-INF/templates/login/login_footer.tpl | 3 + web/login/login_change_personal_data.xhtml | 2 +- 20 files changed, 172 insertions(+), 33 deletions(-) create mode 100644 lib/jcoreee.jar create mode 100644 src/java/org/mxchange/jjobs/validators/password/UserPasswordValidator.java diff --git a/lib/jcoreee.jar b/lib/jcoreee.jar new file mode 100644 index 0000000000000000000000000000000000000000..8fa7868d036fb8592e8acfcd35cc661720d5984d GIT binary patch literal 18591 zcmeHPX>eQDbv_RO@qmX1l7d8uAY%!XC|O(pP_$OaS|BbqEo!ky(Wbn}Aoxf@0s$HT zCCY9bTejocsh#evnc7VyFSX-zNj>g#`osOzKb>i(Gwn2)Oghtv$K$d3 zo%`Oy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b87a226d553d9ae55630dad262db 100644 GIT binary patch delta 663 zcmZpF&e;B(kvG7bnT3mifrEiTu_kpQuLiRMkg}N1ECZx&$%Cms8X#)2I-?Poj$yO` z)3X_!!1Mz~OE4|NWDlm}nB2hhawc0a{hY}H%Ga2DL6KV;VI$B~4+bQlKlz}y>f{Oj zd^~VRfh=Cn>;f`i^Ec)fj9|t?)@(K~!=J|kA~K6tff+2aS0IR45M-{5_&<@qK(j&E z1!%6+s2Pv>WVX|sX?Fuk%M2TV&87J})X!Wc09x-c9} QyB0zCONz3=e4*k}02rXs-2eap delta 663 zcmZpF&e;B(kvG7bnT3mifrEh|D=T6muLg4_kg}N1oCKt9$%Cms8X#)2I-?Poj$yO` z)3X_!!1Mz~OE4|NWDlm}nB2hhawc0a{hY~yIT@&bIg`fZ3yR#*2pfT>dN3dX{mBQt zRVPpI=i`Ap3S{wmW*3k_o4+x?U<5NBvSzb^8U8#T5RqBD3d~@Uy#hhZf*^Bc#Q%x> z1)2@QE!+<&*-dW0{M7zjlPKt*xb$Di&()T z5rKy}z#?){b0J>Xm#~?Q85s1FOVTYsVLy3&IwTlBrt5=LPFBva0Ml_9kl z$_N6}?wOuodUB>en0}fW2Bz(@e8F^ImIpZa?XsjNf60PGp=NdzSgtKQ1Wez}P6N|! zIay$Oa}Ity;R9p%GQzzX0 diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index 1804cc32..226dc27e 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -1033,6 +1033,7 @@ exists or setup the property manually. For example like this: + @@ -1046,6 +1047,7 @@ exists or setup the property manually. For example like this: + diff --git a/nbproject/faces-config.NavData b/nbproject/faces-config.NavData index 14f40311..9a3038d3 100644 --- a/nbproject/faces-config.NavData +++ b/nbproject/faces-config.NavData @@ -2,25 +2,24 @@ - - + - + - - + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 224aeea4..5eb7f85f 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=fafbc183 +build.xml.data.CRC32=b9ff954e build.xml.script.CRC32=fae72669 build.xml.stylesheet.CRC32=651128d4@1.75.1.1 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=fafbc183 -nbproject/build-impl.xml.script.CRC32=d40bda24 +nbproject/build-impl.xml.data.CRC32=b9ff954e +nbproject/build-impl.xml.script.CRC32=fca932bd nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.75.1.1 diff --git a/nbproject/project.properties b/nbproject/project.properties index afaedba9..5179696b 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -38,6 +38,7 @@ excludes= file.reference.jcontacts-core.jar=lib/jcontacts-core.jar file.reference.jcore-logger-lib.jar=lib/jcore-logger-lib.jar file.reference.jcore.jar=lib/jcore.jar +file.reference.jcoreee.jar=lib/jcoreee.jar file.reference.jcountry-core.jar=lib/jcountry-core.jar file.reference.jcountry-lib.jar=lib/jcountry-lib.jar file.reference.jphone-core.jar=lib/jphone-core.jar @@ -60,6 +61,7 @@ javac.classpath=\ ${file.reference.jcontacts-core.jar}:\ ${file.reference.jcore.jar}:\ ${file.reference.jcore-logger-lib.jar}:\ + ${file.reference.jcoreee.jar}:\ ${file.reference.jcountry-core.jar}:\ ${file.reference.jcountry-lib.jar}:\ ${file.reference.jphone-core.jar}:\ @@ -108,6 +110,7 @@ source.encoding=UTF-8 source.reference.jcontacts-core.jar=../jcontacts-core/src/ source.reference.jcore-logger-lib.jar=../jcore-logger-lib/src/ source.reference.jcore.jar=../jcore/src/ +source.reference.jcoreee.jar=../jcoreee/src/ source.reference.jcountry-core.jar=../jcountry-core/src/ source.reference.jcountry-lib.jar=../jcountry-lib/src/ source.reference.jphone-core.jar=../jphone-core/src/ diff --git a/nbproject/project.xml b/nbproject/project.xml index f150bf9c..352befef 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -18,6 +18,10 @@ ${file.reference.jcore-logger-lib.jar} WEB-INF/lib + + ${file.reference.jcoreee.jar} + WEB-INF/lib + ${file.reference.jcountry-core.jar} WEB-INF/lib diff --git a/src/java/org/mxchange/jjobs/beans/country/CountryWebApplicationBean.java b/src/java/org/mxchange/jjobs/beans/country/CountryWebApplicationBean.java index 41d682b5..08811e2d 100644 --- a/src/java/org/mxchange/jjobs/beans/country/CountryWebApplicationBean.java +++ b/src/java/org/mxchange/jjobs/beans/country/CountryWebApplicationBean.java @@ -25,8 +25,8 @@ import javax.inject.Named; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; -import org.mxchange.jcountry.data.AddressbookCountrySingletonBeanRemote; import org.mxchange.jcountry.data.Country; +import org.mxchange.jcountry.data.JobsCountrySingletonBeanRemote; /** * A country bean @@ -45,7 +45,7 @@ public class CountryWebApplicationBean implements CountryWebApplicationControlle /** * Remote country EJB */ - private AddressbookCountrySingletonBeanRemote countryBean; + private JobsCountrySingletonBeanRemote countryBean; /** * List of all countries @@ -62,7 +62,7 @@ public class CountryWebApplicationBean implements CountryWebApplicationControlle Context context = new InitialContext(); // Try to lookup the bean - this.countryBean = (AddressbookCountrySingletonBeanRemote) context.lookup("ejb/jjobs-singleton-country"); //NOI18N + this.countryBean = (JobsCountrySingletonBeanRemote) context.lookup("ejb/jjobs-singleton-country"); //NOI18N } catch (final NamingException ex) { // Continue to throw throw new FaceletException(ex); diff --git a/src/java/org/mxchange/jjobs/beans/login/UserLoginWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/login/UserLoginWebSessionBean.java index 449e4e60..4a9c1edf 100644 --- a/src/java/org/mxchange/jjobs/beans/login/UserLoginWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/login/UserLoginWebSessionBean.java @@ -37,6 +37,7 @@ 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.profilemodes.ProfileMode; import org.mxchange.jusercore.model.user.status.UserAccountStatus; @@ -138,6 +139,24 @@ public class UserLoginWebSessionBean implements UserLoginWebSessionController { } } + @Override + public boolean ifCurrentPasswordMatches () { + // The current password must be set and not empty + if (this.getCurrentPassword() == null) { + // Is not set + throw new NullPointerException("this.currentPassword is null"); //NOI18N + } else if (this.getCurrentPassword().isEmpty()) { + // Is set empty + throw new IllegalStateException("this.currentPassword is empty."); //NOI18N + } + + // Create "container" + LoginContainer container = new UserLoginContainer(this.getLoggedInUser(), this.getCurrentPassword()); + + // Now check if it matches + return UserUtils.ifPasswordMatches(container, this.getLoggedInUser()); + } + @Override public String getCurrentPassword () { return currentPassword; @@ -195,7 +214,6 @@ public class UserLoginWebSessionBean implements UserLoginWebSessionController { // Trace message // NOISY-DEBUG System.out.println(MessageFormat.format("UserLoginWebSessionBean:isUserLoggedIn: this.userLoggedIn={0} - EXIT!", this.userLoggedIn)); - // Return it return this.userLoggedIn; } diff --git a/src/java/org/mxchange/jjobs/beans/login/UserLoginWebSessionController.java b/src/java/org/mxchange/jjobs/beans/login/UserLoginWebSessionController.java index b1454d39..4cf2358a 100644 --- a/src/java/org/mxchange/jjobs/beans/login/UserLoginWebSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/login/UserLoginWebSessionController.java @@ -95,4 +95,12 @@ public interface UserLoginWebSessionController extends Serializable { * @return Current password */ String getCurrentPassword (); + + /** + * Checks whether the (previously entered) current password matches with from + * the user instance. + *

+ * @return If current password matches + */ + boolean ifCurrentPasswordMatches (); } diff --git a/src/java/org/mxchange/jjobs/beans/user/UserWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/user/UserWebSessionBean.java index bb122ea7..61363cfd 100644 --- a/src/java/org/mxchange/jjobs/beans/user/UserWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/UserWebSessionBean.java @@ -47,6 +47,7 @@ import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider; import org.mxchange.jusercore.events.login.UserLoggedInEvent; import org.mxchange.jusercore.events.registration.UserRegisteredEvent; import org.mxchange.jusercore.exceptions.UserNotFoundException; +import org.mxchange.jusercore.exceptions.UserPasswordMismatchException; import org.mxchange.jusercore.model.user.LoginUser; import org.mxchange.jusercore.model.user.User; import org.mxchange.jusercore.model.user.UserSessionBeanRemote; @@ -66,7 +67,6 @@ public class UserWebSessionBean implements UserWebSessionController { */ private static final long serialVersionUID = 542_145_347_916L; - /////////////////////// Properties ///////////////////// /** * Birth day */ @@ -238,6 +238,18 @@ public class UserWebSessionBean implements UserWebSessionController { } } + @Override + public void doChangePersonalData () throws UserPasswordMismatchException { + // This method shall only be called if the user is logged-in + if (!this.loginController.isUserLoggedIn()) { + // Not logged-in + throw new IllegalStateException("User is not logged-in"); //NOI18N + } else if (!this.loginController.ifCurrentPasswordMatches()) { + // Password not matching + throw new UserPasswordMismatchException(this.loginController.getLoggedInUser()); + } + } + @Override public void afterRegistrationEvent (final @Observes UserRegisteredEvent event) { // Trace message diff --git a/src/java/org/mxchange/jjobs/beans/user/UserWebSessionController.java b/src/java/org/mxchange/jjobs/beans/user/UserWebSessionController.java index 9917eab5..cbb933fd 100644 --- a/src/java/org/mxchange/jjobs/beans/user/UserWebSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/user/UserWebSessionController.java @@ -25,6 +25,7 @@ import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider; import org.mxchange.jusercore.events.login.UserLoggedInEvent; import org.mxchange.jusercore.events.registration.UserRegisteredEvent; import org.mxchange.jusercore.exceptions.UserNotFoundException; +import org.mxchange.jusercore.exceptions.UserPasswordMismatchException; import org.mxchange.jusercore.model.user.User; import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; @@ -478,4 +479,12 @@ public interface UserWebSessionController extends Serializable { * @return Whether the user id is empty */ boolean isUserIdEmpty (); + + /** + * Changes logged-in user's personal data if the current password matches + * and TAC + privacy statement has been accepted. + *

+ * @throws UserPasswordMismatchException If the entered password doesn't match + */ + void doChangePersonalData () throws UserPasswordMismatchException; } diff --git a/src/java/org/mxchange/jjobs/converter/country/CountryConverter.java b/src/java/org/mxchange/jjobs/converter/country/CountryConverter.java index 12f96e1b..f27b5c83 100644 --- a/src/java/org/mxchange/jjobs/converter/country/CountryConverter.java +++ b/src/java/org/mxchange/jjobs/converter/country/CountryConverter.java @@ -28,7 +28,7 @@ import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcoreeelogger.beans.local.logger.Log; import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal; -import org.mxchange.jcountry.data.AddressbookCountrySingletonBeanRemote; +import org.mxchange.jcountry.data.JobsCountrySingletonBeanRemote; import org.mxchange.jcountry.data.Country; /** @@ -42,7 +42,7 @@ public class CountryConverter implements Converter { /** * Country bean */ - private AddressbookCountrySingletonBeanRemote countryController; + private JobsCountrySingletonBeanRemote countryController; /** * Logger instance @@ -63,7 +63,7 @@ public class CountryConverter implements Converter { this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N // ... and country controller - this.countryController = (AddressbookCountrySingletonBeanRemote) context.lookup("java:global/jjobs-ejb/country!org.mxchange.jcountry.data.AddressbookCountrySingletonBeanRemote"); //NOI18N + this.countryController = (JobsCountrySingletonBeanRemote) context.lookup("java:global/jjobs-ejb/country!org.mxchange.jcountry.data.JobsCountrySingletonBeanRemote"); //NOI18N } catch (final NamingException ex) { // Continue to throw it throw new RuntimeException("context.lookup() failed.", ex); //NOI18N diff --git a/src/java/org/mxchange/jjobs/validators/password/UserPasswordValidator.java b/src/java/org/mxchange/jjobs/validators/password/UserPasswordValidator.java new file mode 100644 index 00000000..e1d90441 --- /dev/null +++ b/src/java/org/mxchange/jjobs/validators/password/UserPasswordValidator.java @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2016 quix0r + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jjobs.validators.password; + +import javax.faces.application.FacesMessage; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.validator.Validator; +import javax.faces.validator.ValidatorException; +import javax.inject.Inject; +import org.mxchange.jcoreee.validator.string.BaseStringValidator; +import org.mxchange.jjobs.beans.login.UserLoginWebSessionController; +import org.mxchange.jusercore.container.login.LoginContainer; +import org.mxchange.jusercore.container.login.UserLoginContainer; +import org.mxchange.jusercore.model.user.UserUtils; + +/** + * A validator for validating passwords (if they match with stored) + *

+ * @author Roland Haeder + */ +public class UserPasswordValidator extends BaseStringValidator implements Validator { + + /** + * Serial number + */ + private static final long serialVersionUID = 48_581_795_687_317L; + + /** + * User login controller + */ + @Inject + private UserLoginWebSessionController loginController; + + @Override + public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { + // Trace message + //this.getLogger().logTrace(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N + + // The required field + String[] requiredFileds = {"currentPassword"}; //NOI18N + + // Pre-validation (example: not null, not a string, empty string ...) + super.preValidate(context, component, value, requiredFileds, false); + + // value is known to be an entered password, so instance login container + LoginContainer container = new UserLoginContainer(this.loginController.getLoggedInUser(), (String) value); + + // Test it here + if (!UserUtils.ifPasswordMatches(container, this.loginController.getLoggedInUser())) { + // Password mismatches + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Password mismatching.", "The password the user has entered does not match the stored password.")); //NOI18N + } + + // Trace message + //this.getLogger().logTrace("validate: EXIT!"); //NOI18N + } +} diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 473217eb..9c3dca0a 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -256,3 +256,4 @@ LOGIN_ENTER_CURRENT_PASSWORD_CONFIRM=Derzeitiges Passwort: BUTTON_CHANGE_PERSONAL_DATA=Persoenliche Daten aendern #TODO: Please fix German umlaut! LOGIN_CHANGE_PERSONAL_DATA_TITLE=Persoenliche Daten aendern: +ERROR_CURRENT_PASSWORD_MISMATCHING=Ihr eingegebenes Passwort entspricht nicht dem aktuell gespeicherten Passwort. diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index 032df0c2..a348ece0 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -240,3 +240,4 @@ LOGIN_ENTER_CURRENT_PASSWORD_CONFIRMATION_LEGEND_TITLE=Please enter your current LOGIN_ENTER_CURRENT_PASSWORD_CONFIRM=Current password: BUTTON_CHANGE_PERSONAL_DATA=Change personal data LOGIN_CHANGE_PERSONAL_DATA_TITLE=Change personal data: +ERROR_CURRENT_PASSWORD_MISMATCHING=Your entered password doesn't match the currently stored one. diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index 83579c01..25547658 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -37,6 +37,10 @@ UserIdValidator org.mxchange.addressbook.validator.user.UserIdValidator + + UserPasswordValidator + org.mxchange.jjobs.validators.password.UserPasswordValidator + * @@ -140,19 +144,19 @@ /user/show_addressbook_entries.xhtml - - /login/login_edit_user_data.xhtml - - login_change_email_address - /login/login_change_email_address.xhtml - - - login_change_password - /login/login_change_password.xhtml - - - login_change_personal_data - /login/login_change_personal_data.xhtml - - + + /login/login_edit_user_data.xhtml + + login_change_email_address + /login/login_change_email_address.xhtml + + + login_change_password + /login/login_change_password.xhtml + + + login_change_personal_data + /login/login_change_personal_data.xhtml + + diff --git a/web/WEB-INF/templates/login/login_enter_current_password.tpl b/web/WEB-INF/templates/login/login_enter_current_password.tpl index b218c729..517870e1 100644 --- a/web/WEB-INF/templates/login/login_enter_current_password.tpl +++ b/web/WEB-INF/templates/login/login_enter_current_password.tpl @@ -14,7 +14,10 @@

- + + + +
diff --git a/web/WEB-INF/templates/login/login_footer.tpl b/web/WEB-INF/templates/login/login_footer.tpl index ffe77f49..a951a4dc 100644 --- a/web/WEB-INF/templates/login/login_footer.tpl +++ b/web/WEB-INF/templates/login/login_footer.tpl @@ -9,12 +9,15 @@ + + + diff --git a/web/login/login_change_personal_data.xhtml b/web/login/login_change_personal_data.xhtml index e1711f0d..b441a304 100644 --- a/web/login/login_change_personal_data.xhtml +++ b/web/login/login_change_personal_data.xhtml @@ -29,7 +29,7 @@ -- 2.39.5