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.consts.DataType;
import cn.unitid.matrix.pkiservice.sdk.internal.util.ApiUtils;
import cn.unitid.matrix.pkiservice.sdk.svs.request.P7VerifyBatchRequest;
import cn.unitid.matrix.pkiservice.sdk.svs.response.P7VerifyBatchResponse;

import java.util.ArrayList;
import java.util.List;

public class P7VerifyBatchTest {

    public static void main(String[] args) {

        
        // 提供的URL
        String url = "http://localhost:9200";

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

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

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

        P7VerifyBatchRequest request = new P7VerifyBatchRequest();

        ArrayList<P7VerifyBatchRequest.P7Signature> p7Signatures = new ArrayList<>();

        //签名值对象1
        P7VerifyBatchRequest.P7Signature p7Signature1 = new P7VerifyBatchRequest.P7Signature();
        p7Signature1.setSignature("MIAGCiqBHM9VBgEEAgKggDCAAgEDMQ4wDAYIKoEcz1UBgxEFADCABgoqgRzPVQYBBAIBAACggDCCAhcwggG9oAMCAQICDQDEuillc8CChwJ+ee4wCgYIKoEcz1UBg3UwSTELMAkGA1UEBhMCQ04xEjAQBgNVBAgMCeaxn+iLj+ecgTESMBAGA1UEBwwJ5Y2X5Lqs5biCMRIwEAYDVQQDDAl0ZXN0U00yQ0EwHhcNMjIwNjA3MDkxNDAyWhcNMjMwNjA3MDkxNDAyWjBeMQswCQYDVQQGEwJDTjEwMC4GA1UELQwnMjlhY2VjYjgzNTRjNDY0ZmI5MGIzMmRiYzMwZWQ1OTEyMDIyMDY4MR0wGwYDVQQDDBRNYXRyaXggUEtJIFRTUyBUZXN0MTBZMBMGByqGSM49AgEGCCqBHM9VAYItA0IABD9dnFKj6VDTTCg7n6l8FJANwPZjFODTpyeB2diSJlO3uWY38t3CTU0lhcIVnqX0Nr2Q4WPi5NPqdyUUSg5RH92jdTBzMAkGA1UdEwQCMAAwHQYDVR0OBBYEFHgkVz2SHJTgVwzjhZSNW/+OQW47MA4GA1UdDwEB/wQEAwIGwDAWBgNVHSUBAf8EDDAKBggrBgEFBQcDCDAfBgNVHSMEGDAWgBQTcZFDuLKDKvEWLGWUNnpKpY0mJzAKBggqgRzPVQGDdQNIADBFAiBvFIi2ba4jkFZJ17k8maoR0DmZqmfCdtmtPLorvcKIIAIhAJU+M/aZlg8YD60qsqJzMKbCIzHv4rb8+brseNTYM4zMAAAxggE1MIIBMQIBATBaMEkxCzAJBgNVBAYTAkNOMRIwEAYDVQQIDAnmsZ/oi4/nnIExEjAQBgNVBAcMCeWNl+S6rOW4gjESMBAGA1UEAwwJdGVzdFNNMkNBAg0AxLopZXPAgocCfnnuMAwGCCqBHM9VAYMRBQCgaTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0yMjA2MDkwNzEyMDdaMC8GCSqGSIb3DQEJBDEiBCAgfPQQUy+SpH3uJFzpsR/3H1eOvXY+s7vqROvQQ9AY+zANBgkqgRzPVQGCLQEFAARIMEYCIQCD6gUt9xNPR4NPbQvZF+iSszG/F65DT684w7aluOvoMAIhAK/cACK7Jf7vVyj8T4nHeTgaCa5VE6+n+b8n8sw7z4S5AAAAAAAA");
        p7Signature1.setSignatureDataType(DataType.BASE64);
        p7Signature1.setData("123456");
        p7Signature1.setDataType(DataType.ORIGINAL);
        p7Signatures.add(p7Signature1);

        //签名值对象2
        P7VerifyBatchRequest.P7Signature p7Signature2 = new P7VerifyBatchRequest.P7Signature();
        p7Signature2.setSignature("MIAGCiqBHM9VBgEEAgKggDCAAgEDMQ4wDAYIKoEcz1UBgxEFADCABgoqgRzPVQYBBAIBAACggDCCAmswggISoAMCAQICDQCT0vDryDrhJKUCW4E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BQAERzBFAiAzt99qaWainzKpWVufi5DPKZ5vNSqX6OonchU3EdsErgIhALV3uM1gQ0CpaMSSoRbmefcV5nzIUKSfpIiaMFNaYlyuAAAAAAAA");
        p7Signature2.setData("321");
        p7Signature2.setDataType(DataType.ORIGINAL);
        p7Signatures.add(p7Signature2);

        //设置签名值集合
        request.setP7SignatureList(p7Signatures);

        //是否返回证书
        request.setReturnCert(false);

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

    }

//    public static void main(String[] args) {
//        List<P7VerifyBatchRequest.P7Signature> p7SignatureList = new ArrayList<>();
//        p7SignatureList.add(new P7VerifyBatchRequest.P7Signature("123",DataType.ORIGINAL,"MTlz",DataType.BASE64));
//        p7SignatureList.add(new P7VerifyBatchRequest.P7Signature("abc123ABC",DataType.ORIGINAL,"MTlz",DataType.BASE64));
//        p7SignatureList.add(new P7VerifyBatchRequest.P7Signature("!@#$%^&*(){}:\"<>?/.,';]['",DataType.ORIGINAL,"MTlz",DataType.BASE64));
//        System.out.println(ApiUtils.objectToJson(p7SignatureList));
//    }

}
