<copyfiles files="${file.reference.jcontacts-core.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.jcore.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.jcore-logger-lib.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+ <copyfiles files="${file.reference.jcoreee.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.jcountry-core.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.jcountry-lib.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.jphone-core.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.jcontacts-core.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
<copyfiles files="${file.reference.jcore.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
<copyfiles files="${file.reference.jcore-logger-lib.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+ <copyfiles files="${file.reference.jcoreee.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
<copyfiles files="${file.reference.jcountry-core.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
<copyfiles files="${file.reference.jcountry-lib.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
<copyfiles files="${file.reference.jphone-core.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
<Scene Scope="Project" version="2">
<Scope Scope="Faces Configuration Only"/>
<Scope Scope="Project">
- <Node id="login/login_edit_address.xhtml" x="900" y="150" zoom="true"/>
- <Node id="login/login_change_password.xhtml" x="1400" y="150" zoom="true"/>
<Node id="privacy.xhtml" x="900" y="450" zoom="true"/>
+ <Node id="login/login_change_password.xhtml" x="1400" y="150" zoom="true"/>
<Node id="user/register.xhtml" x="400" y="600" zoom="true"/>
<Node id="login/login_all_applications.xhtml" x="650" y="150" zoom="true"/>
<Node id="login/login_index.xhtml" x="650" y="300" zoom="true"/>
<Node id="user/resend_link.xhtml" x="150" y="750" zoom="true"/>
<Node id="login/login_add_addressbook.xhtml" x="900" y="600" zoom="true"/>
<Node id="login/login_own_addressbooks.xhtml" x="1650" y="150" zoom="true"/>
- <Node id="terms.xhtml" x="150" y="150" zoom="true"/>
<Node id="admin/admin_logout.xhtml" x="400" y="750" zoom="true"/>
+ <Node id="terms.xhtml" x="150" y="150" zoom="true"/>
<Node id="user/user_list.xhtml" x="900" y="300" zoom="true"/>
<Node id="bye.xhtml" x="650" y="750" zoom="true"/>
<Node id="index.xhtml" x="400" y="450" zoom="true"/>
<Node id="user/register_done.xhtml" x="1400" y="300" zoom="true"/>
- <Node id="login/login_change_personal_data.xhtml" x="150" y="300" zoom="true"/>
<Node id="user/user_profile.xhtml" x="1150" y="450" zoom="true"/>
- <Node id="imprint.xhtml" x="1150" y="300" zoom="true"/>
+ <Node id="login/login_change_personal_data.xhtml" x="150" y="300" zoom="true"/>
<Node id="user/show_addressbook.xhtml" x="650" y="600" zoom="true"/>
+ <Node id="imprint.xhtml" x="1150" y="300" zoom="true"/>
<Node id="*" x="150" y="900" zoom="true"/>
<Node id="user/login_error.xhtml" x="1150" y="150" zoom="true"/>
<Node id="user/show_addressbook_entries.xhtml" x="400" y="900" zoom="true"/>
-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
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
${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}:\
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/
<file>${file.reference.jcore-logger-lib.jar}</file>
<path-in-war>WEB-INF/lib</path-in-war>
</library>
+ <library dirs="200">
+ <file>${file.reference.jcoreee.jar}</file>
+ <path-in-war>WEB-INF/lib</path-in-war>
+ </library>
<library dirs="200">
<file>${file.reference.jcountry-core.jar}</file>
<path-in-war>WEB-INF/lib</path-in-war>
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
/**
* Remote country EJB
*/
- private AddressbookCountrySingletonBeanRemote countryBean;
+ private JobsCountrySingletonBeanRemote countryBean;
/**
* List of all countries
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);
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;
}
}
+ @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;
// Trace message
// NOISY-DEBUG System.out.println(MessageFormat.format("UserLoginWebSessionBean:isUserLoggedIn: this.userLoggedIn={0} - EXIT!", this.userLoggedIn));
-
// Return it
return this.userLoggedIn;
}
* @return Current password
*/
String getCurrentPassword ();
+
+ /**
+ * Checks whether the (previously entered) current password matches with from
+ * the user instance.
+ * <p>
+ * @return If current password matches
+ */
+ boolean ifCurrentPasswordMatches ();
}
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;
*/
private static final long serialVersionUID = 542_145_347_916L;
- /////////////////////// Properties /////////////////////
/**
* Birth day
*/
}
}
+ @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
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;
* @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.
+ * <p>
+ * @throws UserPasswordMismatchException If the entered password doesn't match
+ */
+ void doChangePersonalData () throws UserPasswordMismatchException;
}
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;
/**
/**
* Country bean
*/
- private AddressbookCountrySingletonBeanRemote countryController;
+ private JobsCountrySingletonBeanRemote countryController;
/**
* Logger instance
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
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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)
+ * <p>
+ * @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
+ }
+}
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.
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.
<validator-id>UserIdValidator</validator-id>
<validator-class>org.mxchange.addressbook.validator.user.UserIdValidator</validator-class>
</validator>
+ <validator>
+ <validator-id>UserPasswordValidator</validator-id>
+ <validator-class>org.mxchange.jjobs.validators.password.UserPasswordValidator</validator-class>
+ </validator>
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<to-view-id>/user/show_addressbook_entries.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
- <navigation-rule>
- <from-view-id>/login/login_edit_user_data.xhtml</from-view-id>
- <navigation-case>
- <from-outcome>login_change_email_address</from-outcome>
- <to-view-id>/login/login_change_email_address.xhtml</to-view-id>
- </navigation-case>
- <navigation-case>
- <from-outcome>login_change_password</from-outcome>
- <to-view-id>/login/login_change_password.xhtml</to-view-id>
- </navigation-case>
- <navigation-case>
- <from-outcome>login_change_personal_data</from-outcome>
- <to-view-id>/login/login_change_personal_data.xhtml</to-view-id>
- </navigation-case>
- </navigation-rule>
+ <navigation-rule>
+ <from-view-id>/login/login_edit_user_data.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>login_change_email_address</from-outcome>
+ <to-view-id>/login/login_change_email_address.xhtml</to-view-id>
+ </navigation-case>
+ <navigation-case>
+ <from-outcome>login_change_password</from-outcome>
+ <to-view-id>/login/login_change_password.xhtml</to-view-id>
+ </navigation-case>
+ <navigation-case>
+ <from-outcome>login_change_personal_data</from-outcome>
+ <to-view-id>/login/login_change_personal_data.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
</faces-config>
</div>
<div class="table_right">
- <h:inputSecret class="input" id="currentPassword" size="10" maxlength="255" value="#{loginController.currentPassword}" required="true" />
+ <h:inputSecret class="input" id="currentPassword" size="10" maxlength="255" value="#{loginController.currentPassword}" required="true" validatorMessage="#{msg.ERROR_CURRENT_PASSWORD_MISMATCHING}">
+ <h:message for="currentPassword" />
+ <f:validator for="currentPassword" validatorId="UserPasswordValidator" />
+ </h:inputSecret>
</div>
<div class="clear"></div>
<li class="footer_link">
<h:link outcome="login_index" title="#{msg.LINK_LOGIN_HOME_TITLE}" value="#{msg.LINK_LOGIN_HOME}" />
</li>
+
<li class="footer_link">
<h:link outcome="imprint" title="#{msg.LINK_GUEST_IMPRINT_TITLE}" value="#{msg.LINK_GUEST_IMPRINT}" />
</li>
+
<li class="footer_link">
<h:link outcome="terms" title="#{msg.LINK_GUEST_TERMS_TITLE}" value="#{msg.LINK_GUEST_TERMS}" />
</li>
+
<li class="footer_link">
<h:link outcome="privacy" title="#{msg.LINK_GUEST_PRIVACY_TITLE}" value="#{msg.LINK_GUEST_PRIVACY}" />
</li>
<div class="table_footer">
<h:commandButton class="reset" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
- <h:commandButton class="submit" type="submit" id="change_personal_data" value="#{msg.BUTTON_CHANGE_PERSONAL_DATA}" action="#{userController.changePersonalData()}" />
+ <h:commandButton class="submit" type="submit" id="change_personal_data" value="#{msg.BUTTON_CHANGE_PERSONAL_DATA}" action="#{userController.doChangePersonalData()}" />
</div>
</h:form>
</div>