﻿function HebcaClient() {
    this.clientCtrl = null;
}

HebcaClient.prototype = {
    _GetClientCtrl: function() {
        if (this.clientCtrl)
            return this.clientCtrl;
        else {
            var certMgrObj;
            try {
                certMgrObj = new ActiveXObject("HebcaP11X.CertMgr");
            }
            catch (e) {
                throw Error("没有安装河北CA数字证书客户端软件(包含在证书Ukey内)或IE阻止其运行");
            }
            certMgrObj.Licence = "aWViYx5oZWIcYWhlnWxhaJplY2FoZWJjoKw7gT6hg+O7EtJhfalPbDH9UlE=";
            this.clientCtrl = certMgrObj;
            return this.clientCtrl;
        }
    },

    Sign: function(source) {
        var c = this._GetClientCtrl().SelectSignCert();
        return c.SignText(source, 1);
    },

    GetSignCert: function() {
        return this._GetClientCtrl().SelectSignCert().GetCertB64();
    },

    GetCryptCert: function() {
        return this._GetClientCtrl().SelectEncryptCert().GetCertB64();
    }

};

