Ejemplo n.º 1
0
  @Override
  public String getDocumentAccess(Long nID_Access, String sSecret) throws Exception {
    Session oSession = getSession();

    DocumentAccess docAcc = new DocumentAccess();
    List<DocumentAccess> list = findAll();
    if (list == null || list.isEmpty()) {
      throw new Exception("Access not accepted!");
    } else {
      for (DocumentAccess da : list) {
        if (da.getId() == nID_Access && da.getSecret().equals(sSecret)) {
          docAcc = da;
          break;
        }
      }
    }
    String sTelephone = "";
    if (docAcc.getTelephone() != null) {
      sTelephone = docAcc.getTelephone();
    }
    String sAnswer = SecurityUtils.generateAnswer();
    docAcc.setAnswer(sAnswer);
    String otpPassword = getOtpPassword(docAcc);
    return otpPassword;
  }
Ejemplo n.º 2
0
  @Override
  public String sSentDocumentAccessOTP_Phone(String sCode) throws Exception {
    String sPhoneSent = null;
    // Session oSession = getSession();
    boolean bSent = false;
    DocumentAccess oDocumentAccess = findBy("sCode", sCode).orNull();
    if (oDocumentAccess.getTelephone() != null
        && oDocumentAccess.getTelephone().trim().length() > 6) {
      String sPhone = oDocumentAccess.getTelephone();
      sPhoneSent = sPhone;
      log.info("[bSentDocumentAccessOTP]sPhone=" + sPhone);

      String sAnswer = SecurityUtils.generateAnswer();
      log.info("[bSentDocumentAccessOTP]sAnswer=" + sAnswer);

      // o.setDateAnswerExpire(null);
      // SEND SMS with this code
      String sReturn;
      if (generalConfig.bTest()) {
        sAnswer = "4444";
      }
      oDocumentAccess.setAnswer(sAnswer);
      //                        writeRow(oDocumentAccess);
      saveOrUpdate(oDocumentAccess);
      log.info("oDocumentAccess.getId()=" + oDocumentAccess.getId() + ":Ok!");

      if (generalConfig.bTest()) {
        sReturn = "test";
      } else {
        sReturn = sendPasswordOTP(sPhone, sAnswer);
      }

      log.info("[bSentDocumentAccessOTP]sReturn=" + sReturn);

      bSent = true;
    } else {
      // TODO loging warn
    }
    // return  bSent;
    return sPhoneSent;
  }