Commit 9a927c45 authored by pkamble's avatar pkamble

Password generation related Changes

  - Get user info from ValidatorEJB
  - Remove "error throwing" from getPassWdComplexity() method

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@209064 ce508802-f39f-4f6c-b175-0d175dae99d5
parent b842ae75
...@@ -20,6 +20,7 @@ import ibase.utility.CommonConstants; ...@@ -20,6 +20,7 @@ import ibase.utility.CommonConstants;
//import ibase.webitm.utility.GenericUtility; //import ibase.webitm.utility.GenericUtility;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.utility.EMail; import ibase.utility.EMail;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
...@@ -218,25 +219,30 @@ public class SysGenPassword extends ValidatorEJB implements SysGenPasswordLocal ...@@ -218,25 +219,30 @@ public class SysGenPassword extends ValidatorEJB implements SysGenPasswordLocal
{ {
refId = "newrefno"; refId = "newrefno";
} }
PassWordGenerator passWordGenerator = new PassWordGenerator();
// Added by Pravin K on 07-OCT-19 [to check passWdComplexity ] START // Added by Pravin K on 07-OCT-19 [to check passWdComplexity ] START
String enterprise = getValueFromXTRA_PARAMS(xtraParams, "enterprise");// UserInfoBean userInfoBean = getUserInfo();
String transDB = getValueFromXTRA_PARAMS(xtraParams, "transDB"); String enterprise = userInfoBean.getEnterprise();
//String passWdComplexity = getDBColumnValue("ENTERPRISE", "PASSWORD_COMPLEXITY", "WHERE ENTERPRISE = '"+enterprise+"'", transDB); String transDB = userInfoBean.getTransDB();
System.out.printf("SysGenPassword :: executepreSaveForm() : enterprise: [%s], transDB: [%s]\n", enterprise, transDB);
String passWdComplexity = getPassWdComplexity(enterprise, transDB); String passWdComplexity = getPassWdComplexity(enterprise, transDB);
System.out.println("SysGenPassword::executepreSaveForm::passWdComplexity =["+passWdComplexity+"]"); System.out.printf("SysGenPassword :: executepreSaveForm : passWdComplexity: [%s]\n", passWdComplexity);
if("1".equals(passWdComplexity))
PassWordGenerator passWordGenerator = null;
if ("1".equals(passWdComplexity))
{ {
genPassWord = ""+(new Random().nextInt(9000)+1000); genPassWord = String.valueOf((new Random().nextInt(9000) + 1000));
} }
else else
{ {
passWordGenerator = new PassWordGenerator();
genPassWord = passWordGenerator.password(userId); genPassWord = passWordGenerator.password(userId);
passWordGenerator = null;
} }
// Added by Pravin K on 07-OCT-19 [to check passWdComplexity ] END // Added by Pravin K on 07-OCT-19 [to check passWdComplexity ] END
passWordGenerator = null;
System.out.println("genPassWord =["+genPassWord+"]"); System.out.println("genPassWord =["+genPassWord+"]");
valueXmlString.append("<pass_wd>").append("<![CDATA[" + genPassWord + "]]>").append("</pass_wd>"); valueXmlString.append("<pass_wd>").append("<![CDATA[" + genPassWord + "]]>").append("</pass_wd>");
...@@ -423,10 +429,8 @@ public class SysGenPassword extends ValidatorEJB implements SysGenPasswordLocal ...@@ -423,10 +429,8 @@ public class SysGenPassword extends ValidatorEJB implements SysGenPasswordLocal
//End changes by Rakesh //End changes by Rakesh
// Added by Pravin K on 07-OCT-19 [to check passWdComplexity ] START // Added by Pravin K on 07-OCT-19 [to check passWdComplexity ] START
public String getPassWdComplexity( String enterprise, String transDB ) throws ITMException public String getPassWdComplexity(String enterprise, String transDB)
{ {
String sql = ""; String sql = "";
String returnValue = null; String returnValue = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
...@@ -435,66 +439,45 @@ public class SysGenPassword extends ValidatorEJB implements SysGenPasswordLocal ...@@ -435,66 +439,45 @@ public class SysGenPassword extends ValidatorEJB implements SysGenPasswordLocal
try try
{ {
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
if(transDB != null && !"null".equalsIgnoreCase(transDB.trim()) && transDB.trim().length() > 0) conn = connDriver.getConnectDB(transDB);
{
conn = connDriver.getConnectDB( transDB ); sql = "SELECT PASSWORD_COMPLEXITY FROM ENTERPRISE WHERE ENTERPRISE=?";
} pstmt = conn.prepareStatement(sql);
else pstmt.setString(1, enterprise);
{
conn = connDriver.getConnectDB( "Driver" );
}
sql = " SELECT PASSWORD_COMPLEXITY FROM ENTERPRISE WHERE ENTERPRISE = " + enterprise ;
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() )
if (rs.next())
{ {
returnValue = rs.getString( 1 ); returnValue = rs.getString("PASSWORD_COMPLEXITY");
} }
if( rs !=null )
{
rs.close();
rs = null;
} }
if( pstmt != null ) catch (Exception exp)
{ {
pstmt.close(); System.out.println("Excepton in getDBColumnValue -- >" + exp);
pstmt = null;
}
}
catch( Exception exp )
{
System.out.println("Excepton in getDBColumnValue -- >"+exp);
exp.printStackTrace(); exp.printStackTrace();
throw new ITMException(exp);
} }
finally finally
{ {
try try
{ {
if(rs!=null) if (rs!= null)
{ {
rs.close(); rs.close();
rs = null;
} }
if(pstmt != null) if (pstmt != null)
{ {
pstmt.close(); pstmt.close();
pstmt = null;
} }
if(conn !=null) if (conn != null)
{ {
conn.close(); conn.close();
conn = null;
} }
} }
catch(SQLException se) catch(SQLException se) { }
{
se.printStackTrace();
throw new ITMException(se);
}
} }
return returnValue; return returnValue;
} }
// Added by Pravin K on 07-OCT-19 [to check passWdComplexity ] END // Added by Pravin K on 07-OCT-19 [to check passWdComplexity ] END
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment