IDEMPIERE-221 Implement password policies / make password policy system wide configurable instead of tenant

This commit is contained in:
Carlos Ruiz 2012-09-06 15:20:49 -05:00
parent 4c951dd67d
commit 9735670208
4 changed files with 29 additions and 5 deletions

View File

@ -0,0 +1,8 @@
-- Sep 5, 2012 5:06:57 PM COT
-- IDEMPIERE-221 Implement password policies
UPDATE AD_Field SET DisplayLogic='@AD_Client_ID@=0',Updated=TO_DATE('2012-09-05 17:06:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200096
;
SELECT register_migration_script('904_IDEMPIERE-221.sql') FROM dual
;

View File

@ -0,0 +1,8 @@
-- Sep 5, 2012 5:06:57 PM COT
-- IDEMPIERE-221 Implement password policies
UPDATE AD_Field SET DisplayLogic='@AD_Client_ID@=0',Updated=TO_TIMESTAMP('2012-09-05 17:06:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200096
;
SELECT register_migration_script('904_IDEMPIERE-221.sql') FROM dual
;

View File

@ -63,7 +63,7 @@ public class MPasswordRule extends X_AD_PasswordRule {
/** /**
* *
*/ */
private static final long serialVersionUID = -3557291675139843726L; private static final long serialVersionUID = -4262842010340413022L;
/** /**
* @param ctx * @param ctx
@ -83,6 +83,16 @@ public class MPasswordRule extends X_AD_PasswordRule {
super(ctx, rs, trxName); super(ctx, rs, trxName);
} }
public static MPasswordRule getRules(Properties ctx, String trxName) {
MClient system = MClient.get(ctx, 0);
int pwdruleID = system.getAD_PasswordRule_ID();
MPasswordRule pass = null;
if (pwdruleID > 0)
pass = new MPasswordRule(ctx, pwdruleID, trxName);
return pass;
}
public void validate(String username, String newPassword) throws AdempiereException { public void validate(String username, String newPassword) throws AdempiereException {
ArrayList<Rule> ruleList = new ArrayList<Rule>(); ArrayList<Rule> ruleList = new ArrayList<Rule>();

View File

@ -927,12 +927,10 @@ public class MUser extends X_AD_User
if (get_ValueOld("Salt") == null && get_Value("Salt") != null) { // being hashed if (get_ValueOld("Salt") == null && get_Value("Salt") != null) { // being hashed
; ;
} else { } else {
int pwdruleid = MClient.get(getCtx(), getAD_Client_ID()).getAD_PasswordRule_ID(); MPasswordRule pwdrule = MPasswordRule.getRules(getCtx(), get_TrxName());
if (pwdruleid > 0) { if (pwdrule != null)
MPasswordRule pwdrule = new MPasswordRule(getCtx(), MClient.get(getCtx()).getAD_PasswordRule_ID(), get_TrxName());
pwdrule.validate((getLDAPUser() != null ? getLDAPUser() : getName()), getPassword()); pwdrule.validate((getLDAPUser() != null ? getLDAPUser() : getName()), getPassword());
} }
}
// Hash password - IDEMPIERE-347 // Hash password - IDEMPIERE-347
boolean hash_password = MSysConfig.getBooleanValue(MSysConfig.USER_PASSWORD_HASH, false); boolean hash_password = MSysConfig.getBooleanValue(MSysConfig.USER_PASSWORD_HASH, false);