package com.yunniu.farming.test.wxTest;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.InputStream;

public class WxPayConfigImpl {


    private byte[] certData = null;

    public WxPayConfigImpl() {
        try {
            //这个证书的位置不是瞎鸡儿填的，你要在这个路径真的有一个证书
            InputStream is = new FileInputStream("/www/wwwroot/minsu/cret/apiclient_cert.p12");
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            byte[] bs = new byte[1024];
            int cnt = -1;
            while ((cnt = is.read(bs)) != -1) {
                baos.write(bs, 0, cnt);
            }
            is.close();
            certData = baos.toByteArray();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public String getAppID() {
        return "APPID";
    }

    public String getMchID() {
        return "商户号";
    }

    public String getKey() {
        return "KEY";
    }

    public InputStream getCertStream() {
        ByteArrayInputStream certBis;
        certBis = new ByteArrayInputStream(this.certData);
        return certBis;
    }

    public int getHttpConnectTimeoutMs() {
        // TODO Auto-generated method stub
        return 8000;
    }

    public int getHttpReadTimeoutMs() {
        // TODO Auto-generated method stub
        return 10000;
    }


}
