Пример #1
0
        string SignL2(ApiUtilLib.HttpMethod httpMethod)
        {
            var authPrefix = _type == GatewayType.PROXY ? "Apex_l2_eg" : "Apex_l2_ig";
            var path       = GetLocalPath(_certFileName);
            var privateKey = ApiAuthorization.PrivateKeyFromP12(path, _certPassPhrase);

            return(ApiAuthorization.Token(realm:  _realm, authPrefix: authPrefix, httpMethod: httpMethod,
                                          urlPath: new Uri(_signingUrlPath), appId: _appId, privateKey: privateKey));
        }
        public void Test_L2_Wrong_Password_Test()
        {
            Assert.Throws <System.Security.Cryptography.CryptographicException>(() =>
            {
                var myPrivateKey = ApiAuthorization.PrivateKeyFromP12(privateCertNameP12, passphrase + "x");

                ApiAuthorization.Token(
                    realm
                    , authPrefixL2
                    , httpMethod
                    , url
                    , appId
                    , privateKey: myPrivateKey
                    );
            });
        }
        public void Test_L2_Not_Supported_Cert_Test()
        {
            var fileName = GetLocalPath("Certificates/ssc.alpha.example.com.pem");

            Assert.Throws <System.ArgumentNullException>(() =>
            {
                var myPrivateKey = ApiAuthorization.PrivateKeyFromP12(fileName, passphrase);

                ApiAuthorization.Token(
                    realm
                    , authPrefixL2
                    , httpMethod
                    , url
                    , appId
                    , privateKey: myPrivateKey
                    );
            });
        }
        public void Test_L2_Invalid_FileName_Test()
        {
            var fileName = "Xssc.alpha.example.com.p12";

            Assert.Throws <System.IO.FileNotFoundException>(() =>
            {
                var myPrivateKey = ApiAuthorization.PrivateKeyFromP12(fileName, passphrase);

                ApiAuthorization.Token(
                    realm
                    , authPrefixL2
                    , httpMethod
                    , url
                    , appId
                    , privateKey: myPrivateKey
                    );
            });
        }