From 4dbdd08d2b4c118e76153bea6a1b8321fa18d524 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 5 Mar 2016 16:34:15 +0100 Subject: [PATCH] Continued with updating personal data: - added user password validator (from jjobs-war) - added missing message strings - added check if all required fields are set - added preparing user instance and sending it to the EJB - doChangeFoo() all need to return a string for next target page (not added yet) - updated jar(s) --- lib/juser-core.jar | Bin 29575 -> 29575 bytes lib/juser-lib.jar | Bin 4024 -> 4112 bytes nbproject/faces-config.NavData | 5 +- .../password/UserPasswordValidator.java | 72 ++++++++++++++++++ .../localization/bundle_de_DE.properties | 1 + .../localization/bundle_en_US.properties | 1 + web/WEB-INF/faces-config.xml | 4 + .../login/login_enter_current_password.tpl | 5 +- web/login/login_change_personal_data.xhtml | 2 +- 9 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 src/java/org/mxchange/addressbook/validators/password/UserPasswordValidator.java diff --git a/lib/juser-core.jar b/lib/juser-core.jar index 40c22b79f6b40e7f73ff091d16431972e436bbce..dab758462c35b87a226d553d9ae55630dad262db 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/lib/juser-lib.jar b/lib/juser-lib.jar index 35588bb0d8abbf068242701f1cb361706e19cff3..035059115efb07232f8a6f59afc1ea2b3c2c3bb4 100644 GIT binary patch delta 634 zcmdlXKS6;vz?+$ci-CcIfx)>sbt10@uTyiXhvU4pZ3PSr3%q9)5R8iDCxMhh_A$7lzp&oerLX<;T?5WP8= ziI*A7NM>bc76giToPHXuRKN_h5QuFjD>A80UcjNkCBx1j$<83f&LF+{9LHHkak0{Z zl*E$M(BjmhfYhSme4t}o5=#;%2XN^!hE1Nyb%v31avFDnE(;@rFoOut{Y(s^U{Z`h z97wYVw$G=o$W?)d9+`!?>CB@Dl&dwmg&LFw@I>%YY$*;LiF>*}a#+{(bz{DU7bPf}P z2!kk)W@BJv5My8n@MdHZVTL&#;Ui1gdL{-25O#)ZVqjR(=mydBj?YLQ6!zY; v{Tk;36@joXio&qT_WUslDDeY~BU=%ta86#!AwKyRzX01EZjcH9xPo=x diff --git a/nbproject/faces-config.NavData b/nbproject/faces-config.NavData index 077c7ff6..882010c1 100644 --- a/nbproject/faces-config.NavData +++ b/nbproject/faces-config.NavData @@ -17,7 +17,6 @@ - @@ -26,17 +25,17 @@ - + + - diff --git a/src/java/org/mxchange/addressbook/validators/password/UserPasswordValidator.java b/src/java/org/mxchange/addressbook/validators/password/UserPasswordValidator.java new file mode 100644 index 00000000..fa5fce37 --- /dev/null +++ b/src/java/org/mxchange/addressbook/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.addressbook.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.addressbook.beans.login.UserLoginWebSessionController; +import org.mxchange.jcoreee.validator.string.BaseStringValidator; +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 fa62ad34..69786442 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -285,3 +285,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 59bc76f0..da62220a 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -270,3 +270,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 9bb8d1f8..d5b62294 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.addressbook.validators.password.UserPasswordValidator + * 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..26206e4c 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/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