/*
- * Copyright (C) 2016 Roland Haeder
+ * Copyright (C) 2016, 2017 Roland Häder
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
package org.mxchange.pizzaapplication.beans.user.password;
import java.util.Objects;
+import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Any;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import org.mxchange.jcoreee.utils.FacesUtils;
+import org.mxchange.jusercore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
-import org.mxchange.jusercore.events.user.password_change.UserUpdatedPasswordEvent;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
import org.mxchange.jusercore.exceptions.UserStatusLockedException;
import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
import org.mxchange.pizzaapplication.beans.BasePizzaController;
import org.mxchange.pizzaapplication.beans.features.PizzaFeaturesWebApplicationController;
-import org.mxchange.pizzaapplication.beans.login.PizzaUserLoginWebSessionController;
+import org.mxchange.pizzaapplication.beans.login.user.PizzaUserLoginWebSessionController;
/**
* A user password (change) bean (controller)
* <p>
- * @author Roland Haeder<roland@mxchange.org>
+ * @author Roland Häder<roland@mxchange.org>
*/
@Named ("userPasswordController")
@RequestScoped
/**
* Remote user bean
*/
- private final UserSessionBeanRemote userBean;
+ private UserSessionBeanRemote userBean;
/**
* Current password (for confirmation of password change)
private PizzaUserLoginWebSessionController userLoginController;
/**
- * User password (unencrypted from web form)
+ * User password (clear-text from web form)
*/
private String userPassword;
/**
- * User password repeated (unencrypted from web form)
+ * User password repeated (clear-text from web form)
*/
private String userPasswordRepeat;
*/
@Any
@Inject
- private Event<UpdatedUserPasswordEvent> userUpdatedPasswordEvent;
+ private Event<ObservableUpdatedUserPasswordEvent> userUpdatedPasswordEvent;
/**
* Default constructor
*/
public PizzaUserPasswordWebRequestBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jlandingpage-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
+ // Call super constructor
+ super();
}
@Override
user.setUserEncryptedPassword(encryptedPassword);
try {
+ // Get base URL
+ String baseUrl = FacesUtils.generateBaseUrl();
+
// All is set, then update password
- PasswordHistory passwordHistory = this.userBean.updateUserPassword(user);
+ PasswordHistory passwordHistory = this.userBean.updateUserPassword(user, baseUrl);
// Fire event
- this.userUpdatedPasswordEvent.fire(new UserUpdatedPasswordEvent(passwordHistory));
+ this.userUpdatedPasswordEvent.fire(new UpdatedUserPasswordEvent(passwordHistory));
} catch (final UserNotFoundException | UserStatusUnconfirmedException | UserStatusLockedException ex) {
// Clear bean
this.clear();
this.userPasswordRepeat = userPasswordRepeat;
}
+ /**
+ * Post-initialization of this class
+ */
+ @PostConstruct
+ public void init () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.userBean = (UserSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+ }
+
+ @Override
public boolean isRequiredChangePasswordSet () {
// Is all data set?
return ((this.getUserCurrentPassword() != null) &&