简体   繁体   English

Java中的SandBox帐户身份验证和上传证书?

[英]SandBox account authentication in java and upload certificate?

  1. My Certificate created on Production account but not on sandbox account. 我的证书是在生产帐户上创建的,而不是在沙盒帐户上创建的。
  2. The certificate created on cert but uploaded pdf is not available to be download from it. 无法在cert上创建在cert上创建但已上传pdf的证书。
  3. My issue is I am not able to download the pdf (Because I think it did not successfully get uploaded), use my SandBox account for the test. 我的问题是我无法下载pdf(因为我认为未成功上传),请使用我的SandBox帐户进行测试。

Below detail, I am using production account token and create the certificate on cert, but uploaded pdf is not able to download. 在下面的详细信息中,我正在使用生产帐户令牌并在cert上创建证书,但是无法下载上载的pdf。

@RequestMapping(method = RequestMethod.POST, value="/certificateFormData")
    public String certificateFormData(@RequestParam("file") MultipartFile inputFile,Model model,HttpServletRequest request) {
        System.out.println("**********");
        String pattern = "yyyy-MM-dd";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
        String date = simpleDateFormat.format(new Date());
        Customer customer= (Customer)request.getSession().getAttribute("customer");

        try {
            if (!inputFile.isEmpty()) {

                System.out.println(inputFile.getName());


                    String exemptReason =   request.getParameter("exempt_reason");
                    String exposureZone =   request.getParameter("exposure_zones");
                    String exemptsCategory =request.getParameter("tax_exempt_category");
                    /*String taxNumber= request.getParameter("tax_number");
                    String verificationNumber = request.getParameter("verification_number");
                    */
                    System.out.println("getData================================>");
                    System.out.println("exempt reaosn"+exemptReason);
                    System.out.println(exposureZone);
                    System.out.println(exemptsCategory);

                    String  base64=Base64.getUrlEncoder().encodeToString(inputFile.getBytes());
                    StringBuilder query = new StringBuilder();
                    query.append("signed_date="+date);
                    query.append("&expiration_date="+"9999-12-31");
                    /*query.append("&valid="+true);
                    query.append("&verified="+true);*/
                    query.append("&never_renew="+true);
                    /*query.append("&renewable="+true);*/
                    query.append("&unused_multi_cert="+false);
                    query.append("&exmpt_percent="+0);/*
                    query.append("&verification_number="+verificationNumber);
                    query.append("&tax_number="+taxNumber);*/


                    query.append("&unused_multi_cert="+false);

                    for(TaxExemptReason reason: taxExemptReasons) {
                        if(reason.getId().equals(exemptReason)){
                            JSONObject obj = new JSONObject();
                            obj.put("id", exemptReason);
                            obj.put("name", reason.getName());
                            obj.put("tag", reason.getTag());
                            query.append("&expected_tax_code=" + obj.toString());
                        }   

                    }

                    for (ExposureZone zone :exposureZones) {
                        if (zone.getId().equals(exposureZone)) {
                            JSONObject obj = new JSONObject();
                            obj.put("id", exposureZone);
                            obj.put("name", zone.getName());
                            obj.put("tag", zone.getTag());
                            query.append("&exposureZone=" + obj.toString());
                        }
                    }
                    query.append("&status={\"name\":\"PENDING\"}");
                    query.append("&pdf=" + base64);


                    String response = certCaptureService.createCertificate(query,properties);
                    System.out.println("cert certificate response"+response);

                    JSONObject certCertificateJson= new  JSONObject(response);

                    if(response.contains("id"))
                    {

                        Certificate certificate= new Certificate();
                        certificate.setBigcommerceCustomerId(customer.getBigcommerceCustomerId());
                        certificate.setCertificateId(certCertificateJson.get("id")+"");
                        certificate.setCertCustomerId(customer.getCertCustomerId());
                        certificate.setCertCustomerNumber(customer.getCertCustomerNumber());
                        certificate.setClientId(customer.getClientId());
                        certificate.setExemptionCategory(exemptsCategory);
                        certificate.setCreatedate(new Timestamp(System.currentTimeMillis()));
                        certificate.setUpdateDate(new Timestamp(System.currentTimeMillis()));
                        certificate.setExempt_reason(exemptReason);
                        certificate.setExposure_zones(exposureZone);
                        certificate.setTaxDetails("");
                        customerDaoService.saveCertificate(certificate);

                        try {
                            String certificateQuery="certificates=[{\"id\":"+certCertificateJson.get("id")+"}]";
                            String certificateQueryResponse= certCaptureService.createCustomerwithCertificate(customer.getCertCustomerId(),
                                    certificateQuery, properties);
                            System.out.println("cert certificate customer response"+certificateQueryResponse);
                            if(certificateQueryResponse.contains("success")) 
                                model.addAttribute("response","Succcessfully create a certificate");
                            else
                                model.addAttribute("response","No Certificate Created.");
                        }catch (Exception e) {
                            model.addAttribute("response","No Certificate Created.");
                        }
                    }
                    else {
                        model.addAttribute("response","No Certificate Created.");
                    }

            }
        }catch (Exception e) {
            e.printStackTrace();
        }   
        return "redirect:/customer/"+customer.getBigcommerceCustomerId();
    }

Not sure if this will help your issue, but I had loads of certificate issues at first. 不知道这是否对您的问题有所帮助,但是起初我遇到了很多证书问题。 When you install the three certificates (wildcard, intermediate, root), install them in $JAVA_HOME/jre/lib/security. 安装三个证书(通配符,中间证书,根证书)时,请将它们安装在$ JAVA_HOME / jre / lib / security中。 If you install them in your JAVA home JRE, they should be picked up by your IDE (provided you're using that JAVA installation). 如果将它们安装在JAVA家用JRE中,则应该由您的IDE拾取它们(前提是您正在使用该JAVA安装)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM