Example #1
0
        public string GetData(int sr_id, int datakeyid, string receiver_key, string sender_fname, string sender_lname, string sender_email)
        {
            DBOperations db = new DBOperations();
            ReadFile     r  = new ReadFile();
            string       myclouddata;
            string       resValidation = db.ValidateUserData(sr_id, datakeyid, receiver_key, sender_fname, sender_lname, sender_email);

            if (resValidation.Equals("success"))
            {
                string datakey         = db.GetDataKey(datakeyid);
                string servicetype     = db.GetServiceType(datakeyid);
                byte[] getencryptedmsg = null;
                if (servicetype.Equals("A"))
                {
                    getencryptedmsg = DownloadDataFromCloud(datakeyid);//aws
                }
                else if (servicetype.Equals("Z"))
                {
                    getencryptedmsg = b.downloadAzuereData(datakeyid); //azure
                }
                else if (servicetype.Equals("C"))
                {
                    getencryptedmsg = c.downloadCycladeData(datakeyid); //cyclade
                }
                else
                {
                    getencryptedmsg = db.GetEncryptedMsg(datakeyid); //getting encrypted data from local sql when testing on localhost
                }
                myclouddata = r.GetDecryptedData(getencryptedmsg, datakey);
                if (myclouddata.Contains("failure"))
                {
                    return("failure");
                }
                else
                {
                    return(myclouddata);
                }
            }
            else
            {
                return("failure");
            }
        }
Example #2
0
        internal void SaveSRAllocation(tbl_SR_allocation tbl_SR_allocation)
        {
            DBOperations dbo = new DBOperations();
            DBModel      db  = new DBModel();
            ReceiverInfo r   = new ReceiverInfo();
            ReadFile     rf  = new ReadFile();

            r.datakeyid = Convert.ToString(tbl_SR_allocation.tbldatakey_id);
            r.senderid  = Convert.ToString(tbl_SR_allocation.sender_id);
            tbl_receiverinfo receiverInfo = db.tbl_receiverinfo.Where(x => x.receiver_id == tbl_SR_allocation.receiver_id).FirstOrDefault();

            r.receiverEmail = receiverInfo.receiver_email;
            r.receiverName  = receiverInfo.receiver_name;
            int    tempn       = rf.GenerateN(r);
            int    n           = rf.ValidateTempN(tempn, tbl_SR_allocation.tbldatakey_id);
            string senderattr  = db.tbl_senderinfo.Where(x => x.sender_id == tbl_SR_allocation.sender_id).Select(x => x.sender_attribute).FirstOrDefault().ToString();
            string receiverKey = rf.GenerateReceiverKey(n, senderattr);

            tbl_SR_allocation.receiver_key = receiverKey;
            dbo.SaveReceiverKeyOnServer(tbl_SR_allocation);
            SendEmailToReceiver(receiverKey, r.receiverEmail, tbl_SR_allocation);
        }