Example #1
0
  public static int getFreeUser(String entidad) throws Exception {

    IeciTdLongIntegerArrayList freeUserIds = null;
    int numFreeUsers, i;
    int freeUserId = -1, userId;
    boolean findFreeUser = false;

    DbConnection dbCon = new DbConnection();
    try {
      dbCon.open(DBSessionManager.getSession(entidad));
      freeUserIds = DaoUsrPoolTbl.selectFreeUserIds(dbCon);
    } catch (Exception e) {
      throw e;
    } finally {
      dbCon.close();
    }

    numFreeUsers = freeUserIds.count();

    for (i = 0; i < numFreeUsers; i++) {
      userId = freeUserIds.get(i);

      DbConnection dbConn = new DbConnection();
      try {
        dbConn.open(DBSessionManager.getSession(entidad));

        dbConn.beginTransaction();

        DaoUsrPoolTbl.lockUserRow(dbConn, userId);

        // Se comprueba que nadie le ha cambiado el estado antes de bloquear
        // la fila

        if (DaoUsrPoolTbl.isUserFree(dbConn, userId)) {
          DaoUsrPoolTbl.setInUseStatus(dbConn, userId);

          findFreeUser = true;
          freeUserId = userId;
        }

        dbConn.endTransaction(true);

        if (findFreeUser) break;
      } catch (Exception e) {
        throw e;
      } finally {
        dbConn.close();
      }
    }

    if (!findFreeUser) {
      throw new IeciTdException(
          UtilError.EC_NOT_EXISTS_POOL_FREE_USER, UtilError.EM_NOT_EXISTS_POOL_FREE_USER);
    }

    return freeUserId;
  }
Example #2
0
  /**
   * Cambia la contraseña del usuario, si y solo si, se cumplen los requisitos fijados en la
   * aplicación. Lanza una excepción si no se ha podido cambiar la pasword indicando el motivo
   *
   * @param name Login del usuario
   * @param pwd Password introducida por el usuario al logarse
   * @param cntsTriesNum Número de intentos de login que ha realizado el usuario
   * @param newPwd1 Nueva password del usuario
   * @param newPwd2 Verificación de la nueva password del usuario
   * @throws Exception Exception if the application business logic throws an exception
   * @since V1.0
   */
  public static void changePassword(
      String name, String pwd, int cntsTriesNum, String newPwd1, String newPwd2, String entidad)
      throws Exception {

    DbConnection dbConn = new DbConnection();
    try {
      dbConn.open(DBSessionManager.getSession(entidad));

      UasMdoAuth.changePassword(name, pwd, cntsTriesNum, newPwd1, newPwd2, entidad);

    } catch (Exception e) {
      throw e;
    } finally {
      dbConn.close();
    }
  }
Example #3
0
  public static void freeUser(int userId, String entidad) throws Exception {

    DbConnection dbConn = new DbConnection();
    try {
      dbConn.open(DBSessionManager.getSession(entidad));

      dbConn.beginTransaction();

      DaoUsrPoolTbl.setFreeStatus(dbConn, userId);

      dbConn.endTransaction(true);

    } catch (Exception e) {
      throw e;
    } finally {
      dbConn.close();
    }
  }
Example #4
0
  /**
   * DOCUMENT ME!
   *
   * @param name Login del usuario
   * @param pwd Password introducida por el usuario al logarse
   * @param cntsTriesNum Número de intentos de login que ha realizado el usuario
   * @return UasAuthToken Información completa del usuario
   * @throws Exception Exception if the application business logic throws an exception
   * @since V1.0
   */
  public static UasAuthToken authenticateUser(
      String name, String pwd, int cntsTriesNum, String entidad) throws Exception {

    UasAuthToken uasToken = null;

    DbConnection dbConn = new DbConnection();
    try {
      dbConn.open(DBSessionManager.getSession(entidad));

      uasToken = UasMdoAuth.authenticateUser(name, pwd, cntsTriesNum, entidad);

      return uasToken;
    } catch (Exception e) {
      return uasToken;

    } finally {
      dbConn.close();
    }
  }
Example #5
0
  /**
   * @autor IECISA
   * @param name Login del usuario
   * @return UasDaoUserRecO Objeto UasDaoUserRecO con la información del usuario
   * @throws Exception Exception if the application business logic throws an exception
   * @since V1.0
   */
  public static UasDaoUserRecO selectRecO(String name, String entidad) throws Exception {

    UasDaoUserRecO rec = new UasDaoUserRecO();
    String qual;

    qual = "WHERE " + CD_NAME.getName() + "='" + name + "'";

    DbConnection dbConn = new DbConnection();
    try {
      dbConn.open(DBSessionManager.getSession(entidad));
      DbSelectFns.select(dbConn, TN, OCN, qual, rec);
    } catch (Exception e) {
      throw e;
    } finally {
      dbConn.close();
    }

    return rec;
  }