IDEMPIERE-206 Integrate fitnesse with iDempiere / Let fitnesse login fixture check the USE_EMAIL_FOR_LOGIN sysconfig parameter
- refactored unnecessary repeated .close - indent method
This commit is contained in:
parent
a6ed2846a0
commit
b26888800d
|
@ -277,9 +277,17 @@ public class Login
|
|||
KeyNamePair[] retValue = null;
|
||||
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
|
||||
|
||||
|
||||
boolean email_login = MSysConfig.getBooleanValue(MSysConfig.USE_EMAIL_FOR_LOGIN, false);
|
||||
String userNameCol;
|
||||
if (email_login)
|
||||
userNameCol = "AD_User.EMail";
|
||||
else
|
||||
userNameCol = "COALESCE(AD_User.LDAPUser,AD_User.Name)";
|
||||
|
||||
if(hash_password){
|
||||
// adaxa-pb: try to authenticate using hashed password -- falls back to plain text/encrypted
|
||||
String where = " COALESCE(LDAPUser,Name) = ? AND" +
|
||||
String where = " " + userNameCol + " = ? AND" +
|
||||
" EXISTS (SELECT * FROM AD_User_Roles ur" +
|
||||
" INNER JOIN AD_Role r ON (ur.AD_Role_ID=r.AD_Role_ID)" +
|
||||
" WHERE ur.AD_User_ID=AD_User.AD_User_ID AND ur.IsActive='Y' AND r.IsActive='Y') AND " +
|
||||
|
@ -300,15 +308,15 @@ public class Login
|
|||
}
|
||||
}
|
||||
else{
|
||||
StringBuffer sql = new StringBuffer("SELECT u.AD_User_ID,")
|
||||
.append(" u.ConnectionProfile ")
|
||||
.append(" FROM AD_User u");
|
||||
sql.append(" WHERE COALESCE(u.LDAPUser,u.Name)=?");
|
||||
sql.append(" AND u.IsActive='Y'").append(" AND EXISTS (SELECT * FROM AD_Client c WHERE u.AD_Client_ID=c.AD_Client_ID AND c.IsActive='Y')");
|
||||
StringBuffer sql = new StringBuffer("SELECT AD_User.AD_User_ID,")
|
||||
.append(" AD_User.ConnectionProfile ")
|
||||
.append(" FROM AD_User ");
|
||||
sql.append(" WHERE ").append(userNameCol).append("=?");
|
||||
sql.append(" AND AD_User.IsActive='Y'").append(" AND EXISTS (SELECT * FROM AD_Client c WHERE AD_User.AD_Client_ID=c.AD_Client_ID AND c.IsActive='Y')");
|
||||
|
||||
if (app_pwd != null)
|
||||
sql.append(" AND ((u.Password=? AND (SELECT IsEncrypted FROM AD_Column WHERE AD_Column_ID=417)='N') "
|
||||
+ "OR (u.Password=? AND (SELECT IsEncrypted FROM AD_Column WHERE AD_Column_ID=417)='Y'))"); // #2/3
|
||||
sql.append(" AND ((AD_User.Password=? AND (SELECT IsEncrypted FROM AD_Column WHERE AD_Column_ID=417)='N') "
|
||||
+ "OR (AD_User.Password=? AND (SELECT IsEncrypted FROM AD_Column WHERE AD_Column_ID=417)='Y'))"); // #2/3
|
||||
|
||||
PreparedStatement pstmt1=null;
|
||||
ResultSet rs1=null;
|
||||
|
@ -341,19 +349,19 @@ public class Login
|
|||
}
|
||||
|
||||
if(authenticated){
|
||||
StringBuffer sql = new StringBuffer("SELECT u.AD_User_ID, r.AD_Role_ID,r.Name,")
|
||||
.append(" u.ConnectionProfile ")
|
||||
.append("FROM AD_User u")
|
||||
.append(" INNER JOIN AD_User_Roles ur ON (u.AD_User_ID=ur.AD_User_ID AND ur.IsActive='Y')")
|
||||
StringBuffer sql = new StringBuffer("SELECT AD_User.AD_User_ID, r.AD_Role_ID,r.Name,")
|
||||
.append(" AD_User.ConnectionProfile ")
|
||||
.append("FROM AD_User ")
|
||||
.append(" INNER JOIN AD_User_Roles ur ON (AD_User.AD_User_ID=ur.AD_User_ID AND ur.IsActive='Y')")
|
||||
.append(" INNER JOIN AD_Role r ON (ur.AD_Role_ID=r.AD_Role_ID AND r.IsActive='Y') ");
|
||||
|
||||
sql.append("WHERE COALESCE(u.LDAPUser,u.Name)=?"); // #1
|
||||
sql.append("WHERE ").append(userNameCol).append("=?"); // #1
|
||||
|
||||
sql.append(" AND u.IsActive='Y'").append(" AND EXISTS (SELECT * FROM AD_Client c WHERE u.AD_Client_ID=c.AD_Client_ID AND c.IsActive='Y')");
|
||||
sql.append(" AND AD_User.IsActive='Y'").append(" AND EXISTS (SELECT * FROM AD_Client c WHERE AD_User.AD_Client_ID=c.AD_Client_ID AND c.IsActive='Y')");
|
||||
|
||||
/* if (app_pwd != null && !hash_password)
|
||||
sql.append(" AND ((u.Password=? AND (SELECT IsEncrypted FROM AD_Column WHERE AD_Column_ID=417)='N') "
|
||||
+ "OR (u.Password=? AND (SELECT IsEncrypted FROM AD_Column WHERE AD_Column_ID=417)='Y'))"); // #2/3*/
|
||||
sql.append(" AND ((AD_User.Password=? AND (SELECT IsEncrypted FROM AD_Column WHERE AD_Column_ID=417)='N') "
|
||||
+ "OR (AD_User.Password=? AND (SELECT IsEncrypted FROM AD_Column WHERE AD_Column_ID=417)='Y'))"); // #2/3*/
|
||||
|
||||
sql.append(" ORDER BY r.Name");
|
||||
|
||||
|
@ -381,15 +389,11 @@ public class Login
|
|||
Env.setContext(m_ctx, "#User_Level", "S "); // Format 'SCO'
|
||||
Env.setContext(m_ctx, "#User_Client", "0"); // Format c1, c2, ...
|
||||
Env.setContext(m_ctx, "#User_Org", "0"); // Format o1, o2, ...
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
retValue = new KeyNamePair[] {new KeyNamePair(0, "System Administrator")};
|
||||
return retValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
log.saveError("UserPwdError", app_user, false);
|
||||
return null;
|
||||
}
|
||||
|
@ -480,8 +484,6 @@ public class Login
|
|||
|
||||
if (!rs.next())
|
||||
{
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
log.log(Level.SEVERE, "No Clients for Role: " + role.toStringX());
|
||||
return null;
|
||||
}
|
||||
|
@ -502,9 +504,6 @@ public class Login
|
|||
list.add(p);
|
||||
}
|
||||
while (rs.next());
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
pstmt = null;
|
||||
//
|
||||
retValue = new KeyNamePair[list.size()];
|
||||
list.toArray(retValue);
|
||||
|
@ -575,8 +574,6 @@ public class Login
|
|||
// load Orgs
|
||||
if (!rs.next())
|
||||
{
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
log.log(Level.SEVERE, "No org for Role: " + rol.toStringX());
|
||||
return null;
|
||||
}
|
||||
|
@ -726,8 +723,6 @@ public class Login
|
|||
|
||||
if (!rs.next())
|
||||
{
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
log.info("No Warehouses for Org: " + org.toStringX());
|
||||
return null;
|
||||
}
|
||||
|
@ -742,9 +737,6 @@ public class Login
|
|||
}
|
||||
while (rs.next());
|
||||
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
pstmt = null;
|
||||
//
|
||||
retValue = new KeyNamePair[list.size()];
|
||||
list.toArray(retValue);
|
||||
|
@ -893,8 +885,8 @@ public class Login
|
|||
Env.setContext(m_ctx, "$C_Currency_ID", rs.getInt("C_Currency_ID"));
|
||||
Env.setContext(m_ctx, "$HasAlias", rs.getString("HasAlias"));
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
|
||||
/**Define AcctSchema , Currency, HasAlias for Multi AcctSchema**/
|
||||
MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(Env.getCtx(), AD_Client_ID);
|
||||
|
@ -931,8 +923,8 @@ public class Login
|
|||
rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
Env.setContext(m_ctx, "$Element_" + rs.getString("ElementType"), "Y");
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
|
||||
// This reads all relevant window neutral defaults
|
||||
// overwriting superseeded ones. Window specific is read in Mainain
|
||||
|
@ -962,8 +954,8 @@ public class Login
|
|||
String va = rs.getString(2);
|
||||
Env.setContext(m_ctx, at, va);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
|
||||
// Default Values
|
||||
|
@ -978,9 +970,8 @@ public class Login
|
|||
rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
loadDefault (rs.getString(1), rs.getString(2));
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
pstmt = null;
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
|
@ -1025,9 +1016,6 @@ public class Login
|
|||
rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
value = rs.getString(1);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
|
@ -1518,8 +1506,6 @@ public class Login
|
|||
|
||||
if (!rs.next())
|
||||
{
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
log.log(Level.SEVERE, "No Roles for Client: " + client.toStringX());
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue