//generate certificate api
        public static Response GenerateCertificate(Request userInfo, string jsonData)
        {
            if (!RequestHandler.IsRequestNull(userInfo, out string message))
            {
                return(RequestHandler.ErrorResponse("GSP121", message));
            }

            string payload;

            try
            {
                payload = JsonConvert.SerializeObject(new RequestPayload()
                {
                    APIAction     = "RETGENCERT",
                    EncryptedData = CipherHandler.EncryptData(jsonData, userInfo.Keys.SessionKey),
                    HAMCData      = CipherHandler.Hmac(jsonData, userInfo.Keys)
                });
            }
            catch (Exception)
            {
                return(RequestHandler.ErrorResponse("GSP141", "Error encrypting payload"));
            }
            var handler = new RequestHandler(userInfo);
            var url     = UrlHandler.Route(accessGroup.taxpayerapi, version.v1_1, modName.returns_gstr9c);

            return(handler.Put(url, "RETGENCERT", payload));
        }
        //request for extension of authentication token api
        public static Response RequestForExtensionOfAuthToken(Request userInfo)
        {
            if (!RequestHandler.IsRequestNull(userInfo, out string message))
            {
                return(RequestHandler.ErrorResponse("GSP121", message));
            }

            string payload;

            try
            {
                payload = JsonConvert.SerializeObject(new
                {
                    action     = "REFRESHTOKEN",
                    app_key    = CipherHandler.EncryptTextWithGSTNPublicKey(userInfo.Keys.GSTNAppKey),
                    username   = userInfo.Header.Username,
                    auth_token = userInfo.Header.AuthToken
                });
            }
            catch (Exception)
            {
                return(RequestHandler.ErrorResponse("GSP141", "Error encrypting payload"));
            }
            var handler = new RequestHandler(userInfo);
            var url     = UrlHandler.Route(accessGroup.taxpayerapi, version.v0_1, modName.authenticate);

            return(handler.DecryptPostResponse(url, "REFRESHTOKEN", payload));
        }
        //request for authentication token api
        public static AuthResponse RequestForAuthToken(Request userInfo, string otp)
        {
            if (!RequestHandler.IsRequestNull(userInfo, out string message))
            {
                return(RequestHandler.AuthErrorResponse("GSP121", message));
            }

            string payload;

            try
            {
                payload = JsonConvert.SerializeObject(new
                {
                    action   = "AUTHTOKEN",
                    app_key  = CipherHandler.EncryptTextWithGSTNPublicKey(userInfo.Keys.GSTNAppKey),
                    username = userInfo.Header.Username,
                    otp      = CipherHandler.EncryptData(otp, userInfo.Keys.GSTNAppKey)
                });
            }
            catch (Exception)
            {
                return(RequestHandler.AuthErrorResponse("GSP141", "Error encrypting payload"));
            }
            var handler = new RequestHandler(userInfo);

            return(handler.PostAuthResponse(payload));
        }
예제 #4
0
        //log out api
        public static Response Logout(string username, string appKey, string authToken)
        {
            string payload;

            try
            {
                payload = JsonConvert.SerializeObject(new JObject()
                {
                    { "action", "LOGOUT" },
                    { "username", username },
                    { "authtoken", authToken },
                    { "app_key", CipherHandler.EncryptTextWithGSTNPublicKey(appKey) }
                });
            }
            catch (Exception)
            {
                return(RequestHandler.ErrorResponse("GSP141", "Error encrypting payload"));
            }
            var handler = new RequestHandler();

            handler.UserRequest.Header.Username  = username;
            handler.UserRequest.Header.AuthToken = authToken;
            var url = UrlHandler.Route(accessGroup.commonapi, version.v0_2, modName.authenticate);

            return(handler.Post(url, "LOGOUT", payload));
        }
예제 #5
0
        private List <string> MakeTitleList()
        {
            CipherHandler handler = new CipherHandler();
            CipherTable   table   = new CipherTable();

            table = handler.getCiphers();
            List <string> ciphernameList = new List <string>();

            foreach (var item in table.getTable())
            {
                ciphernameList.Add(item.Title);
            }
            return(ciphernameList);
        }
예제 #6
0
        //authentication request api
        public static Response AuthRequest(string username, string password, string appKey)
        {
            string payload;

            try
            {
                payload = JsonConvert.SerializeObject(new JObject()
                {
                    { "action", "ACCESSTOKEN" },
                    { "username", username },
                    { "password", CipherHandler.EncryptData(password, appKey) },
                    { "app_key", CipherHandler.EncryptTextWithGSTNPublicKey(appKey) }
                });
            }
            catch (Exception)
            {
                return(RequestHandler.ErrorResponse("GSP141", "Error encrypting payload"));
            }
            var handler = new RequestHandler();
            var url     = UrlHandler.Route(accessGroup.commonapi, version.v0_2, modName.authenticate);

            return(handler.Post(url, "ACCESSTOKEN", payload));
        }