Reputation: 39
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();
}
Upvotes: 0
Views: 91
Reputation: 115
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).
Upvotes: 0