From bd51dfdf4e9b8ccf7301f26a33ebde37e697d0f3 Mon Sep 17 00:00:00 2001 From: hieplq Date: Mon, 6 Apr 2015 10:27:21 +0700 Subject: [PATCH] IDEMPIERE-2558:don't allow use old password when change password update library to passay --- .../oracle/201504061604-IDEMPIERE-2558.sql | 10 +++ .../201504061604-IDEMPIERE-2558.sql | 7 ++ org.adempiere.base/.classpath | 3 +- org.adempiere.base/META-INF/MANIFEST.MF | 5 +- org.adempiere.base/build.properties | 5 +- .../src/org/compiere/model/MPasswordRule.java | 64 +++++++++---------- .../org/compiere/model/X_AD_PasswordRule.java | 14 ++-- 7 files changed, 62 insertions(+), 46 deletions(-) create mode 100644 migration/i2.1z/oracle/201504061604-IDEMPIERE-2558.sql create mode 100644 migration/i2.1z/postgresql/201504061604-IDEMPIERE-2558.sql diff --git a/migration/i2.1z/oracle/201504061604-IDEMPIERE-2558.sql b/migration/i2.1z/oracle/201504061604-IDEMPIERE-2558.sql new file mode 100644 index 0000000000..8da011e7ff --- /dev/null +++ b/migration/i2.1z/oracle/201504061604-IDEMPIERE-2558.sql @@ -0,0 +1,10 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator +-- Apr 6, 2015 1:54:49 AM ICT +UPDATE AD_Field SET IsActive='N',Updated=TO_DATE('2015-04-06 01:54:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200080 +; +SELECT register_migration_script('201504061604-IDEMPIERE-2558.sql') FROM dual +; + diff --git a/migration/i2.1z/postgresql/201504061604-IDEMPIERE-2558.sql b/migration/i2.1z/postgresql/201504061604-IDEMPIERE-2558.sql new file mode 100644 index 0000000000..944c5e088d --- /dev/null +++ b/migration/i2.1z/postgresql/201504061604-IDEMPIERE-2558.sql @@ -0,0 +1,7 @@ +-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator +-- Apr 6, 2015 1:54:49 AM ICT +UPDATE AD_Field SET IsActive='N',Updated=TO_TIMESTAMP('2015-04-06 01:54:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200080 +; +SELECT register_migration_script('201504061604-IDEMPIERE-2558.sql') FROM dual +; + diff --git a/org.adempiere.base/.classpath b/org.adempiere.base/.classpath index bf57879ec2..dca11cb25b 100644 --- a/org.adempiere.base/.classpath +++ b/org.adempiere.base/.classpath @@ -1,5 +1,6 @@ + @@ -14,8 +15,6 @@ - - diff --git a/org.adempiere.base/META-INF/MANIFEST.MF b/org.adempiere.base/META-INF/MANIFEST.MF index a95d39d4cf..b1f842b5d2 100644 --- a/org.adempiere.base/META-INF/MANIFEST.MF +++ b/org.adempiere.base/META-INF/MANIFEST.MF @@ -16,11 +16,10 @@ Bundle-ClassPath: base.jar, jfreechart-1.0.19.jar, jnlp.jar, groovy-all-1.7.5.jar, - vt-dictionary-3.0.jar, - vt-password-3.1.2.jar, super-csv-2.2.0.jar, barcode4j-2.1.jar, - bcprov-jdk15on-1.46.jar + bcprov-jdk15on-1.46.jar, + passay-1.0.jar Export-Package: bsh, bsh.classpath, bsh.collection, diff --git a/org.adempiere.base/build.properties b/org.adempiere.base/build.properties index 4dfc9b2351..8ad0b737b9 100644 --- a/org.adempiere.base/build.properties +++ b/org.adempiere.base/build.properties @@ -14,8 +14,6 @@ bin.includes = META-INF/,\ jnlp.jar,\ OSGI-INF/,\ groovy-all-1.7.5.jar,\ - vt-dictionary-3.0.jar,\ - vt-password-3.1.2.jar,\ super-csv-2.2.0.jar,\ OSGI-INF/dslocator.xml,\ OSGI-INF/serverbean.xml,\ @@ -35,7 +33,8 @@ bin.includes = META-INF/,\ OSGI-INF/addressvalidationeventhandler.xml,\ schema/,\ barcode4j-2.1.jar,\ - bcprov-jdk15on-1.46.jar + bcprov-jdk15on-1.46.jar,\ + passay-1.0.jar output.base.jar = bin/ src.includes = schema/ source.base.jar = src/ diff --git a/org.adempiere.base/src/org/compiere/model/MPasswordRule.java b/org.adempiere.base/src/org/compiere/model/MPasswordRule.java index d7d9713cde..756b839b3a 100644 --- a/org.adempiere.base/src/org/compiere/model/MPasswordRule.java +++ b/org.adempiere.base/src/org/compiere/model/MPasswordRule.java @@ -30,32 +30,32 @@ import org.adempiere.exceptions.AdempiereException; import org.compiere.util.Env; import org.compiere.util.Msg; import org.compiere.util.Util; +import org.passay.AlphabeticalCharacterRule; +import org.passay.AlphabeticalSequenceRule; +import org.passay.CharacterCharacteristicsRule; +import org.passay.DictionarySubstringRule; +import org.passay.DigitCharacterRule; +import org.passay.LengthRule; +import org.passay.LowercaseCharacterRule; +import org.passay.MessageResolver; +import org.passay.NumericalSequenceRule; +import org.passay.PasswordData; +import org.passay.PasswordGenerator; +import org.passay.PasswordValidator; +import org.passay.PropertiesMessageResolver; +import org.passay.QwertySequenceRule; +import org.passay.RepeatCharacterRegexRule; +import org.passay.Rule; +import org.passay.RuleResult; +import org.passay.SpecialCharacterRule; +import org.passay.UppercaseCharacterRule; +import org.passay.UsernameRule; +import org.passay.WhitespaceRule; +import org.passay.dictionary.ArrayWordList; +import org.passay.dictionary.WordListDictionary; +import org.passay.dictionary.WordLists; +import org.passay.dictionary.sort.ArraysSort; -import edu.vt.middleware.dictionary.ArrayWordList; -import edu.vt.middleware.dictionary.WordListDictionary; -import edu.vt.middleware.dictionary.WordLists; -import edu.vt.middleware.dictionary.sort.ArraysSort; -import edu.vt.middleware.password.AlphabeticalCharacterRule; -import edu.vt.middleware.password.AlphabeticalSequenceRule; -import edu.vt.middleware.password.CharacterCharacteristicsRule; -import edu.vt.middleware.password.DictionarySubstringRule; -import edu.vt.middleware.password.DigitCharacterRule; -import edu.vt.middleware.password.LengthRule; -import edu.vt.middleware.password.LowercaseCharacterRule; -import edu.vt.middleware.password.MessageResolver; -import edu.vt.middleware.password.NonAlphanumericCharacterRule; -import edu.vt.middleware.password.NumericalSequenceRule; -import edu.vt.middleware.password.Password; -import edu.vt.middleware.password.PasswordData; -import edu.vt.middleware.password.PasswordGenerator; -import edu.vt.middleware.password.PasswordValidator; -import edu.vt.middleware.password.QwertySequenceRule; -import edu.vt.middleware.password.RepeatCharacterRegexRule; -import edu.vt.middleware.password.Rule; -import edu.vt.middleware.password.RuleResult; -import edu.vt.middleware.password.UppercaseCharacterRule; -import edu.vt.middleware.password.UsernameRule; -import edu.vt.middleware.password.WhitespaceRule; /** * @author juliana @@ -144,7 +144,7 @@ public class MPasswordRule extends X_AD_PasswordRule { if (getNonAlphaNumericCharacter() > 0) { // require at least n non-alphanumeric char numValidations++; - charRule.getRules().add(new NonAlphanumericCharacterRule(getNonAlphaNumericCharacter())); + charRule.getRules().add(new SpecialCharacterRule(getNonAlphaNumericCharacter())); } if (getUppercaseCharacter() > 0) { numValidations++; @@ -193,11 +193,11 @@ public class MPasswordRule extends X_AD_PasswordRule { WordListDictionary dict = new WordListDictionary(awl); DictionarySubstringRule dictRule = new DictionarySubstringRule(dict); - if (getDictWordLength() > 0) { + /*if (getDictWordLength() > 0) {//when update library to passay. this method is miss dictRule.setWordLength(getDictWordLength()); // size of words to check in the password } else{ dictRule.setWordLength(DictionarySubstringRule.DEFAULT_WORD_LENGTH); - } + }*/ if (isDictMatchBackwards()) { dictRule.setMatchBackwards(true); // match dictionary words backwards @@ -215,7 +215,7 @@ public class MPasswordRule extends X_AD_PasswordRule { if (!ruleList.isEmpty()) { PasswordValidator validator = new PasswordValidator(getCustomResolver(), ruleList); - PasswordData passwordData = new PasswordData(new Password(newPassword)); + PasswordData passwordData = new PasswordData(newPassword); passwordData.setUsername(username); RuleResult result = validator.validate(passwordData); if (!result.isValid()) { @@ -253,9 +253,9 @@ public class MPasswordRule extends X_AD_PasswordRule { } } if (props == null) - return new MessageResolver(); + return new PropertiesMessageResolver(); else - return new MessageResolver(props); + return new PropertiesMessageResolver(props); } public String generate() { @@ -269,7 +269,7 @@ public class MPasswordRule extends X_AD_PasswordRule { if (getNonAlphaNumericCharacter() > 0) { // require at least n non-alphanumeric char numValidations++; - charRule.getRules().add(new NonAlphanumericCharacterRule(getNonAlphaNumericCharacter())); + charRule.getRules().add(new SpecialCharacterRule(getNonAlphaNumericCharacter())); } if (getUppercaseCharacter() > 0) { numValidations++; diff --git a/org.adempiere.base/src/org/compiere/model/X_AD_PasswordRule.java b/org.adempiere.base/src/org/compiere/model/X_AD_PasswordRule.java index 8673c70345..6fd6180b6e 100644 --- a/org.adempiere.base/src/org/compiere/model/X_AD_PasswordRule.java +++ b/org.adempiere.base/src/org/compiere/model/X_AD_PasswordRule.java @@ -27,12 +27,12 @@ import org.compiere.util.KeyNamePair; public class X_AD_PasswordRule extends PO implements I_AD_PasswordRule, I_Persistent { - /** - * + /** + * */ - private static final long serialVersionUID = 20141030L; + private static final long serialVersionUID = -6204385406753580912L; - /** Standard Constructor */ + /** Standard Constructor */ public X_AD_PasswordRule (Properties ctx, int AD_PasswordRule_ID, String trxName) { super (ctx, AD_PasswordRule_ID, trxName); @@ -154,14 +154,16 @@ public class X_AD_PasswordRule extends PO implements I_AD_PasswordRule, I_Persis } /** Set Word Length Dictionary. - @param DictWordLength Word Length Dictionary */ + @param DictWordLength Word Length Dictionary + @deprecated by update library */ public void setDictWordLength (int DictWordLength) { set_Value (COLUMNNAME_DictWordLength, Integer.valueOf(DictWordLength)); } /** Get Word Length Dictionary. - @return Word Length Dictionary */ + @return Word Length Dictionary + @deprecated by update library*/ public int getDictWordLength () { Integer ii = (Integer)get_Value(COLUMNNAME_DictWordLength);