int timeout = agent.getParamInteger(PARAM_TIMEOUT, 30);
// Determina si la cuenta del usuario est� o no bloqueada
if (isLocked(login, attemps, timeout))
{
throw new AuthenticationException("La cuenta " + login + " est� bloqueada.");
}
}
try
{
sql = "SELECT * " +
"FROM " + TABLE_NAME + " " +
"WHERE Lower(usrlogin) = '" + login.trim().toLowerCase() + "' And " +
" usrpwd = '" + CryptoUtils.encrypt(password) + "'";
conn = DataFactory.getInstance(workspace);
// ds = this.workspace.getProperties().getDataProperties().getDataSource();
// conn = new DataConnection(ds);
// conn.connect();
ResultSet rs = conn.executeSql(sql);
if (rs.next())
{
user = new User();
user.setLogin(rs.getString("usrlogin"));
user.setMail(rs.getString("usrmail"));
user.setName(rs.getString("usrname"));
user.setCreated(rs.getDate("usrcreated"));
user.setLastLogin(rs.getDate("usrlastlogin"));
user.setLogonCount(rs.getInt("usrlogoncount"));
}
else
{
// Si tiene el control de bloqueo activado, actualiza la informaci�n de bloqueo
if (agent.getParamBoolean(PARAM_LOCKCONTROL, false))
{
loginFail(login);
}
throw new UserNotFoundException();
}
// Actualiza los datos estadísticos y de control del usuario
sql = "UPDATE " + TABLE_NAME + " " +
"SET usrlastlogin = current_timestamp, " +
" usrlogoncount = usrlogoncount + 1 " +
"WHERE Lower(usrlogin) = '" + login.trim().toLowerCase() + "'";
conn.execute(sql);
// Confirma los cambios en la bbdd
if (!conn.isAutoCommit()) conn.commit();
}
catch (SQLException ex)
{
throw new AuthenticationException(ex.getMessage(), ex);
}
catch (GeneralSecurityException ex)
{
throw new AuthenticationException(ex.getMessage(), ex);
}
catch (UserNotFoundException ex)
{
throw ex;
}
catch (Exception ex)
{
throw new AuthenticationException(ex.getMessage(), ex);
}
finally
{
conn.disconnect();
}