From d28dec8f329d9c6ab63f6f5d94675952d7f2dfe5 Mon Sep 17 00:00:00 2001 From: Nicolas Micoud Date: Wed, 25 Apr 2018 13:31:59 +0200 Subject: [PATCH] IDEMPIERE-3696 Implementing warning to encourage user to change their password before it is expired --- .../oracle/201804242200_IDEMPIERE-3696.sql | 18 ++++++++++++++++++ .../postgresql/201804242200_IDEMPIERE-3696.sql | 15 +++++++++++++++ .../src/org/compiere/model/MSysConfig.java | 3 ++- .../org/adempiere/webui/panel/RolePanel.java | 15 ++++++++++++++- 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 migration/i5.1z/oracle/201804242200_IDEMPIERE-3696.sql create mode 100644 migration/i5.1z/postgresql/201804242200_IDEMPIERE-3696.sql diff --git a/migration/i5.1z/oracle/201804242200_IDEMPIERE-3696.sql b/migration/i5.1z/oracle/201804242200_IDEMPIERE-3696.sql new file mode 100644 index 0000000000..ee35cd1e07 --- /dev/null +++ b/migration/i5.1z/oracle/201804242200_IDEMPIERE-3696.sql @@ -0,0 +1,18 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-3696 Implementing warning to encourage user to change their password before it is expired +-- Apr 24, 2018 9:44:15 PM CEST +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Your password will expire in {0} days',0,0,'Y',TO_DATE('2018-04-24 21:44:15','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2018-04-24 21:44:15','YYYY-MM-DD HH24:MI:SS'),0,200453,'YourPasswordWillExpireInDays','D','85f74e09-67bf-4044-a276-a0bb07bb73f9') +; + +-- Apr 24, 2018 9:44:22 PM CEST +UPDATE AD_Message SET EntityType='D',Updated=TO_DATE('2018-04-24 21:44:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=200453 +; + +-- Apr 24, 2018 9:44:44 PM CEST +INSERT INTO AD_SysConfig (AD_SysConfig_ID,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive,Name,Value,Description,EntityType,ConfigurationLevel,AD_SysConfig_UU) VALUES (200117,0,0,TO_DATE('2018-04-24 21:44:44','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2018-04-24 21:44:44','YYYY-MM-DD HH24:MI:SS'),0,0,'Y','USER_LOCKING_PASSWORD_NOTIFY_DAY','0','Define a period (before password is expired) where a popup will appears to encourage user to change its password','D','S','92d15407-ddc2-4100-b2ae-bdccca3098d6') +; + +SELECT register_migration_script('201804242200_IDEMPIERE-3696.sql') FROM dual +; diff --git a/migration/i5.1z/postgresql/201804242200_IDEMPIERE-3696.sql b/migration/i5.1z/postgresql/201804242200_IDEMPIERE-3696.sql new file mode 100644 index 0000000000..ad545dd894 --- /dev/null +++ b/migration/i5.1z/postgresql/201804242200_IDEMPIERE-3696.sql @@ -0,0 +1,15 @@ +-- IDEMPIERE-3696 Implementing warning to encourage user to change their password before it is expired +-- Apr 24, 2018 9:44:15 PM CEST +INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','Your password will expire in {0} days',0,0,'Y',TO_TIMESTAMP('2018-04-24 21:44:15','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2018-04-24 21:44:15','YYYY-MM-DD HH24:MI:SS'),0,200453,'YourPasswordWillExpireInDays','D','85f74e09-67bf-4044-a276-a0bb07bb73f9') +; + +-- Apr 24, 2018 9:44:22 PM CEST +UPDATE AD_Message SET EntityType='D',Updated=TO_TIMESTAMP('2018-04-24 21:44:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Message_ID=200453 +; + +-- Apr 24, 2018 9:44:44 PM CEST +INSERT INTO AD_SysConfig (AD_SysConfig_ID,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive,Name,Value,Description,EntityType,ConfigurationLevel,AD_SysConfig_UU) VALUES (200117,0,0,TO_TIMESTAMP('2018-04-24 21:44:44','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2018-04-24 21:44:44','YYYY-MM-DD HH24:MI:SS'),0,0,'Y','USER_LOCKING_PASSWORD_NOTIFY_DAY','0','Define a period (before password is expired) where a popup will appears to encourage user to change its password','D','S','92d15407-ddc2-4100-b2ae-bdccca3098d6') +; + +SELECT register_migration_script('201804242200_IDEMPIERE-3696.sql') FROM dual +; diff --git a/org.adempiere.base/src/org/compiere/model/MSysConfig.java b/org.adempiere.base/src/org/compiere/model/MSysConfig.java index 0a6d0b84fb..0a65e68d88 100644 --- a/org.adempiere.base/src/org/compiere/model/MSysConfig.java +++ b/org.adempiere.base/src/org/compiere/model/MSysConfig.java @@ -42,7 +42,7 @@ public class MSysConfig extends X_AD_SysConfig /** * */ - private static final long serialVersionUID = -2698648078997788547L; + private static final long serialVersionUID = 5886520708050807357L; public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION"; public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS"; @@ -149,6 +149,7 @@ public class MSysConfig extends X_AD_SysConfig public static final String USER_LOCKING_MAX_INACTIVE_PERIOD_DAY = "USER_LOCKING_MAX_INACTIVE_PERIOD_DAY"; public static final String USER_LOCKING_MAX_LOGIN_ATTEMPT = "USER_LOCKING_MAX_LOGIN_ATTEMPT"; public static final String USER_LOCKING_MAX_PASSWORD_AGE_DAY = "USER_LOCKING_MAX_PASSWORD_AGE_DAY"; + public static final String USER_LOCKING_PASSWORD_NOTIFY_DAY = "USER_LOCKING_PASSWORD_NOTIFY_DAY"; public static final String USER_PASSWORD_HASH = "USER_PASSWORD_HASH"; public static final String VALIDATE_MATCHING_TO_ORDERED_QTY = "VALIDATE_MATCHING_TO_ORDERED_QTY"; public static final String WEBUI_LOGOURL = "WEBUI_LOGOURL"; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java index 656c3b3a9a..3976655912 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java @@ -52,6 +52,7 @@ import org.compiere.util.KeyNamePair; import org.compiere.util.Language; import org.compiere.util.Login; import org.compiere.util.Msg; +import org.compiere.util.TimeUtil; import org.compiere.util.Util; import org.zkoss.zhtml.Table; import org.zkoss.zhtml.Td; @@ -84,7 +85,7 @@ public class RolePanel extends Window implements EventListener, Deferrabl /** * */ - private static final long serialVersionUID = 4068073033610726196L; + private static final long serialVersionUID = 372661654078492488L; protected LoginWindow wndLogin; protected Login login; @@ -643,6 +644,18 @@ public class RolePanel extends Window implements EventListener, Deferrabl return; } + // See if a popup should encourage user to change its password + int notifyDay = MSysConfig.getIntValue(MSysConfig.USER_LOCKING_PASSWORD_NOTIFY_DAY, 0); + int pwdAgeDay = MSysConfig.getIntValue(MSysConfig.USER_LOCKING_MAX_PASSWORD_AGE_DAY, 0); + if (notifyDay > 0 && pwdAgeDay > 0) { + Timestamp limit = TimeUtil.addDays(MUser.get(Env.getCtx(), Env.getAD_User_ID(Env.getCtx())).getDatePasswordChanged(), pwdAgeDay); + Timestamp notifyAfter = TimeUtil.addDays(limit, -notifyDay); + Timestamp now = TimeUtil.getDay(null); + + if (now.after(notifyAfter)) + FDialog.warn(0, null, "", Msg.getMsg(Env.getCtx(), "YourPasswordWillExpireInDays", new Object[] {TimeUtil.getDaysBetween(now, limit)})); + } + wndLogin.loginCompleted(); // Elaine 2009/02/06 save preference to AD_Preference