Ejemplo n.º 1
0
  @Override
  protected void initOwnPageComponents() {
    super.initOwnPageComponents();
    if (LOG.isDebugEnabled()) LOG.debug("Continue Authentication");

    if (getMobiliserWebSession().getTxnPayer() == null) {
      setResponsePage(ErrorPage.class);
      return;
    }

    Transaction txn = getMobiliserWebSession().getTransaction();
    if (LOG.isDebugEnabled()) LOG.debug("Request retry count: " + txn.getContinueRetryCounter());
    // Create Thread.
    SmsAuthenticationThread t =
        new SmsAuthenticationThread(
            txn, getMobiliserWebSession().getMsisdn(), createWebContinueRequest());
    t.setName("TxnThread" + txn.getTxnId());

    // Store Thread in Context
    getMobiliserWebSession().setSmsThread(t);

    if (LOG.isDebugEnabled())
      LOG.debug(
          "Starting Authentication Thread. [Msisdn="
              + txn.getPayer().getId()
              + "] [txn="
              + txn.getTxnId()
              + "]");

    // Start Thread
    t.start();

    constructPageComponent();
  }
Ejemplo n.º 2
0
  private void prepairResponse(AjaxResponse obj, Transaction txn) {
    if (LOG.isDebugEnabled())
      LOG.debug("Return Ajax status " + obj.getStatus() + " - " + obj.getErrorMessage());

    if (txn != null) {
      obj.setReturnUrl(txn.getReturnUrl());
      obj.setRetry(txn.getContinueRetryCounter());
      obj.setRedirect(true);

      if (LOG.isDebugEnabled()) {
        Date pollStart = (Date) txn.getContinueStartDate();
        Date currentTime = new Date();
        long dif = currentTime.getTime() - pollStart.getTime();
        LOG.debug(
            "Ajax Poll: [RetryCount="
                + (obj.getRetry())
                + "] [Elapsed Time="
                + (dif / 1000)
                + "s]");
      }
    }
    response = obj;
  }
Ejemplo n.º 3
0
  protected void checkStatus(AjaxRequestTarget target) {
    if (PortalUtils.exists(response)) {
      checkResponse(target);
    }
    // get current Thread
    SmsAuthenticationThread t = getMobiliserWebSession().getSmsThread();

    // if technical problem...
    // Thread not started
    if (t == null) {
      prepairResponse(new AjaxResponse(9999, "Thread not started"), null);
      return;
    }

    // exception was thrown from thread
    if (t.getException() != null) {
      prepairResponse(new AjaxResponse(9999, "Exception: " + t.getException().getMessage()), null);
      return;
    }

    // Still processing request
    if (t.isActive()) {
      prepairResponse(new AjaxResponse(-1, ""), null);
      return;
    }

    // Thread is finished

    // no answer from Mobiliser. Technical error
    if (t.getResponse() == null) {
      prepairResponse(new AjaxResponse(9999, "No response from Mobiliser"), null);
      return;
    }

    Transaction txn = getMobiliserWebSession().getTransaction();

    // check if second try is exceeded. Cancel Transaction by second
    // retry
    if (txn.getContinueRetryCounter() >= 2 && t.getResponse().getStatus().getCode() == 2853) {

      if (LOG.isDebugEnabled()) LOG.debug("retry count exceeded. Canceling transaction");

      try {
        // Fail transaction
        txn.failTransaction(2853);

      } catch (Exception e) {
        LOG.error("#failTransaction: " + e, e);
      }

      // Kill Session
      getMobiliserWebSession().invalidate();

      prepairResponse(new AjaxResponse(9999, "Cancel Response"), txn);
      return;
    }

    // check status of mobiliser response
    if (t.getResponse().getStatus() != null && t.getResponse().getStatus().getCode() != 0) {
      // Mobiliser request failed with an error code

      AjaxResponse response =
          new AjaxResponse(
              t.getResponse().getStatus().getCode(), t.getResponse().getStatus().getValue());

      switch (t.getResponse().getStatus().getCode()) {
        case 2853: // Transaction timed out
          response.setRetryVisible(true);

        default:
          response.setRedirect(true);
      }

      prepairResponse(response, txn);
      return;
    }

    // everything was OK
    prepairResponse(new AjaxResponse(0, "OK"), txn);
  }