IDEMPIERE-221 Implement password policies / Thanks to Juliana Corredor

This commit is contained in:
Carlos Ruiz 2012-09-25 13:51:07 -05:00
parent d9d27e6990
commit 0347e6f4e8
1 changed files with 23 additions and 1 deletions

View File

@ -29,6 +29,7 @@ import java.util.Properties;
import org.adempiere.exceptions.AdempiereException;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
import edu.vt.middleware.dictionary.ArrayWordList;
import edu.vt.middleware.dictionary.WordListDictionary;
@ -64,7 +65,7 @@ public class MPasswordRule extends X_AD_PasswordRule {
/**
*
*/
private static final long serialVersionUID = 7376091524332484101L;
private static final long serialVersionUID = 5454698615095632059L;
/**
* @param ctx
@ -94,6 +95,27 @@ public class MPasswordRule extends X_AD_PasswordRule {
return pass;
}
@Override
protected boolean beforeSave (boolean newRecord)
{
if (isUsingDictionary()) {
StringBuilder msg = new StringBuilder();
if (Util.isEmpty(getPathDictionary())) {
msg.append(Msg.getElement(getCtx(), COLUMNNAME_PathDictionary));
}
if (getDictWordLength() <= 0) {
if (msg.length() > 0)
msg.append(", ");
msg.append(Msg.getElement(getCtx(), COLUMNNAME_DictWordLength));
}
if (msg.length() > 0) {
log.saveError("FillMandatory", msg.toString());
return false;
}
}
return true;
}
public void validate(String username, String newPassword) throws AdempiereException {
ArrayList<Rule> ruleList = new ArrayList<Rule>();