Пример #1
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;
  }
Пример #2
0
  private String getSessionId() {
    String sessionId;
    String login = generalConfig.getSID_login();
    String password = generalConfig.getSID_password();
    String uriSid = generalConfig.sURL_GenerationSID() + "?lang=UA";

    String xml =
        "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>\n"
            + "<session><user auth='EXCL' login='******' password='******'/></session>";

    String xmlResponse =
        new RestRequest()
            .post(uriSid, xml, MediaType.TEXT_XML, StandardCharsets.UTF_8, String.class, null);
    sessionId = getSidFromXml(xmlResponse);

    return sessionId;
  }
  @RequestMapping(
      value = "/setPaymentStatus_TaskActiviti",
      method = RequestMethod.POST,
      headers = {"Accept=application/json"})
  public @ResponseBody String setPaymentStatus_TaskActiviti(
      @RequestParam String sID_Order,
      @RequestParam String sID_PaymentSystem,
      @RequestParam String sData,
      @RequestParam(value = "sPrefix", required = false) String sPrefix,
      @RequestParam(value = "data", required = false) String data,
      @RequestParam(value = "signature", required = false) String signature,
      HttpServletRequest request)
      throws Exception {

    if (sPrefix == null) {
      sPrefix = "";
    }

    String URI = request.getRequestURI() + "?" + request.getQueryString();
    LOG.info("/setPaymentStatus_TaskActiviti");

    LOG.info("sID_Order=" + sID_Order);
    LOG.info("sID_PaymentSystem=" + sID_PaymentSystem);
    LOG.info("sData=" + sData);
    LOG.info("sPrefix=" + sPrefix);

    LOG.info("data=" + data);
    LOG.info("signature=" + signature);
    LOG.info("URI=" + URI);
    String sDataDecoded = null;

    try {
      if (data != null) {
        sDataDecoded = new String(Base64.decodeBase64(data.getBytes()));
        LOG.info("sDataDecoded=" + sDataDecoded);
      }
      setPaymentStatus(sID_Order, sDataDecoded, sID_PaymentSystem, sPrefix);
      // setPaymentStatus(sID_Order, null, sID_PaymentSystem);
    } catch (Exception oException) {
      LOG.error("/setPaymentStatus_TaskActiviti", oException);
      String snID_Subject = "0";
      String sAccessKey = null;
      try {
        // sAccessKey = accessDataDao.setAccessData(URI);
        sAccessKey = accessCover.getAccessKey(URI);
      } catch (Exception oException1) {
        LOG.error("/setPaymentStatus_TaskActiviti:sAccessKey=", oException1);
      }

      // generalConfig.sHost() +
      // "/wf/service/setPaymentStatus_TaskActiviti_Direct?sID_Order="+sID_Order+"&sID_PaymentSystem="+sID_PaymentSystem+"&sData=&sID_Transaction=&sStatus_Payment="
      String sURL =
          new StringBuilder(generalConfig.sHost())
              .append("/wf/service/setPaymentStatus_TaskActiviti_Direct?")
              .append("sID_Order=")
              .append(sID_Order)
              .append("&sID_PaymentSystem=")
              .append(sID_PaymentSystem)
              .append("&sData=")
              .append("")
              .append("&nID_Subject=")
              .append(snID_Subject)
              // .append("sAccessContract=").append("Request")
              // .append("&sAccessKey=").append(sAccessKey)
              .append("&")
              .append(AuthenticationTokenSelector.ACCESS_CONTRACT)
              .append("=")
              .append(AuthenticationTokenSelector.ACCESS_CONTRACT_REQUEST)
              .append("&")
              .append(AuthenticationTokenSelector.ACCESS_KEY)
              .append("=")
              .append(sAccessKey)
              .toString();

      String sFormHTML =
          new StringBuilder()
              .append("<form method=\"GET\" action=\"") // POST
              .append(sURL)
              .append("\" ")
              .append("accept-charset=\"utf-8\">")
              .append("<input type=\"text\" name=\"sID_Transaction\" value=\"\"/>")
              .append("<input type=\"text\" name=\"sStatus_Payment\" value=\"\"/>")
              .append("<input type=\"submit\" value=\"��������� ������ ����������!\"/>")
              .append("</form>")
              .toString();

      String saToMail = "[email protected],[email protected]";
      String sHead =
          (generalConfig.bTest() ? "(test)" : "(PROD)")
              + "/setPaymentStatus_TaskActiviti:������ ��� ������� �������� ��������� ���������� � ������� � ��������-������!";
      String sBody =
          "oException.getMessage()="
              + oException.getMessage()
              + "<br>"
              + "<br>"
              + "sID_Order="
              + sID_Order
              + "<br>"
              + "sID_PaymentSystem="
              + sID_PaymentSystem
              + "<br>"
              + "sData="
              + sData
              + "<br>"
              + "data="
              + data
              + "<br>"
              + "signature="
              + signature
              + "<br>"
              + "<br>"
              + "���� ������� �������� ��� �������� �������:<br>"
              + sFormHTML
              + "<br>"
              + "<br>"
              + "���� �� ����������, ��������� �� <a href=\""
              + sURL
              + "&sID_Transaction=&sStatus_Payment="
              + "\" target=\"_top\">���� ������</a>, � ���������� ������� �� ����������(sID_Transaction) � ������(sStatus_Payment). �����, ��� ������������� ��������������� ����� � ������ (����� �������� � ������)<br>"
              + "("
              + sURL
              + "&sID_Transaction=&sStatus_Payment="
              + ")<br>"
              + "<br>";
      oMail.reset();
      oMail
          // ._From(mailAddressNoreplay)
          ._To(saToMail)
          ._Head(sHead)
          ._Body(sBody);
      oMail.send();
      throw oException;
    }
    return sData;
  }
