package cn.unitid.matrix.pkiservice.test.svs;

import cn.unitid.matrix.pkiservice.sdk.ApiException;
import cn.unitid.matrix.pkiservice.sdk.PkiClient;
import cn.unitid.matrix.pkiservice.sdk.PkiOkhttpClient;
import cn.unitid.matrix.pkiservice.sdk.svs.request.CrlVerifyRequest;
import cn.unitid.matrix.pkiservice.sdk.svs.response.CrlVerifyResponse;

/**
 * @Description CRL 校验
 * @Date 2022/5/16
 * @Created by zhy
 */
public class CrlVerifyTest {

    public static void main(String[] args) {
        // 提供的URL
        String url = "http://localhost:20402";

        // 您的appKey
        String appKey = "CLxUIrYIO0";

        // 您的appSecret
        String appSecret = "Rsl7kjMrqHrxhDk9uou23IYRnCVjRKJC";

        // 1.原客户端
        PkiClient pkiClient = new PkiOkhttpClient(url, appKey, appSecret);

        // 2.调用出错，自动重试客户端
        String certBase64 = "MIICszCCAligAwIBAgINAO2Cjz/tEqZSVvI/eDAKBggqgRzPVQGDdTBJMQswCQYDVQQGEwJDTjESMBAGA1UECAwJ5rGf6IuP55yBMRIwEAYDVQQHDAnljZfkuqzluIIxEjAQBgNVBAMMCXRlc3RTTTJDQTAeFw0yMjAzMTgwNTQwMTlaFw0yMzAzMTgwNTQwMTlaMIGjMQswCQYDVQQGEwJDTjEPMA0GA1UECAwG5rGf6IuPMQ8wDQYDVQQHDAbljZfkuqwxFTATBgNVBAoMDOaVsOWtl+iupOivgTERMA8GA1UECwwI5pm65oWnQ0ExMDAuBgNVBC0MJzFmZWM0ODA3MjlhYTQ0MjJiODk0YzhiMTM2YjFkNDU0MjAyMjAzNzEWMBQGA1UEAwwNd3d3LnF3ZmRjLmNvbTBZMBMGByqGSM49AgEGCCqBHM9VAYItA0IABFjoFlPaMPGM7OAKEYpwwsJWKjr5w0qy32hLc/z4r065nPWJyZl+VkP/8EF0mRSrvjJz3tlR9OMiaDjjHwxW86KjgckwgcYwCQYDVR0TBAIwADAdBgNVHQ4EFgQU0HDEQ8QjtsYHokinKQvAK7z+FoEwSwYDVR0lAQH/BEEwPwYIKwYBBQUHAwEGCCsGAQUFBwMCBggrBgEFBQcDBAYIKwYBBQUHAwgGCisGAQQBgjcKAwMGCWCGSAGG+EIEATAOBgNVHQ8BAf8EBAMCBsAwHAYDVR0RBBUwE4IRd3d3Lnh1amkudGVzdC5jb20wHwYDVR0jBBgwFoAUE3GRQ7iygyrxFixllDZ6SqWNJicwCgYIKoEcz1UBg3UDSQAwRgIhAIi2sGHKO+KkMX9MxC2c+u/p82t4SxqEjbDk96zluqmfAiEA00lg6iFIc03pofZbsA5uiA6vznSLKaru1A+nGqO78Uw=";

        CrlVerifyRequest request = new CrlVerifyRequest();
        request.setCert(certBase64);
        request.setCrlId("62565e04bd7c966f8c0afde6");
        request.setCertSn("f2ea5129fe03c8623759b25d");

        try {
            CrlVerifyResponse response = pkiClient.execute(request);
            // 后续业务
            if (response.isSuccess()) {
                System.out.println("成功：" + response.getBody());
            } else {
                System.out.println("失败：" + response.getBody());
            }
        } catch (ApiException e) {
            e.printStackTrace();
        }
    }

}
