Exemple #1
0
        /**
         *注册COM组件,完成token获取、单点登录
         */
        private string GetToken(string gateway_ip)
        {
            string        token = null;
            IPNXDataTrans COM   = null;

            try {
                COM   = new PNXDataTrans();
                token = COM.GetSessionToken(gateway_ip);
            } catch (Exception e) {
                MessageBox.Show(e.Message);
                //TODO release resource
            } finally {
                if (COM.GetLastError() != 0)
                {
                    string errMSG = COM.GetLastErrorMessage();
                }
            }
            return(token);
        }
Exemple #2
0
        /// <summary>
        /// PKCS#7 signature
        /// </summary>
        /// <returns></returns>
        private string signatureP1(string random, bool isDetach, bool isIncludeCert)
        {
            string        siguature = null;
            IPNXDataTrans COM       = null;

            try {
                COM = new PNXDataTrans();
                COM.Initialize("", "<?xml version=\"1.0\" encoding=\"utf-8\"?><authinfo><liblist><lib type=\"SKF\" version=\"1.1\" dllname=\"U2h1dHRsZUNzcDExXzMwMDBHTS5kbGw=\" ><algid val=\"SHA1\" sm2_hashalg=\"SM3\"/></lib><lib type=\"CSP\" version=\"1.0\" dllname=\"RkVJVElBTiBlUGFzc05HIENTUCBGb3IgSklUM0sgVjEuMA==\" ><algid val=\"SHA1\" sm2_hashalg=\"SHA1\"/></lib><lib type=\"CSP\" version=\"1.0\" dllname=\"RW50ZXJTYWZlIGVQYXNzMzAwMyBDU1AgdjEuMA==\" ><algid val=\"SHA1\" sm2_hashalg=\"SHA1\"/></lib><lib type=\"PM\" version=\"1.0\" dllname=\"Q3J5cHRPY3guZGxs\" ><algid val=\"SHA1\" sm2_hashalg=\"SM3\"/></lib><lib type=\"CSP\" version=\"1.0\" dllname=\"RkVJVElBTiBlUGFzc05HIFJTQSBDcnlwdG9ncmFwaGljIFNlcnZpY2UgUHJvdmlkZXI=\" ><algid val=\"SHA1\" sm2_hashalg=\"SHA1\"/></lib><lib type=\"CSP\" version=\"1.0\" dllname=\"SklUIFVTQiBLZXkgQ1NQIHYxLjA=\" ><algid val=\"SHA1\" sm2_hashalg=\"SHA1\"/></lib><lib type=\"CSP\" version=\"1.0\" dllname=\"RW50ZXJTYWZlIGVQYXNzMjAwMSBDU1AgdjEuMA==\" ><algid val=\"SHA1\" sm2_hashalg=\"SHA1\"/></lib><lib type=\"CSP\" version=\"1.0\" dllname=\"SklUIFVTQiBLZXkzMDAzIENTUCB2MS4w\" ><algid val=\"SHA1\" sm2_hashalg=\"SHA1\"/></lib><lib type=\"CSP\" version=\"1.0\" dllname=\"TWljcm9zb2Z0IEVuaGFuY2VkIENyeXB0b2dyYXBoaWMgUHJvdmlkZXIgdjEuMA==\" ><algid val=\"SHA1\" sm2_hashalg=\"SHA1\"/></lib><lib type=\"CSP\" version=\"1.0\" dllname=\"TWljcm9zb2Z0IFN0cm9uZyBDcnlwdG9ncmFwaGljIFByb3ZpZGVy\" ><algid val=\"SHA1\" sm2_hashalg=\"SHA1\"/></lib><lib type=\"CSP\" version=\"1.0\" dllname=\"TWljcm9zb2Z0IEJhc2UgQ3J5cHRvZ3JhcGhpYyBQcm92aWRlciB2MS4w\" ><algid val=\"SHA1\" sm2_hashalg=\"SHA1\"/></lib></liblist></authinfo>");
                siguature = COM.P7SignString(random, isDetach, isIncludeCert);
                if (COM.GetLastError() != 0)
                {
                    //TODO
                    string errMSG = getErrMsg(COM);
                }
            } catch (Exception e) {
                MessageBox.Show(e.Message);
            } finally {
                COM.Finalize();
            }
            return(siguature);
        }