Пример #4
0
  @Override
  public String setDocumentLink(
      Long nID_Document, String sFIO, String sTarget, String sTelephone, Long nMS, String sMail)
      throws Exception {
    DocumentAccess oDocumentAccess = new DocumentAccess();
    oDocumentAccess.setID_Document(nID_Document);
    oDocumentAccess.setDateCreate(new DateTime());
    oDocumentAccess.setMS(nMS);
    oDocumentAccess.setFIO(sFIO);
    oDocumentAccess.setMail(sMail);
    oDocumentAccess.setTarget(sTarget);
    oDocumentAccess.setTelephone(sTelephone);
    oDocumentAccess.setSecret(SecurityUtils.generateSecret());

    //		String id = writeRow(oDocumentAccess).toString();

    if (oDocumentAccess.getsCode() == null) oDocumentAccess.setsCode("null");
    if (oDocumentAccess.getsCodeType() == null) oDocumentAccess.setsCodeType("null");

    saveOrUpdate(oDocumentAccess);

    String id = oDocumentAccess.getId().toString();
    log.info("id=" + id);

    // sCode;sCodeType
    oDocumentAccess.setsCode(id);
    oDocumentAccess.setsCodeType((sTelephone != null && sTelephone.length() > 6) ? "sms" : "");
    //		writeRow(oDocumentAccess);
    saveOrUpdate(oDocumentAccess);
    log.info("id=" + id + ":Ok!");

    /*StringBuilder osURL = new StringBuilder(sURL);
          osURL.append("nID_Access=");
    osURL.append(getIdAccess()+"&");
    osURL.append("sSecret=");
    osURL.append(oDocumentAccess.getSecret());*/
    // return osURL.toString();

    if (sMail != null && !"".equals(sMail.trim())) {
      String saToMail = sMail;
      String sHead = "Доступ до документу";
      String sBody =
          "Вам надано доступ до документу на Порталі державних послуг iGov.org.ua.<br>"
              + "<br>"
              + "<b>Код документу:</b> %"
              + id
              + "%<br>"
              + "<br>"
              + "Щоб переглянути цей документ, зайдіть на <a href=\""
              + generalConfig.sHostCentral()
              + "\">iGov.org.ua</a>, пункт меню <b>Документи</b>, вкладка <b>Пошук документу за кодом</b>. Там оберіть тип документу, того, хто його надає та введіть код.<br>"
              + "<br>"
              + "З повагою,<br>"
              + "команда порталу державних послу iGov";
      oMail.reset();
      oMail._To(saToMail)._Head(sHead)._Body(sBody);
      oMail.send();
    }

    return id;
  }
Пример #5
0
  public Document getDocument() {
    Document doc = new Document();
    String sessionId;
    String keyIdParam;
    String callBackKey = "&callbackUrl=";
    String callBackValue = generalConfig.sURL_DocumentKvitanciiCallback();
    String keyID = this.accessCode;
    Collection<Long> correctDocTypes = Lists.newArrayList(0L, 1L);
    String uriDoc;

    if (this.documentTypeId == null || !correctDocTypes.contains(this.documentTypeId)) {
      LOG.error("DocumentTypeId = " + this.documentTypeId);
      throw new DocumentTypeNotSupportedException(
          "Incorrect DocumentTypeId. DocumentTypeId = " + this.documentTypeId);
    } else {
      uriDoc =
          Long.valueOf(0L).equals(this.documentTypeId)
              ? generalConfig.sURL_DocumentKvitanciiForIgov()
              : generalConfig.sURL_DocumentKvitanciiForAccounts();

      keyIdParam = Long.valueOf(0L).equals(this.documentTypeId) ? "?keyID=" : "?id=";
    }

    String finalUri = uriDoc + keyIdParam + keyID + callBackKey + callBackValue;

    // if (generalConfig.bTest()) {
    SSLCertificateValidation.disable();
    // }

    try {
      sessionId = getSessionId();
      String authHeader = "sid:" + sessionId;
      byte[] authHeaderBytes = Base64.encode(authHeader.getBytes(StandardCharsets.UTF_8));
      String authHeaderEncoded = new String(authHeaderBytes);

      HttpHeaders headers = new HttpHeaders();
      headers.setAccept(Collections.singletonList(MediaType.ALL));
      headers.set("Authorization", "Basic " + authHeaderEncoded);
      LOG.debug("try to final url: {}", finalUri);
      ResponseEntity<byte[]> documentEntity =
          new RestRequest()
              .getEntity(finalUri, null, StandardCharsets.UTF_8, byte[].class, headers);

      String contentType = documentEntity.getHeaders().getContentType().toString();
      String contentDispositionHeader =
          documentEntity.getHeaders().get("Content-Disposition").get(0);
      ContentDisposition header = new ContentDisposition(contentDispositionHeader);
      String documentName = header.getParameter("name");

      if (isBlank(documentName)) {
        documentName = header.getParameter("filename");
      }

      if (this.withContent) {
        doc.setFileBody(getFileFromRespEntity(documentEntity));
      }

      doc.setDocumentType(documentTypeDao.findByIdExpected(0L));
      doc.setSubject(subjectDao.getSubject(this.nID_Subject));
      doc.setFile(documentName);
      doc.setContentType(contentType);
      doc.setDate_Upload(DateTime.now());
      doc.setsID_subject_Upload(null);
      doc.setContentKey(null);
      doc.setoSignData(null);

    } catch (ParseException | ResourceAccessException e) {
      LOG.error("Can't get document: ", e);
      throw new DocumentNotFoundException("Can't get document: ", e);
    }

    return doc;
  }