import java.util.ResourceBundle;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
+import org.mxchange.jusercore.model.user.UserUtils;
/**
* A general controller
return isEnabled;
}
+ /**
+ * Checks if given password is to weak to be used
+ * <p>
+ * @param password Clear-text password
+ * <p>
+ * @return Whether the entered password is to weak
+ */
+ protected boolean isWeakPassword (final String password) {
+ // Log message
+ System.out.println(this.getClass().getSimpleName() + ":isWeakPassword: password=" + password + " - CALLED!");
+
+ // Is parameter set?
+ if (null == password) {
+ // Throw NPE
+ throw new NullPointerException("password is null"); //NOI18N
+ }
+
+ // Get score value
+ double passwordScore = UserUtils.calculatePasswordScore(password);
+
+ // Log message
+ System.out.println(this.getClass().getSimpleName() + ".isWeakPassword: passwordScore=" + passwordScore);
+
+ // Is the score within range?
+ boolean isWeak = (passwordScore <= this.getIntegerContextParameter("min_user_password_score")); //NOI18N
+
+ // Log message
+ System.out.println(this.getClass().getSimpleName() + ".isWeakPassword: isWeak=" + isWeak + " - EXIT!");
+
+ // Return it
+ return isWeak;
+ }
+
/**
* Shows a faces message for given causing exception. The message from the
* exception is being inserted into the message.
} else if ((this.beanHelper.getContact() == null) && (this.contactController.isEmailAddressRegistered(user.getUserContact()))) {
// Email address is already used
this.showFacesMessage("admin_add_user:emailAddress", "ERROR_EMAIL_ADDRESS_ALREADY_USED"); //NOI18N
+
+ // Always clear password
+ this.setUserPassword(null);
+ this.setUserPasswordRepeat(null);
+
+ // Skip it
return ""; //NOI18N
} else if ((this.getUserPassword() == null && (this.getUserPasswordRepeat() == null)) || ((this.getUserPassword().isEmpty()) && (this.getUserPasswordRepeat().isEmpty()))) {
// Empty password entered, then generate one
// No redirect
return ""; //NOI18N
+ } else if (this.isWeakPassword(this.getUserPassword())) {
+ // Password is to weak
+ this.showFacesMessage("form_user_change_password:userPassword", "ERROR_USER_PASSWORD_TO_WEAK"); //NOI18N
+
+ // Clear bean
+ this.userLoginController.setUserCurrentPassword(null);
+ this.clear();
+
+ // Skip it
+ return ""; //NOI18N
}
// Get user instance
USER_ENTER_NEW_PASSWORD_REPEAT=Wiederholen:
BUTTON_USER_CHANGE_PASSWORD=Passwort \u00e4ndern
ADMIN_LINK_SHOW_CONTACT_DATA=Kontaktdaten anzeigen
+ERROR_USER_PASSWORD_TO_WEAK=Das eingegebene Passwort ist zu schwach. Bitte geben Sie Bustaben, Zahlen und Sonderzeichen ein, um ein sicheres Passwort zu erstellen.
USER_ENTER_NEW_PASSWORD_REPEAT=Repeat:
BUTTON_USER_CHANGE_PASSWORD=Change password
ADMIN_LINK_SHOW_CONTACT_DATA=Show contact data
+ERROR_USER_PASSWORD_TO_WEAK=Your entered password is to weak. Please enter letters, numbers and special characters to create a secure password.
<param-name>is_feature_user_must_change_email_address_enabled</param-name>
<param-value>true</param-value>
</context-param>
+ <context-param>
+ <description>Minimum password score (default 50 may be to low)</description>
+ <param-name>min_user_password_score</param-name>
+ <param-value>50</param-value>
+ </context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>