[ChangePassword] Solved some problems importing libraries.
authorJonathan Bueno <jonathan.bueno@openbravo.com>
Wed, 25 Nov 2015 10:35:15 +0100
changeset 28639 632560abfb78
parent 28638 0d4f091d1e54
child 28640 a2f2698c2672
[ChangePassword] Solved some problems importing libraries.
src/org/openbravo/authentication/basic/DefaultAuthenticationManager.java
src/org/openbravo/base/secureApp/LoginUtils.java
--- a/src/org/openbravo/authentication/basic/DefaultAuthenticationManager.java	Mon Nov 23 18:24:08 2015 +0100
+++ b/src/org/openbravo/authentication/basic/DefaultAuthenticationManager.java	Wed Nov 25 10:35:15 2015 +0100
@@ -13,19 +13,15 @@
 package org.openbravo.authentication.basic;
 
 import java.io.IOException;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
 import org.openbravo.authentication.AuthenticationException;
-import org.openbravo.authentication.AuthenticationExpiryPasswordException;
 import org.openbravo.authentication.AuthenticationManager;
 import org.openbravo.base.HttpBaseUtils;
 import org.openbravo.base.secureApp.LoginUtils;
@@ -34,8 +30,6 @@
 import org.openbravo.erpCommon.utility.OBError;
 import org.openbravo.erpCommon.utility.Utility;
 
-import com.sun.xml.internal.ws.util.StringUtils;
-
 /**
  * 
  * @author adrianromero
@@ -100,29 +94,6 @@
       throw new AuthenticationException("IDENTIFICATION_FAILURE_TITLE", errorMsg);
     }
 
-    // Check if password valid date is reached
-    String strUPD = LoginUtils.getUpdatePasswordDate(conn, strUser, strPass);
-    Date formattedUPD = null;
-    if (!strUPD.isEmpty()) {
-      DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
-      try {
-        formattedUPD = df.parse(strUPD);
-      } catch (ParseException e) {
-        e.printStackTrace();
-      }
-      // Checks if password
-      Calendar currentDate = Calendar.getInstance();
-      Date today = new Date(currentDate.getTimeInMillis());
-      if (formattedUPD.compareTo(today) <= 0) {
-        log4j.debug("Failed user/password. Username: " + strUser + " - Session ID:" + sessionId);
-        OBError errorMsg = new OBError();
-        errorMsg.setType("Error");
-        errorMsg.setTitle("IDENTIFICATION_FAILURE_TITLE");
-        errorMsg.setMessage("IDENTIFICATION_FAILURE_MSG");
-        throw new AuthenticationExpiryPasswordException("IDENTIFICATION_FAILURE_TITLE", errorMsg);
-      }
-    }
-
     // Using the Servlet API instead of vars.setSessionValue to avoid breaking code
     // vars.setSessionValue always transform the key to upper-case
     request.getSession(true).setAttribute("#Authenticated_user", userId);
--- a/src/org/openbravo/base/secureApp/LoginUtils.java	Mon Nov 23 18:24:08 2015 +0100
+++ b/src/org/openbravo/base/secureApp/LoginUtils.java	Wed Nov 25 10:35:15 2015 +0100
@@ -21,6 +21,7 @@
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 
+import org.apache.log4j.Logger;
 import org.openbravo.base.HttpBaseUtils;
 import org.openbravo.base.exception.OBException;
 import org.openbravo.base.exception.OBSecurityException;
@@ -88,26 +89,6 @@
     }
   }
 
-  public static String getUpdatePasswordDate(ConnectionProvider connectionProvider, String login,
-      String unHashedPassword) {
-    try {
-      // Get the Update password date
-      UserLock lockSettings = new UserLock(login);
-      lockSettings.delayResponse();
-      if (lockSettings.isLockedUser()) {
-        return null;
-      }
-      final String hashedPassword = FormatUtilities.sha1Base64(unHashedPassword);
-      String valid = SeguridadData.validityDatePassword(connectionProvider, login, hashedPassword);
-      if (valid == null) {
-        log4j.error("Valid password date is reached");
-      }
-      return valid;
-    } catch (final Exception e) {
-      throw new OBException(e);
-    }
-  }
-
   /**
    * Similar to {@link LoginUtils#getValidUserId(ConnectionProvider, String, String)} but not
    * blocking user accounts.