Skip to main content

Java SDK User Guide

Installation​

Loading SDK configuration…

Initialization​

Loading SDK configuration…

Product and Pricing List​

API Reference

import java.util.Map;

Map<String, Object> resp = product.productList();
System.out.println(resp.get("data"));

Create Certificate Order​

API Reference

import com.anquanssl.request.CertificateCreateRequest;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

CertificateCreateRequest req = new CertificateCreateRequest();
req.setUniqueId("order_" + UUID.randomUUID());
req.setProductId("sslcom_dv_flex");
req.setPeriod("annually");
req.setCsr("-----BEGIN CERTIFICATE REQUEST-----\n...\n-----END CERTIFICATE REQUEST-----");
req.setContactEmail("contact@example.com");
req.setNotifyUrl("https://app.example.com/notify");

Map<String, String> domainDcv = new HashMap<>();
domainDcv.put("example.com", "dns");
domainDcv.put("www.example.com", "http");
req.setDomainDcv(domainDcv);

Map<String, Object> resp = order.certificateCreate(req);
Map<String, Object> data = (Map<String, Object>) resp.get("data");
String serviceId = data.get("service_id").toString();

System.out.println(resp);

Query Certificate​

API Reference

import com.anquanssl.request.CertificateDetailRequest;

CertificateDetailRequest req = new CertificateDetailRequest();
req.setServiceId(serviceId);

Map<String, Object> resp = order.certificateDetail(req);
System.out.println(resp);

Update DCV​

API Reference

The Java SDK does not currently provide a wrapper for the certificateUpdateDCV method; you can call the client directly:

Map<String, Object> body = new HashMap<>();
Map<String, String> domainDcv = new HashMap<>();
domainDcv.put("example.com", "dns");
domainDcv.put("www.example.com", "https");
body.put("service_id", serviceId);
body.put("domain_dcv", domainDcv);

Map<String, Object> resp = client.post("/certificate/update-dcv", new HashMap<>(), body);
System.out.println(resp);

Validate DCV​

API Reference

import com.anquanssl.request.CertificateValidateDCVRequest;

CertificateValidateDCVRequest req = new CertificateValidateDCVRequest();
req.setServiceId(serviceId);

Map<String, Object> resp = order.certificateValidateDCV(req);
System.out.println(resp);

Remove SAN​

API Reference

The Java SDK does not currently provide a wrapper for the certificateRemoveSan method; you can call the client directly:

Map<String, Object> body = new HashMap<>();
body.put("service_id", serviceId);
body.put("domain", "www.example.com");

Map<String, Object> resp = client.post("/certificate/remove-san", new HashMap<>(), body);
System.out.println(resp);

Reissue Certificate​

API Reference

Map<String, Object> body = new HashMap<>();
Map<String, String> domainDcv = new HashMap<>();
domainDcv.put("example.com", "dns");
domainDcv.put("www.example.com", "http");
body.put("unique_id", "reissue_" + UUID.randomUUID());
body.put("service_id", serviceId);
body.put("csr", "-----BEGIN CERTIFICATE REQUEST-----\n...\n-----END CERTIFICATE REQUEST-----");
body.put("contact_email", "contact@example.com");
body.put("domain_dcv", domainDcv);

Map<String, Object> resp = client.post("/certificate/reissue", new HashMap<>(), body);
System.out.println(resp);

Refund Certificate​

API Reference

import com.anquanssl.request.CertificateRefundRequest;

CertificateRefundRequest req = new CertificateRefundRequest();
req.setServiceId(serviceId);

Map<String, Object> resp = order.certificateRefund(req);
System.out.println(resp);

Error Handling​

Map<String, Object> resp = product.productList();
if (!Boolean.TRUE.equals(resp.get("success"))) {
throw new RuntimeException(String.valueOf(resp.get("message")));
}