From 27965aa47f0980111f0d05bbd939ba87f6fd6af8 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Fri, 28 Sep 2012 13:18:09 +0000 Subject: [PATCH] Merged BRANCHES/DEV/V4.1-BUG-FIX to HEAD 41929: ALF-12202: Solr Port display wrong labels on Edit form - Added solr.help.field.solr.port and solr.help.field.solr.port.ssl messages 41940: Fix for ALF-16086 SOLR tracking does not include transformation status etc (error in header name) 41958: Merged V4.1 to V4.1-BUG-FIX (RECORD ONLY) 39973: Merged BRANCHES/DEV/V4.1-BUG-FIX to BRANCHES/V4.1: merged for KR => ALF-13404 (and CLOUD-438) 39953: Refactored "Content I'm Editing" dashlet from synchronous (slowing down user dashboard initial display) to asynchronous client-side rendering. 39976: Merged BRANCHES/DEV/V4.1-BUG-FIX to BRANCHES/DEV/V3.4-BUG-FIX: (record-only) - for KR (to ignore the hand merge of the dashlet changes from V3.4) 39953: Refactored "Content I'm Editing" dashlet from synchronous (slowing down user dashboard initial display) to asynchronous client-side rendering. (ALF-13404) 41129: ALF-15782: Merged V4.1-BUG-FIX to V4.1 41032: Fix for ALF-15753 Infinite loop during Solr ACL indexing when ACL Changeset batch is empty 41986: Merged PATCHES/V4.1.1 to V4.1-BUG-FIX 41983: Merged V4.1 to PATCHES/V4.1.1 41982: Merged DEV to V4.1 41962: ALF-16029: TransactionCleanupTest throws constraint violations Use overrided deleteNodesByCommitTime() method in DAO for MSSQL. 41977: ALF-16029: TransactionCleanupTest throws constraint violations. Change delete_NodePropsByTxnCommitTime statement to be common for all DB dialects. 41985: Merged V4.1 to PATCHES/V4.1.1 (RECORD ONLY) 41129: ALF-15782: Merged V4.1-BUG-FIX to V4.1 41032: Fix for ALF-15753 Infinite loop during Solr ACL indexing when ACL Changeset batch is empty 41654: Fix for ALF-15965 - hand merged back from rev 41653 41968: Merged PATCHES/V4.1.1 to V4.1 (4.1.1) 42045: Refactor of recent change to always release opLock on close. Code needs to move out of the transactional layers to LegacyFileStateDriver. 42052: Fix for ALF-952 Merged BRANCHES/DEV to BRANCHES/DEV/V4.1-BUG-FIX 41829: akovalchuk ALF-952: Message "Password must be between 3 and 256 characters in length" incorrect Configuration of max password length is now being picked up from ClientConfig (which reads it from password-max-length element of web-client-config.xml) and validated on backend using LoginBean.validatePassword method. Maximum password length is set to 255. Field "confirm" is checked only for exact matching to the field "password" at validation phase using LoginBean.validateMatch. Tenant username check now is made at validation phase together with other username validations in CreateUserWizard.validateUsername. 42056: Merged HEAD to V4.1-BUG-FIX (RECORD ONLY) ALF-15987: merged Visio support in HEAD to V4.1-BUG-FIX. 42111: SPANISH: Translation updates based on EN r41902, Fixes: ALF-15359, ALF-15682, ALF-15926 42112: ITALIAN: Translation updates based on EN r41902, Fixes: ALF-15359, ALF-15682, ALF-15926 42113: JAPANESE: Translation updates based on EN r41902, Fixes: ALF-15359, ALF-15682, ALF-15926 42115: ALL LANGUAGES: Standardises on 24 hour display for all non-English languages. Fixes: ALF-15992 and related to ALF-13712 42129: ALF-16098: Activiti upgrade to 5.10 (RECORD ONLY) 42136: Last SOLR side update for ALF-14861 SOLR to scale for non-admin users in 100k sites and a subgroup of each of 1000 independent groupings with 1000 subgroups 42137: ALF-16132 - Problems with Versionable onUpdate Policy execution and JLan exception handling fixed third sub issue. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@42145 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/web-client-config.xml | 3 ++ .../java/org/alfresco/web/bean/LoginBean.java | 30 ++++++++++++- .../web/bean/users/CreateUserWizard.java | 45 ++++++++----------- .../web/config/ClientConfigElement.java | 22 +++++++++ .../web/config/ClientElementReader.java | 8 ++++ source/web/jsp/users/change-my-password.jsp | 8 ++-- source/web/jsp/users/change-password.jsp | 8 ++-- .../new-user-wizard/new-user-properties.jsp | 8 ++-- 8 files changed, 94 insertions(+), 38 deletions(-) diff --git a/config/alfresco/web-client-config.xml b/config/alfresco/web-client-config.xml index 6f53b610e8..b61dffde17 100644 --- a/config/alfresco/web-client-config.xml +++ b/config/alfresco/web-client-config.xml @@ -93,6 +93,9 @@ 2 3 + + 255 + 3 diff --git a/source/java/org/alfresco/web/bean/LoginBean.java b/source/java/org/alfresco/web/bean/LoginBean.java index df6f87d207..08dc752dd1 100644 --- a/source/java/org/alfresco/web/bean/LoginBean.java +++ b/source/java/org/alfresco/web/bean/LoginBean.java @@ -27,6 +27,7 @@ import java.util.Map; import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; +import javax.faces.component.UIInput; import javax.faces.context.FacesContext; import javax.faces.validator.ValidatorException; @@ -44,6 +45,7 @@ import org.alfresco.web.app.servlet.AuthenticationHelper; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.User; import org.alfresco.web.bean.users.UserPreferencesBean; +import org.alfresco.web.bean.users.UsersDialog; import org.alfresco.web.ui.common.PanelGenerator; import org.alfresco.web.ui.common.Utils; import org.apache.commons.logging.Log; @@ -262,6 +264,29 @@ public class LoginBean implements Serializable // ------------------------------------------------------------------------------ // Validator methods + /** + * Validate that field "confirm" matches to the field "password" + */ + public void validateMatch(FacesContext context, UIComponent component, Object value) + throws ValidatorException + { + String confirm = (String)value; + + String field1Id = (String) component.getAttributes().get("passwd1Id"); + UIInput passComponent = (UIInput) context.getViewRoot().findComponent(field1Id); + String pass = (String) passComponent.getSubmittedValue(); + if (pass == null) + { + pass = (String) passComponent.getValue(); + } + + if (!pass.equals(confirm)) + { + String err = Application.getMessage(context, UsersDialog.ERROR_PASSWORD_MATCH); + throw new ValidatorException(new FacesMessage(err)); + } + } + /** * Validate password field data is acceptable */ @@ -269,12 +294,13 @@ public class LoginBean implements Serializable throws ValidatorException { int minPasswordLength = Application.getClientConfig(context).getMinPasswordLength(); + int maxPasswordLength = Application.getClientConfig(context).getMaxPasswordLength(); String pass = (String)value; - if (pass.length() < minPasswordLength || pass.length() > 256) + if (pass.length() < minPasswordLength || pass.length() > maxPasswordLength) { String err = MessageFormat.format(Application.getMessage(context, MSG_PASSWORD_LENGTH), - new Object[]{minPasswordLength, 256}); + new Object[]{minPasswordLength, maxPasswordLength}); throw new ValidatorException(new FacesMessage(err)); } } diff --git a/source/java/org/alfresco/web/bean/users/CreateUserWizard.java b/source/java/org/alfresco/web/bean/users/CreateUserWizard.java index cfd30ad20c..60d92370d5 100644 --- a/source/java/org/alfresco/web/bean/users/CreateUserWizard.java +++ b/source/java/org/alfresco/web/bean/users/CreateUserWizard.java @@ -270,31 +270,6 @@ public class CreateUserWizard extends BaseWizardBean this.sizeQuotaUnits = ""; } - @Override - public String next() - { - String stepName = Application.getWizardManager().getCurrentStepName(); - - if ("summary".equals(stepName)) - { - FacesContext context = FacesContext.getCurrentInstance(); - - if (! this.password.equals(this.confirm)) - { - Utils.addErrorMessage(Application.getMessage(context, UsersDialog.ERROR_PASSWORD_MATCH)); - } - - checkTenantUserName(); - - if (context.getMessages().hasNext()) - { - Application.getWizardManager().getState().setCurrentStep(Application.getWizardManager().getCurrentStep() - 1); - } - } - - return super.next(); - } - /** * @return Returns the summary data for the wizard. */ @@ -594,16 +569,19 @@ public class CreateUserWizard extends BaseWizardBean /** * Validate password field data is acceptable + * + * @deprecated Method is never used */ public void validatePassword(FacesContext context, UIComponent component, Object value) throws ValidatorException { int minPasswordLength = Application.getClientConfig(context).getMinPasswordLength(); + int maxPasswordLength = Application.getClientConfig(context).getMaxPasswordLength(); String pass = (String)value; - if (pass.length() < minPasswordLength || pass.length() > 256) + if (pass.length() < minPasswordLength || pass.length() > maxPasswordLength) { String err = MessageFormat.format(Application.getMessage(context, LoginBean.MSG_PASSWORD_LENGTH), - new Object[]{minPasswordLength, 256}); + new Object[]{minPasswordLength, maxPasswordLength}); throw new ValidatorException(new FacesMessage(err)); } } @@ -628,6 +606,19 @@ public class CreateUserWizard extends BaseWizardBean new Object[]{"\", \\"}); throw new ValidatorException(new FacesMessage(err)); } + + try + { + name = PersonServiceImpl.updateUsernameForTenancy( + name, getTenantService() + ); + } + catch(TenantDomainMismatchException e) + { + String err = MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), + ERROR_DOMAIN_MISMATCH), e.getTenantA(), e.getTenantB()); + throw new ValidatorException(new FacesMessage(err)); + } } // ------------------------------------------------------------------------------ diff --git a/source/java/org/alfresco/web/config/ClientConfigElement.java b/source/java/org/alfresco/web/config/ClientConfigElement.java index 08e54bc60e..0ede9af8b8 100644 --- a/source/java/org/alfresco/web/config/ClientConfigElement.java +++ b/source/java/org/alfresco/web/config/ClientConfigElement.java @@ -75,6 +75,7 @@ public class ClientConfigElement extends ConfigElementAdapter private List simpleSearchAdditionalAttributes = null; private int minUsernameLength = 2; private int minPasswordLength = 3; + private int maxPasswordLength = 255; private int minGroupNameLength = 3; private String breadcrumbMode = BREADCRUMB_PATH; private String cifsURLSuffix = null; @@ -280,6 +281,11 @@ public class ClientConfigElement extends ConfigElementAdapter combinedElement.setMinPasswordLength(newElement.getMinPasswordLength()); } + if (newElement.getMaxPasswordLength() != combinedElement.getMaxPasswordLength()) + { + combinedElement.setMaxPasswordLength(newElement.getMaxPasswordLength()); + } + if (newElement.getMinGroupNameLength() != combinedElement.getMinGroupNameLength()) { combinedElement.setMinGroupNameLength(newElement.getMinGroupNameLength()); @@ -769,6 +775,22 @@ public class ClientConfigElement extends ConfigElementAdapter this.minPasswordLength = minPasswordLength; } + /** + * @return Returns the maximum length for a password. + */ + public int getMaxPasswordLength() + { + return this.maxPasswordLength; + } + + /** + * @param maxPasswordLength The maximum length of a password + */ + public void setMaxPasswordLength(int maxPasswordLength) + { + this.maxPasswordLength = maxPasswordLength; + } + /** * @return Returns the minimum length for a group name. */ diff --git a/source/java/org/alfresco/web/config/ClientElementReader.java b/source/java/org/alfresco/web/config/ClientElementReader.java index a1962dfc93..36743b668c 100644 --- a/source/java/org/alfresco/web/config/ClientElementReader.java +++ b/source/java/org/alfresco/web/config/ClientElementReader.java @@ -59,6 +59,7 @@ public class ClientElementReader implements ConfigElementReader public static final String ELEMENT_SIMPLESEARCHADDITIONALATTRSQNAME = "qname"; public static final String ELEMENT_MINUSERNAMELENGTH = "username-min-length"; public static final String ELEMENT_MINPASSWORDLENGTH = "password-min-length"; + public static final String ELEMENT_MAXPASSWORDLENGTH = "password-max-length"; public static final String ELEMENT_MINGROUPNAMELENGTH = "group-name-min-length"; public static final String ELEMENT_BREADCRUMB_MODE = "breadcrumb-mode"; public static final String ELEMENT_CIFSURLSUFFIX = "cifs-url-suffix"; @@ -268,6 +269,13 @@ public class ClientElementReader implements ConfigElementReader configElement.setMinPasswordLength(Integer.parseInt(minPassword.getTextTrim())); } + // get the maximum length of passwords + Element maxPassword = element.element(ELEMENT_MAXPASSWORDLENGTH); + if (maxPassword != null) + { + configElement.setMaxPasswordLength(Integer.parseInt(maxPassword.getTextTrim())); + } + // get the minimum length of group names Element minGroupName = element.element(ELEMENT_MINGROUPNAMELENGTH); if (minGroupName != null) diff --git a/source/web/jsp/users/change-my-password.jsp b/source/web/jsp/users/change-my-password.jsp index 33bffad8f3..4a0f2b41f6 100644 --- a/source/web/jsp/users/change-my-password.jsp +++ b/source/web/jsp/users/change-my-password.jsp @@ -79,15 +79,17 @@ :  *   :  * + size="35" validator="#{LoginBean.validateMatch}" + onkeyup="updateButtonState();" onchange="updateButtonState();"> + +  *   diff --git a/source/web/jsp/users/change-password.jsp b/source/web/jsp/users/change-password.jsp index f6f84d806e..299a1b5234 100644 --- a/source/web/jsp/users/change-password.jsp +++ b/source/web/jsp/users/change-password.jsp @@ -63,7 +63,7 @@  *   @@ -72,8 +72,10 @@  * + size="35" validator="#{LoginBean.validateMatch}" + onkeyup="updateButtonState();" onchange="updateButtonState();" > + +  *   diff --git a/source/web/jsp/users/new-user-wizard/new-user-properties.jsp b/source/web/jsp/users/new-user-wizard/new-user-properties.jsp index e472593c7a..4718714f75 100644 --- a/source/web/jsp/users/new-user-wizard/new-user-properties.jsp +++ b/source/web/jsp/users/new-user-wizard/new-user-properties.jsp @@ -98,17 +98,19 @@ function validate() - + - + - + + +