简体   繁体   中英

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.
  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.

Below detail, I am using production account token and create the certificate on cert, but uploaded pdf is not able to download.

@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. If you install them in your JAVA home JRE, they should be picked up by your IDE (provided you're using that JAVA installation).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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