From 7a048fdf8350755b6ece424dc566af3373c36c7c Mon Sep 17 00:00:00 2001 From: dwkim Date: Thu, 24 Mar 2016 05:23:13 +0900 Subject: [PATCH 01/36] updated logger - error log save on ATS update startup - add CloudBreadErrorLog table storage --- CBLoggers.cs | 37 ++++++++++++++++++++++++++++++++++++- Global.asax.cs | 2 ++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/CBLoggers.cs b/CBLoggers.cs index ff61674..de5ef1a 100644 --- a/CBLoggers.cs +++ b/CBLoggers.cs @@ -80,6 +80,41 @@ public static bool RunLog(CBLoggers message) message.memberID = ""; /// in case of non-member triggered job } + /// critical error case, save in ATS CloudBreadErrorLog + if (message.Level.ToUpper() == "ERROR") + { + try + { + /// Save error log on Azure Table Storage + { + /// Azure Table Storage connection retry policy + var tableStorageRetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(2), 10); + CloudStorageAccount storageAccountT = CloudStorageAccount.Parse(globalVal.StorageConnectionString); + CloudTableClient tableClient = storageAccountT.CreateCloudTableClient(); + tableClient.DefaultRequestOptions.RetryPolicy = tableStorageRetryPolicy; + CloudTable table = tableClient.GetTableReference("CloudBreadErrorLog"); + CBATSMessageEntity Message = new CBATSMessageEntity(message.memberID, Guid.NewGuid().ToString()); + Message.jobID = message.jobID; + Message.Date = DateTimeOffset.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); + Message.Thread = message.Thread; + Message.Level = message.Level; + Message.Logger = message.Logger; + Message.Message = message.Message; + Message.Exception = message.Exception; + TableOperation insertOperation = TableOperation.Insert(Message); + table.Execute(insertOperation); + } + } + catch (Exception) + { + /// Catch fail to log on database. Most case database connection or login fail issue. + throw; + } + } + } + else + { + /// Regarding to web.config logger settting, save logs on specific storage try { switch (globalVal.CloudBreadLoggerSetting) @@ -116,7 +151,7 @@ public static bool RunLog(CBLoggers message) CloudTableClient tableClient = storageAccountT.CreateCloudTableClient(); tableClient.DefaultRequestOptions.RetryPolicy = tableStorageRetryPolicy; CloudTable table = tableClient.GetTableReference("CloudBreadLog"); - CBATSMessageEntity Message = new CBATSMessageEntity(message.memberID, Guid.NewGuid().ToString()); //memberid를 파티션키로 쓴다. + CBATSMessageEntity Message = new CBATSMessageEntity(message.memberID, Guid.NewGuid().ToString()); Message.jobID = message.jobID; Message.Date = DateTimeOffset.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); //Message.Date = DateTimeOffset.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ"); diff --git a/Global.asax.cs b/Global.asax.cs index b7d55fa..c33954e 100644 --- a/Global.asax.cs +++ b/Global.asax.cs @@ -39,6 +39,8 @@ protected void Application_Start(object sender, EventArgs e) tableClient.DefaultRequestOptions.RetryPolicy = retryPolicy; var cloudTable = tableClient.GetTableReference("CloudBreadLog"); cloudTable.CreateIfNotExists(); + cloudTable = tableClient.GetTableReference("CloudBreadErrorLog"); + cloudTable.CreateIfNotExists(); /// this queue is used for CloudBread queue method game log saving CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient(); From 556f3d57731036045cefb0c67b15ed3448f2a26c Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 00:36:39 +0900 Subject: [PATCH 02/36] adding crypt feature --- CloudBread.csproj | 6 + .../CBAddMemberItemPurchaseController.cs | 121 ++++++------------ .../CBComSelGiftDepositoryController.cs | 71 +++++----- Controllers/CBComSelItemList1Controller.cs | 78 +++++------ Controllers/CBSelNoticesController.cs | 78 +++++------ DataObjects/globalVal.cs | 7 +- Models/AddMemberItemPurchase.cs | 83 ++++++++++++ Models/ComSelGiftDepository.cs | 33 +++++ Models/ComSelItemList1.cs | 37 ++++++ Models/EncryptedData.cs | 12 ++ Models/RowcountResult.cs | 12 ++ Models/SelNotices.cs | 37 ++++++ 12 files changed, 386 insertions(+), 189 deletions(-) create mode 100644 Models/AddMemberItemPurchase.cs create mode 100644 Models/ComSelGiftDepository.cs create mode 100644 Models/ComSelItemList1.cs create mode 100644 Models/EncryptedData.cs create mode 100644 Models/RowcountResult.cs create mode 100644 Models/SelNotices.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index d6d174b..683b81e 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -286,7 +286,13 @@ Global.asax + + + + + + diff --git a/Controllers/CBAddMemberItemPurchaseController.cs b/Controllers/CBAddMemberItemPurchaseController.cs index 56d90bb..3140bea 100644 --- a/Controllers/CBAddMemberItemPurchaseController.cs +++ b/Controllers/CBAddMemberItemPurchaseController.cs @@ -33,102 +33,42 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBAddMemberItemPurchaseController : ApiController { - - public class InputParams + public HttpResponseMessage Post(AddMemberItemPurchaseInputParams p) { - public string InsertORUpdate { get; set; } - public string MemberItemID_MemberItems { get; set; } - public string MemberID_MemberItems { get; set; } - public string ItemListID_MemberItems { get; set; } - public string ItemCount_MemberItems { get; set; } - public string ItemStatus_MemberItems { get; set; } - public string sCol1_MemberItems { get; set; } - public string sCol2_MemberItems { get; set; } - public string sCol3_MemberItems { get; set; } - public string sCol4_MemberItems { get; set; } - public string sCol5_MemberItems { get; set; } - public string sCol6_MemberItems { get; set; } - public string sCol7_MemberItems { get; set; } - public string sCol8_MemberItems { get; set; } - public string sCol9_MemberItems { get; set; } - public string sCol10_MemberItems { get; set; } - public string MemberID_MemberItemPurchases { get; set; } - public string ItemListID_MemberItemPurchases { get; set; } - public string PurchaseQuantity_MemberItemPurchases { get; set; } - public string PurchasePrice_MemberItemPurchases { get; set; } - public string PGinfo1_MemberItemPurchases { get; set; } - public string PGinfo2_MemberItemPurchases { get; set; } - public string PGinfo3_MemberItemPurchases { get; set; } - public string PGinfo4_MemberItemPurchases { get; set; } - public string PGinfo5_MemberItemPurchases { get; set; } - public string PurchaseDeviceID_MemberItemPurchases { get; set; } - public string PurchaseDeviceIPAddress_MemberItemPurchases { get; set; } - public string PurchaseDeviceMACAddress_MemberItemPurchases { get; set; } - public string PurchaseDT_MemberItemPurchases { get; set; } - public string PurchaseCancelYN_MemberItemPurchases { get; set; } - public string PurchaseCancelDT_MemberItemPurchases { get; set; } - public string PurchaseCancelingStatus_MemberItemPurchases { get; set; } - public string PurchaseCancelReturnedAmount_MemberItemPurchases { get; set; } - public string PurchaseCancelDeviceID_MemberItemPurchases { get; set; } - public string PurchaseCancelDeviceIPAddress_MemberItemPurchases { get; set; } - public string PurchaseCancelDeviceMACAddress_MemberItemPurchases { get; set; } - public string sCol1_MemberItemPurchases { get; set; } - public string sCol2_MemberItemPurchases { get; set; } - public string sCol3_MemberItemPurchases { get; set; } - public string sCol4_MemberItemPurchases { get; set; } - public string sCol5_MemberItemPurchases { get; set; } - public string sCol6_MemberItemPurchases { get; set; } - public string sCol7_MemberItemPurchases { get; set; } - public string sCol8_MemberItemPurchases { get; set; } - public string sCol9_MemberItemPurchases { get; set; } - public string sCol10_MemberItemPurchases { get; set; } - public string MemberID_MemberGameInfoes { get; set; } - public string Level_MemberGameInfoes { get; set; } - public string Exps_MemberGameInfoes { get; set; } - public string Points_MemberGameInfoes { get; set; } - public string UserSTAT1_MemberGameInfoes { get; set; } - public string UserSTAT2_MemberGameInfoes { get; set; } - public string UserSTAT3_MemberGameInfoes { get; set; } - public string UserSTAT4_MemberGameInfoes { get; set; } - public string UserSTAT5_MemberGameInfoes { get; set; } - public string UserSTAT6_MemberGameInfoes { get; set; } - public string UserSTAT7_MemberGameInfoes { get; set; } - public string UserSTAT8_MemberGameInfoes { get; set; } - public string UserSTAT9_MemberGameInfoes { get; set; } - public string UserSTAT10_MemberGameInfoes { get; set; } - public string sCol1_MemberGameInfoes { get; set; } - public string sCol2_MemberGameInfoes { get; set; } - public string sCol3_MemberGameInfoes { get; set; } - public string sCol4_MemberGameInfoes { get; set; } - public string sCol5_MemberGameInfoes { get; set; } - public string sCol6_MemberGameInfoes { get; set; } - public string sCol7_MemberGameInfoes { get; set; } - public string sCol8_MemberGameInfoes { get; set; } - public string sCol9_MemberGameInfoes { get; set; } - public string sCol10_MemberGameInfoes { get; set; } - - - } + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); - public string Post(InputParams p) - { - string result = ""; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID_MemberGameInfoes, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID_MemberGameInfoes, this.User as ClaimsPrincipal); p.MemberID_MemberGameInfoes = sid; p.MemberID_MemberItemPurchases = sid; p.MemberID_MemberItems = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); + RowcountResult rowCountResult = new RowcountResult(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); try { @@ -223,7 +163,7 @@ public string Post(InputParams p) { while (dreader.Read()) { - result = dreader[0].ToString(); + rowCountResult.result = dreader[0].ToString(); } dreader.Close(); } @@ -236,7 +176,24 @@ public string Post(InputParams p) logMessage.Message = jsonParam; Logging.RunLog(logMessage); - return result; + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowCountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, rowCountResult); + return response; } } diff --git a/Controllers/CBComSelGiftDepositoryController.cs b/Controllers/CBComSelGiftDepositoryController.cs index 955dd9b..28bb2e7 100644 --- a/Controllers/CBComSelGiftDepositoryController.cs +++ b/Controllers/CBComSelGiftDepositoryController.cs @@ -30,6 +30,7 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { @@ -37,43 +38,33 @@ namespace CloudBread.Controllers public class CBComSelGiftDepositoryController : ApiController { - public class InputParams { - public string MemberID; // log purpose - public string GiftDepositoryID; - } - - public class Model + public HttpResponseMessage Post(ComSelGiftDepositoryInputParams p) { - public string GiftDepositoryID { get; set; } - public string ItemListID { get; set; } - public string ItemCount { get; set; } - public string FromMemberID { get; set; } - public string ToMemberID { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - - - } + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); - public List Post(InputParams p) - { + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); - List result = new List(); + List result = new List(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); try { @@ -92,7 +83,7 @@ public List Post(InputParams p) { while (dreader.Read()) { - Model workItem = new Model() + ComSelGiftDepositoryModel workItem = new ComSelGiftDepositoryModel() { GiftDepositoryID = dreader[0].ToString(), ItemListID = dreader[1].ToString(), @@ -117,7 +108,25 @@ public List Post(InputParams p) } connection.Close(); } - return result; + + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(result), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, result); + return response; } } diff --git a/Controllers/CBComSelItemList1Controller.cs b/Controllers/CBComSelItemList1Controller.cs index 813311f..8325860 100644 --- a/Controllers/CBComSelItemList1Controller.cs +++ b/Controllers/CBComSelItemList1Controller.cs @@ -31,53 +31,41 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBComSelItemList1Controller : ApiController { - - public class InputParams { - public string MemberID; // log purpose - public string ItemListID; - } - - public class Model + public HttpResponseMessage Post(ComSelItemList1InputParams p) { - public string ItemListID { get; set; } - public string ItemName { get; set; } - public string ItemDescription { get; set; } - public string ItemPrice { get; set; } - public string ItemSellPrice { get; set; } - public string ItemCategory1 { get; set; } - public string ItemCategory2 { get; set; } - public string ItemCategory3 { get; set; } - //public string IteamCreateAdminID { get; set; } - //public string IteamUpdateAdminID { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - } + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } - public List Post(InputParams p) - { // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); - List result = new List(); + List result = new List(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); try { @@ -95,7 +83,7 @@ public List Post(InputParams p) { while (dreader.Read()) { - Model workItem = new Model() + ComSelItemList1Model workItem = new ComSelItemList1Model() { ItemListID = dreader[0].ToString(), ItemName = dreader[1].ToString(), @@ -105,8 +93,6 @@ public List Post(InputParams p) ItemCategory1 = dreader[5].ToString(), ItemCategory2 = dreader[6].ToString(), ItemCategory3 = dreader[7].ToString(), - //IteamCreateAdminID = dreader[8].ToString(), - //IteamUpdateAdminID = dreader[9].ToString(), sCol1 = dreader[8].ToString(), sCol2 = dreader[9].ToString(), sCol3 = dreader[10].ToString(), @@ -124,7 +110,25 @@ public List Post(InputParams p) } connection.Close(); } - return result; + + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(result), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, result); + return response; } } diff --git a/Controllers/CBSelNoticesController.cs b/Controllers/CBSelNoticesController.cs index 55c8379..422583a 100644 --- a/Controllers/CBSelNoticesController.cs +++ b/Controllers/CBSelNoticesController.cs @@ -31,56 +31,42 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBSelNoticesController : ApiController { - - public class InputParams { - public string MemberID; // log tasking purpose - } - - public class Model + //public List Post(InputParams p) + public HttpResponseMessage Post(SelNoticesInputParams p) { - public string NoticeID { get; set; } - public string NoticeCategory1 { get; set; } - public string NoticeCategory2 { get; set; } - public string NoticeCategory3 { get; set; } - public string TargetGroup { get; set; } - public string TargetOS { get; set; } - public string TargetDevice { get; set; } - public string NoticeImageLink { get; set; } - public string title { get; set; } - public string content { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); - } + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } - public List Post(InputParams p) - { - //string sid = ""; // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - //claimsPrincipal.GetType - //string sid = claimsPrincipal == null ? p.MemberID : CBAuth.getSID(claimsPrincipal); - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); - List result = new List(); + List result = new List(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); try { @@ -97,7 +83,7 @@ public List Post(InputParams p) { while (dreader.Read()) { - Model workItem = new Model() + SelNoticesModel workItem = new SelNoticesModel() { NoticeID = dreader[0].ToString(), NoticeCategory1 = dreader[1].ToString(), @@ -126,7 +112,25 @@ public List Post(InputParams p) } connection.Close(); } - return result; + + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(result), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, result); + return response; } } diff --git a/DataObjects/globalVal.cs b/DataObjects/globalVal.cs index 6c15d49..ac218fd 100644 --- a/DataObjects/globalVal.cs +++ b/DataObjects/globalVal.cs @@ -11,8 +11,11 @@ public static class globalVal { public static string DBConnectionString = ConfigurationManager.ConnectionStrings["CloudBreadDBConString"].ConnectionString; public static string StorageConnectionString = ConfigurationManager.ConnectionStrings["CloudBreadStorageConString"].ConnectionString; - public static string CloudBreadLoggerSetting = ConfigurationManager.AppSettings["CloudBreadLoggerSetting"].ToString(); - public static string CloudBreadCryptSetting = ConfigurationManager.AppSettings["CloudBreadCryptSetting"].ToString(); + public static string CloudBreadLoggerSetting = ConfigurationManager.AppSettings["CloudBreadLoggerSetting"]; + public static string CloudBreadCryptSetting = ConfigurationManager.AppSettings["CloudBreadCryptSetting"]; + public static string CloudBreadCryptKey = ConfigurationManager.AppSettings["CloudBreadCryptKey"]; /// adding v2.0.0 + public static string CloudBreadCryptIV = ConfigurationManager.AppSettings["CloudBreadCryptIV"]; /// adding v2.0.0 + public static int conRetryCount = int.Parse(ConfigurationManager.AppSettings["CloudBreadconRetryCount"]); /// adding v2.0.0 public static int conRetryFromSeconds = int.Parse(ConfigurationManager.AppSettings["CloudBreadconRetryFromSeconds"]); /// adding v2.0.0 public static string CloudBreadSocketKeyText = ConfigurationManager.AppSettings["CloudBreadSocketKeyText"]; /// adding v2.0.0 diff --git a/Models/AddMemberItemPurchase.cs b/Models/AddMemberItemPurchase.cs new file mode 100644 index 0000000..699e4c6 --- /dev/null +++ b/Models/AddMemberItemPurchase.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class AddMemberItemPurchaseInputParams + { + public string InsertORUpdate { get; set; } + public string MemberItemID_MemberItems { get; set; } + public string MemberID_MemberItems { get; set; } + public string ItemListID_MemberItems { get; set; } + public string ItemCount_MemberItems { get; set; } + public string ItemStatus_MemberItems { get; set; } + public string sCol1_MemberItems { get; set; } + public string sCol2_MemberItems { get; set; } + public string sCol3_MemberItems { get; set; } + public string sCol4_MemberItems { get; set; } + public string sCol5_MemberItems { get; set; } + public string sCol6_MemberItems { get; set; } + public string sCol7_MemberItems { get; set; } + public string sCol8_MemberItems { get; set; } + public string sCol9_MemberItems { get; set; } + public string sCol10_MemberItems { get; set; } + public string MemberID_MemberItemPurchases { get; set; } + public string ItemListID_MemberItemPurchases { get; set; } + public string PurchaseQuantity_MemberItemPurchases { get; set; } + public string PurchasePrice_MemberItemPurchases { get; set; } + public string PGinfo1_MemberItemPurchases { get; set; } + public string PGinfo2_MemberItemPurchases { get; set; } + public string PGinfo3_MemberItemPurchases { get; set; } + public string PGinfo4_MemberItemPurchases { get; set; } + public string PGinfo5_MemberItemPurchases { get; set; } + public string PurchaseDeviceID_MemberItemPurchases { get; set; } + public string PurchaseDeviceIPAddress_MemberItemPurchases { get; set; } + public string PurchaseDeviceMACAddress_MemberItemPurchases { get; set; } + public string PurchaseDT_MemberItemPurchases { get; set; } + public string PurchaseCancelYN_MemberItemPurchases { get; set; } + public string PurchaseCancelDT_MemberItemPurchases { get; set; } + public string PurchaseCancelingStatus_MemberItemPurchases { get; set; } + public string PurchaseCancelReturnedAmount_MemberItemPurchases { get; set; } + public string PurchaseCancelDeviceID_MemberItemPurchases { get; set; } + public string PurchaseCancelDeviceIPAddress_MemberItemPurchases { get; set; } + public string PurchaseCancelDeviceMACAddress_MemberItemPurchases { get; set; } + public string sCol1_MemberItemPurchases { get; set; } + public string sCol2_MemberItemPurchases { get; set; } + public string sCol3_MemberItemPurchases { get; set; } + public string sCol4_MemberItemPurchases { get; set; } + public string sCol5_MemberItemPurchases { get; set; } + public string sCol6_MemberItemPurchases { get; set; } + public string sCol7_MemberItemPurchases { get; set; } + public string sCol8_MemberItemPurchases { get; set; } + public string sCol9_MemberItemPurchases { get; set; } + public string sCol10_MemberItemPurchases { get; set; } + public string MemberID_MemberGameInfoes { get; set; } + public string Level_MemberGameInfoes { get; set; } + public string Exps_MemberGameInfoes { get; set; } + public string Points_MemberGameInfoes { get; set; } + public string UserSTAT1_MemberGameInfoes { get; set; } + public string UserSTAT2_MemberGameInfoes { get; set; } + public string UserSTAT3_MemberGameInfoes { get; set; } + public string UserSTAT4_MemberGameInfoes { get; set; } + public string UserSTAT5_MemberGameInfoes { get; set; } + public string UserSTAT6_MemberGameInfoes { get; set; } + public string UserSTAT7_MemberGameInfoes { get; set; } + public string UserSTAT8_MemberGameInfoes { get; set; } + public string UserSTAT9_MemberGameInfoes { get; set; } + public string UserSTAT10_MemberGameInfoes { get; set; } + public string sCol1_MemberGameInfoes { get; set; } + public string sCol2_MemberGameInfoes { get; set; } + public string sCol3_MemberGameInfoes { get; set; } + public string sCol4_MemberGameInfoes { get; set; } + public string sCol5_MemberGameInfoes { get; set; } + public string sCol6_MemberGameInfoes { get; set; } + public string sCol7_MemberGameInfoes { get; set; } + public string sCol8_MemberGameInfoes { get; set; } + public string sCol9_MemberGameInfoes { get; set; } + public string sCol10_MemberGameInfoes { get; set; } + public string token { get; set; } + + } +} \ No newline at end of file diff --git a/Models/ComSelGiftDepository.cs b/Models/ComSelGiftDepository.cs new file mode 100644 index 0000000..0324424 --- /dev/null +++ b/Models/ComSelGiftDepository.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class ComSelGiftDepositoryInputParams + { + public string MemberID; // log purpose + public string GiftDepositoryID; + public string token; + } + + public class ComSelGiftDepositoryModel + { + public string GiftDepositoryID { get; set; } + public string ItemListID { get; set; } + public string ItemCount { get; set; } + public string FromMemberID { get; set; } + public string ToMemberID { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + } +} \ No newline at end of file diff --git a/Models/ComSelItemList1.cs b/Models/ComSelItemList1.cs new file mode 100644 index 0000000..605ef93 --- /dev/null +++ b/Models/ComSelItemList1.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class ComSelItemList1InputParams + { + public string MemberID; // log purpose + public string ItemListID; + public string token; + } + + public class ComSelItemList1Model + { + public string ItemListID { get; set; } + public string ItemName { get; set; } + public string ItemDescription { get; set; } + public string ItemPrice { get; set; } + public string ItemSellPrice { get; set; } + public string ItemCategory1 { get; set; } + public string ItemCategory2 { get; set; } + public string ItemCategory3 { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + } + +} \ No newline at end of file diff --git a/Models/EncryptedData.cs b/Models/EncryptedData.cs new file mode 100644 index 0000000..d8a89ea --- /dev/null +++ b/Models/EncryptedData.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class EncryptedData + { + public string token { get; set; } + } +} \ No newline at end of file diff --git a/Models/RowcountResult.cs b/Models/RowcountResult.cs new file mode 100644 index 0000000..3e5c8ae --- /dev/null +++ b/Models/RowcountResult.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class RowcountResult + { + public string result { get; set; } + } +} \ No newline at end of file diff --git a/Models/SelNotices.cs b/Models/SelNotices.cs new file mode 100644 index 0000000..38e69b4 --- /dev/null +++ b/Models/SelNotices.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class SelNoticesInputParams + { + public string MemberID { get; set; } // log tasking purpose + public string token { get; set; } + } + + public class SelNoticesModel + { + public string NoticeID { get; set; } + public string NoticeCategory1 { get; set; } + public string NoticeCategory2 { get; set; } + public string NoticeCategory3 { get; set; } + public string TargetGroup { get; set; } + public string TargetOS { get; set; } + public string TargetDevice { get; set; } + public string NoticeImageLink { get; set; } + public string title { get; set; } + public string content { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + } +} \ No newline at end of file From ee184b4834a1e31183af87c36beb4dcd5257e5b2 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 00:41:17 +0900 Subject: [PATCH 03/36] add crypt CBComSelMemberController --- CloudBread.csproj | 1 + Controllers/CBComSelMemberController.cs | 91 +++++++++++-------------- Models/ComSelMember.cs | 54 +++++++++++++++ 3 files changed, 95 insertions(+), 51 deletions(-) create mode 100644 Models/ComSelMember.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index 683b81e..74c924f 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -289,6 +289,7 @@ + diff --git a/Controllers/CBComSelMemberController.cs b/Controllers/CBComSelMemberController.cs index 989c82f..90e8521 100644 --- a/Controllers/CBComSelMemberController.cs +++ b/Controllers/CBComSelMemberController.cs @@ -29,70 +29,41 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBComSelMemberController : ApiController { - - public class InputParams { - public string memberID; - } - - public class Model + public HttpResponseMessage Post(ComSelMemberInputParams p) { - public string MemberID { get; set; } - public string MemberPWD { get; set; } - public string EmailAddress { get; set; } - public string EmailConfirmedYN { get; set; } - public string PhoneNumber1 { get; set; } - public string PhoneNumber2 { get; set; } - public string PINumber { get; set; } - public string Name1 { get; set; } - public string Name2 { get; set; } - public string Name3 { get; set; } - public string DOB { get; set; } - public string RecommenderID { get; set; } - public string MemberGroup { get; set; } - public string LastDeviceID { get; set; } - public string LastIPaddress { get; set; } - public string LastLoginDT { get; set; } - public string LastLogoutDT { get; set; } - public string LastMACAddress { get; set; } - public string AccountBlockYN { get; set; } - public string AccountBlockEndDT { get; set; } - public string AnonymousYN { get; set; } - public string _3rdAuthProvider { get; set; } - public string _3rdAuthID { get; set; } - public string _3rdAuthParam { get; set; } - public string PushNotificationID { get; set; } - public string PushNotificationProvider { get; set; } - public string PushNotificationGroup { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); - } + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } - public List Post(InputParams p) - { // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.memberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.memberID, this.User as ClaimsPrincipal); p.memberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); - List result = new List(); + List result = new List(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); try { @@ -110,7 +81,7 @@ public List Post(InputParams p) { while (dreader.Read()) { - Model workItem = new Model() + ComSelMemberModel workItem = new ComSelMemberModel() { MemberID = dreader[0].ToString(), MemberPWD = dreader[1].ToString(), @@ -159,7 +130,25 @@ public List Post(InputParams p) } connection.Close(); } - return result; + + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(result), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, result); + return response; } } diff --git a/Models/ComSelMember.cs b/Models/ComSelMember.cs new file mode 100644 index 0000000..bb3c2db --- /dev/null +++ b/Models/ComSelMember.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class ComSelMemberInputParams + { + public string memberID; + public string token; + } + + public class ComSelMemberModel + { + public string MemberID { get; set; } + public string MemberPWD { get; set; } + public string EmailAddress { get; set; } + public string EmailConfirmedYN { get; set; } + public string PhoneNumber1 { get; set; } + public string PhoneNumber2 { get; set; } + public string PINumber { get; set; } + public string Name1 { get; set; } + public string Name2 { get; set; } + public string Name3 { get; set; } + public string DOB { get; set; } + public string RecommenderID { get; set; } + public string MemberGroup { get; set; } + public string LastDeviceID { get; set; } + public string LastIPaddress { get; set; } + public string LastLoginDT { get; set; } + public string LastLogoutDT { get; set; } + public string LastMACAddress { get; set; } + public string AccountBlockYN { get; set; } + public string AccountBlockEndDT { get; set; } + public string AnonymousYN { get; set; } + public string _3rdAuthProvider { get; set; } + public string _3rdAuthID { get; set; } + public string _3rdAuthParam { get; set; } + public string PushNotificationID { get; set; } + public string PushNotificationProvider { get; set; } + public string PushNotificationGroup { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + } +} \ No newline at end of file From 56c5472abd1d05bed9fe6d67fb59f471e1319c07 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 00:50:27 +0900 Subject: [PATCH 04/36] adding crypt CBComSelMemberGameInfoesController --- CloudBread.csproj | 1 + .../CBComSelMemberGameInfoesController.cs | 76 ++++++++++--------- Models/ComSelMemberGameInfoes.cs | 41 ++++++++++ 3 files changed, 82 insertions(+), 36 deletions(-) create mode 100644 Models/ComSelMemberGameInfoes.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index 74c924f..8f6dfe7 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -290,6 +290,7 @@ + diff --git a/Controllers/CBComSelMemberGameInfoesController.cs b/Controllers/CBComSelMemberGameInfoesController.cs index f9811ac..028a089 100644 --- a/Controllers/CBComSelMemberGameInfoesController.cs +++ b/Controllers/CBComSelMemberGameInfoesController.cs @@ -30,55 +30,41 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBComSelMemberGameInfoesController : ApiController { - - public class InputParams { public string MemberID;} - - public class Model + public HttpResponseMessage Post(ComSelMemberGameInfoesInputParams p) { - public string MemberID { get; set; } - public string Level { get; set; } - public string Exps { get; set; } - public string Points { get; set; } - public string UserSTAT1 { get; set; } - public string UserSTAT2 { get; set; } - public string UserSTAT3 { get; set; } - public string UserSTAT4 { get; set; } - public string UserSTAT5 { get; set; } - public string UserSTAT6 { get; set; } - public string UserSTAT7 { get; set; } - public string UserSTAT8 { get; set; } - public string UserSTAT9 { get; set; } - public string UserSTAT10 { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); - } + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } - public List Post(InputParams p) - { // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); - List result = new List(); + List result = new List(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); try { @@ -96,7 +82,7 @@ public List Post(InputParams p) { while (dreader.Read()) { - Model workItem = new Model() + ComSelMemberGameInfoesModel workItem = new ComSelMemberGameInfoesModel() { MemberID = dreader[0].ToString(), Level = dreader[1].ToString(), @@ -130,7 +116,25 @@ public List Post(InputParams p) } connection.Close(); } - return result; + + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(result), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, result); + return response; } } diff --git a/Models/ComSelMemberGameInfoes.cs b/Models/ComSelMemberGameInfoes.cs new file mode 100644 index 0000000..e213135 --- /dev/null +++ b/Models/ComSelMemberGameInfoes.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class ComSelMemberGameInfoesInputParams + { + public string MemberID { get; set; } + public string token { get; set; } + } + + public class ComSelMemberGameInfoesModel + { + public string MemberID { get; set; } + public string Level { get; set; } + public string Exps { get; set; } + public string Points { get; set; } + public string UserSTAT1 { get; set; } + public string UserSTAT2 { get; set; } + public string UserSTAT3 { get; set; } + public string UserSTAT4 { get; set; } + public string UserSTAT5 { get; set; } + public string UserSTAT6 { get; set; } + public string UserSTAT7 { get; set; } + public string UserSTAT8 { get; set; } + public string UserSTAT9 { get; set; } + public string UserSTAT10 { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + } +} \ No newline at end of file From 63129212bfc1aec649f12056da0edd233897a80c Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 00:57:44 +0900 Subject: [PATCH 05/36] adding crypt CBComSelMemberGameInfoStagesController --- CloudBread.csproj | 1 + .../CBComSelMemberGameInfoStagesController.cs | 83 +++++++++---------- Models/ComSelMemberGameInfoStages.cs | 46 ++++++++++ 3 files changed, 87 insertions(+), 43 deletions(-) create mode 100644 Models/ComSelMemberGameInfoStages.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index 8f6dfe7..4eb0e2e 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -291,6 +291,7 @@ + diff --git a/Controllers/CBComSelMemberGameInfoStagesController.cs b/Controllers/CBComSelMemberGameInfoStagesController.cs index 731e731..5e3df4a 100644 --- a/Controllers/CBComSelMemberGameInfoStagesController.cs +++ b/Controllers/CBComSelMemberGameInfoStagesController.cs @@ -30,61 +30,40 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBComSelMemberGameInfoStagesController : ApiController { - - public class InputParams { - public string MemberID { get; set; } // log purpose - public string MemberGameInfoStageID { get; set; } - } - - public class Model + public HttpResponseMessage Post(ComSelMemberGameInfoStagesInputParams p) { - public string MemberGameInfoStageID { get; set; } - public string MemberID { get; set; } - public string StageName { get; set; } - public string StageStatus { get; set; } - public string Category1 { get; set; } - public string Category2 { get; set; } - public string Category3 { get; set; } - public string Mission1 { get; set; } - public string Mission2 { get; set; } - public string Mission3 { get; set; } - public string Mission4 { get; set; } - public string Mission5 { get; set; } - public string Points { get; set; } - public string StageStat1 { get; set; } - public string StageStat2 { get; set; } - public string StageStat3 { get; set; } - public string StageStat4 { get; set; } - public string StageStat5 { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - } + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } - public List Post(InputParams p) - { // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); - List result = new List(); + List result = new List(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); try { @@ -103,7 +82,7 @@ public List Post(InputParams p) { while (dreader.Read()) { - Model workItem = new Model() + ComSelMemberGameInfoStagesModel workItem = new ComSelMemberGameInfoStagesModel() { MemberGameInfoStageID = dreader[0].ToString(), MemberID = dreader[1].ToString(), @@ -140,7 +119,25 @@ public List Post(InputParams p) } connection.Close(); } - return result; + + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(result), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, result); + return response; } } diff --git a/Models/ComSelMemberGameInfoStages.cs b/Models/ComSelMemberGameInfoStages.cs new file mode 100644 index 0000000..e54b0a1 --- /dev/null +++ b/Models/ComSelMemberGameInfoStages.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class ComSelMemberGameInfoStagesInputParams + { + public string MemberID { get; set; } // log purpose + public string MemberGameInfoStageID { get; set; } + public string token { get; set; } + } + + public class ComSelMemberGameInfoStagesModel + { + public string MemberGameInfoStageID { get; set; } + public string MemberID { get; set; } + public string StageName { get; set; } + public string StageStatus { get; set; } + public string Category1 { get; set; } + public string Category2 { get; set; } + public string Category3 { get; set; } + public string Mission1 { get; set; } + public string Mission2 { get; set; } + public string Mission3 { get; set; } + public string Mission4 { get; set; } + public string Mission5 { get; set; } + public string Points { get; set; } + public string StageStat1 { get; set; } + public string StageStat2 { get; set; } + public string StageStat3 { get; set; } + public string StageStat4 { get; set; } + public string StageStat5 { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + } +} \ No newline at end of file From 04955e5bfbad930a5c10d3ac01b229ba2a1ab3eb Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 01:11:12 +0900 Subject: [PATCH 06/36] adding crypt CBComSelMemberItemController --- CloudBread.csproj | 1 + Controllers/CBComSelMemberItemController.cs | 69 ++++++++++++--------- Models/ComSelMemberItem.cs | 33 ++++++++++ 3 files changed, 74 insertions(+), 29 deletions(-) create mode 100644 Models/ComSelMemberItem.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index 4eb0e2e..4436ece 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -292,6 +292,7 @@ + diff --git a/Controllers/CBComSelMemberItemController.cs b/Controllers/CBComSelMemberItemController.cs index aeff5f9..f48c5fc 100644 --- a/Controllers/CBComSelMemberItemController.cs +++ b/Controllers/CBComSelMemberItemController.cs @@ -30,47 +30,40 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBComSelMemberItemController : ApiController { - public class InputParams { - public string MemberID; // log purpose - public string MemberItemID; - } - - public class Model + public HttpResponseMessage Post(ComSelMemberItemInputParams p) { - public string MemberItemID { get; set; } - public string MemberID { get; set; } - public string ItemListID { get; set; } - public string ItemCount { get; set; } - public string ItemStatus { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - } + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } - public List Post(InputParams p) - { // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); - List result = new List(); + List result = new List(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); try { @@ -89,7 +82,7 @@ public List Post(InputParams p) { while (dreader.Read()) { - Model workItem = new Model() + ComSelMemberItemModel workItem = new ComSelMemberItemModel() { MemberItemID = dreader[0].ToString(), MemberID = dreader[1].ToString(), @@ -113,7 +106,25 @@ public List Post(InputParams p) } connection.Close(); } - return result; + + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(result), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, result); + return response; } } diff --git a/Models/ComSelMemberItem.cs b/Models/ComSelMemberItem.cs new file mode 100644 index 0000000..527d267 --- /dev/null +++ b/Models/ComSelMemberItem.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class ComSelMemberItemInputParams + { + public string MemberID { get; set; } // log purpose + public string MemberItemID { get; set; } + public string token { get; set; } + } + + public class ComSelMemberItemModel + { + public string MemberItemID { get; set; } + public string MemberID { get; set; } + public string ItemListID { get; set; } + public string ItemCount { get; set; } + public string ItemStatus { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + } +} \ No newline at end of file From c51e0669af99c5450b96b62bec4209c96a402a0b Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 01:17:27 +0900 Subject: [PATCH 07/36] adding crypt CBComSelMemberItemPurchaseController --- CloudBread.csproj | 1 + .../CBComSelMemberItemPurchaseController.cs | 87 +++++++++---------- Models/ComSelMemberItemPurchase.cs | 49 +++++++++++ 3 files changed, 90 insertions(+), 47 deletions(-) create mode 100644 Models/ComSelMemberItemPurchase.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index 4436ece..65dddc0 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -293,6 +293,7 @@ + diff --git a/Controllers/CBComSelMemberItemPurchaseController.cs b/Controllers/CBComSelMemberItemPurchaseController.cs index bf659ab..2c0bf33 100644 --- a/Controllers/CBComSelMemberItemPurchaseController.cs +++ b/Controllers/CBComSelMemberItemPurchaseController.cs @@ -30,65 +30,40 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBComSelMemberItemPurchaseController : ApiController { - - public class InputParams { - public string MemberID; // log purpose - public string MemberItemPurchaseID; - } - - public class Model + public HttpResponseMessage Post(ComSelMemberItemPurchaseInputParams p) { - public string MemberItemPurchaseID { get; set; } - public string MemberID { get; set; } - public string ItemListID { get; set; } - public string PurchaseQuantity { get; set; } - public string PurchasePrice { get; set; } - public string PGinfo1 { get; set; } - public string PGinfo2 { get; set; } - public string PGinfo3 { get; set; } - public string PGinfo4 { get; set; } - public string PGinfo5 { get; set; } - public string PurchaseDeviceID { get; set; } - public string PurchaseDeviceIPAddress { get; set; } - public string PurchaseDeviceMACAddress { get; set; } - public string PurchaseDT { get; set; } - public string PurchaseCancelYN { get; set; } - public string PurchaseCancelDT { get; set; } - public string PurchaseCancelingStatus { get; set; } - public string PurchaseCancelReturnedAmount { get; set; } - public string PurchaseCancelDeviceID { get; set; } - public string PurchaseCancelDeviceIPAddress { get; set; } - public string PurchaseCancelDeviceMACAddress { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - - } + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } - public List Post(InputParams p) - { // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); - List result = new List(); + List result = new List(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); try { @@ -107,7 +82,7 @@ public List Post(InputParams p) { while (dreader.Read()) { - Model workItem = new Model() + ComSelMemberItemPurchaseModel workItem = new ComSelMemberItemPurchaseModel() { MemberItemPurchaseID = dreader[0].ToString(), MemberID = dreader[1].ToString(), @@ -148,7 +123,25 @@ public List Post(InputParams p) } connection.Close(); } - return result; + + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(result), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, result); + return response; } } diff --git a/Models/ComSelMemberItemPurchase.cs b/Models/ComSelMemberItemPurchase.cs new file mode 100644 index 0000000..e8e8957 --- /dev/null +++ b/Models/ComSelMemberItemPurchase.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class ComSelMemberItemPurchaseInputParams + { + public string MemberID { get; set; } // log purpose + public string MemberItemPurchaseID { get; set; } + public string token { get; set; } + } + + public class ComSelMemberItemPurchaseModel + { + public string MemberItemPurchaseID { get; set; } + public string MemberID { get; set; } + public string ItemListID { get; set; } + public string PurchaseQuantity { get; set; } + public string PurchasePrice { get; set; } + public string PGinfo1 { get; set; } + public string PGinfo2 { get; set; } + public string PGinfo3 { get; set; } + public string PGinfo4 { get; set; } + public string PGinfo5 { get; set; } + public string PurchaseDeviceID { get; set; } + public string PurchaseDeviceIPAddress { get; set; } + public string PurchaseDeviceMACAddress { get; set; } + public string PurchaseDT { get; set; } + public string PurchaseCancelYN { get; set; } + public string PurchaseCancelDT { get; set; } + public string PurchaseCancelingStatus { get; set; } + public string PurchaseCancelReturnedAmount { get; set; } + public string PurchaseCancelDeviceID { get; set; } + public string PurchaseCancelDeviceIPAddress { get; set; } + public string PurchaseCancelDeviceMACAddress { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + } +} \ No newline at end of file From c52a8d8421735b42456abf5d22a477ec29a9b576 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 01:27:27 +0900 Subject: [PATCH 08/36] adding crypt CBComUdtGiftDepositoryController --- CloudBread.csproj | 1 + .../CBComUdtGiftDepositoryController.cs | 69 +++++++++++-------- Models/ComUdtGiftDepository.cs | 28 ++++++++ 3 files changed, 70 insertions(+), 28 deletions(-) create mode 100644 Models/ComUdtGiftDepository.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index 65dddc0..600e61c 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -294,6 +294,7 @@ + diff --git a/Controllers/CBComUdtGiftDepositoryController.cs b/Controllers/CBComUdtGiftDepositoryController.cs index f4a4335..47532a1 100644 --- a/Controllers/CBComUdtGiftDepositoryController.cs +++ b/Controllers/CBComUdtGiftDepositoryController.cs @@ -30,46 +30,41 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBComUdtGiftDepositoryController : ApiController { - - public class InputParams + public HttpResponseMessage Post(ComUdtGiftDepositoryInputParams p) { - public string MemberID; - public string GiftDepositoryID { get; set; } - public string ItemListID { get; set; } - public string ItemCount { get; set; } - public string FromMemberID { get; set; } - public string ToMemberID { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - - } - - public string Post(InputParams p) - { - string result = ""; + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); + RowcountResult rowcountResult = new RowcountResult(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + try { // task start log @@ -107,7 +102,7 @@ public string Post(InputParams p) { while (dreader.Read()) { - result = dreader[0].ToString(); + rowcountResult.result = dreader[0].ToString(); } dreader.Close(); } @@ -120,7 +115,25 @@ public string Post(InputParams p) logMessage.Message = jsonParam; Logging.RunLog(logMessage); - return result; + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowcountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); + return response; + } } diff --git a/Models/ComUdtGiftDepository.cs b/Models/ComUdtGiftDepository.cs new file mode 100644 index 0000000..6f60db3 --- /dev/null +++ b/Models/ComUdtGiftDepository.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class ComUdtGiftDepositoryInputParams + { + public string MemberID; + public string GiftDepositoryID { get; set; } + public string ItemListID { get; set; } + public string ItemCount { get; set; } + public string FromMemberID { get; set; } + public string ToMemberID { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + public string token { get; set; } + } +} \ No newline at end of file From b85137f812824fa2ac19713f8dea62a351fc5b78 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 01:42:32 +0900 Subject: [PATCH 09/36] adding crypt CBCOMUdtMemberController --- CloudBread.csproj | 1 + Controllers/CBCOMUdtMemberController.cs | 89 +++++++++++-------------- Models/COMUdtMember.cs | 50 ++++++++++++++ 3 files changed, 91 insertions(+), 49 deletions(-) create mode 100644 Models/COMUdtMember.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index 600e61c..c457a58 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -295,6 +295,7 @@ + diff --git a/Controllers/CBCOMUdtMemberController.cs b/Controllers/CBCOMUdtMemberController.cs index 86f7bb4..4e6bdaa 100644 --- a/Controllers/CBCOMUdtMemberController.cs +++ b/Controllers/CBCOMUdtMemberController.cs @@ -30,67 +30,41 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBCOMUdtMemberController : ApiController { - - public class InputParams + public HttpResponseMessage Post(COMUdtMemberInputParams p) { - public string MemberID { get; set; } - public string MemberPWD { get; set; } // CloudBread 2.0.0-beta deplicated. Use 3rd party authentication by default. - public string EmailAddress { get; set; } - public string EmailConfirmedYN { get; set; } - public string PhoneNumber1 { get; set; } - public string PhoneNumber2 { get; set; } - public string PINumber { get; set; } - public string Name1 { get; set; } - public string Name2 { get; set; } - public string Name3 { get; set; } - public string DOB { get; set; } - public string RecommenderID { get; set; } - public string MemberGroup { get; set; } - public string LastDeviceID { get; set; } - public string LastIPaddress { get; set; } - public string LastLoginDT { get; set; } - public string LastLogoutDT { get; set; } - public string LastMACAddress { get; set; } - public string AccountBlockYN { get; set; } - public string AccountBlockEndDT { get; set; } - public string AnonymousYN { get; set; } - public string _3rdAuthProvider { get; set; } - public string _3rdAuthID { get; set; } - public string _3rdAuthParam { get; set; } - public string PushNotificationID { get; set; } - public string PushNotificationProvider { get; set; } - public string PushNotificationGroup { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - public string TimeZoneID { get; set; } - } - - public string Post(InputParams p) - { - string result = ""; + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); + RowcountResult rowcountResult = new RowcountResult(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + try { // start task log @@ -155,7 +129,7 @@ public string Post(InputParams p) { while (dreader.Read()) { - result = dreader[0].ToString(); + rowcountResult.result = dreader[0].ToString(); } dreader.Close(); } @@ -168,7 +142,24 @@ public string Post(InputParams p) logMessage.Message = jsonParam; Logging.RunLog(logMessage); - return result; + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowcountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); + return response; } } diff --git a/Models/COMUdtMember.cs b/Models/COMUdtMember.cs new file mode 100644 index 0000000..4af6c19 --- /dev/null +++ b/Models/COMUdtMember.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class COMUdtMemberInputParams + { + public string MemberID { get; set; } + public string MemberPWD { get; set; } // CloudBread 2.0.0-beta deplicated. Use 3rd party authentication by default. + public string EmailAddress { get; set; } + public string EmailConfirmedYN { get; set; } + public string PhoneNumber1 { get; set; } + public string PhoneNumber2 { get; set; } + public string PINumber { get; set; } + public string Name1 { get; set; } + public string Name2 { get; set; } + public string Name3 { get; set; } + public string DOB { get; set; } + public string RecommenderID { get; set; } + public string MemberGroup { get; set; } + public string LastDeviceID { get; set; } + public string LastIPaddress { get; set; } + public string LastLoginDT { get; set; } + public string LastLogoutDT { get; set; } + public string LastMACAddress { get; set; } + public string AccountBlockYN { get; set; } + public string AccountBlockEndDT { get; set; } + public string AnonymousYN { get; set; } + public string _3rdAuthProvider { get; set; } + public string _3rdAuthID { get; set; } + public string _3rdAuthParam { get; set; } + public string PushNotificationID { get; set; } + public string PushNotificationProvider { get; set; } + public string PushNotificationGroup { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + public string TimeZoneID { get; set; } + public string token { get; set; } + } +} \ No newline at end of file From 105ae53506b961a58a96fc3dbd281c5fdda9bafb Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 01:50:52 +0900 Subject: [PATCH 10/36] adding crypt CBComUdtMemberGameInfoesController --- CloudBread.csproj | 1 + .../CBComUdtMemberGameInfoesController.cs | 76 ++++++++++--------- Models/ComUdtMemberGameInfoes.cs | 36 +++++++++ 3 files changed, 77 insertions(+), 36 deletions(-) create mode 100644 Models/ComUdtMemberGameInfoes.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index c457a58..bed4fd6 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -296,6 +296,7 @@ + diff --git a/Controllers/CBComUdtMemberGameInfoesController.cs b/Controllers/CBComUdtMemberGameInfoesController.cs index 2ee85e3..9bd10fa 100644 --- a/Controllers/CBComUdtMemberGameInfoesController.cs +++ b/Controllers/CBComUdtMemberGameInfoesController.cs @@ -30,54 +30,41 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBComUdtMemberGameInfoesController : ApiController { - - public class InputParams + public HttpResponseMessage Post(ComUdtMemberGameInfoesInputParams p) { - public string MemberID { get; set; } - public string Level { get; set; } - public string Exps { get; set; } - public string Points { get; set; } - public string UserSTAT1 { get; set; } - public string UserSTAT2 { get; set; } - public string UserSTAT3 { get; set; } - public string UserSTAT4 { get; set; } - public string UserSTAT5 { get; set; } - public string UserSTAT6 { get; set; } - public string UserSTAT7 { get; set; } - public string UserSTAT8 { get; set; } - public string UserSTAT9 { get; set; } - public string UserSTAT10 { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - - } - - public string Post(InputParams p) - { - string result = ""; + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + RowcountResult rowcountResult = new RowcountResult(); + try { // task start log @@ -125,7 +112,7 @@ public string Post(InputParams p) { while (dreader.Read()) { - result = dreader[0].ToString(); + rowcountResult.result = dreader[0].ToString(); } dreader.Close(); } @@ -138,7 +125,24 @@ public string Post(InputParams p) logMessage.Message = jsonParam; Logging.RunLog(logMessage); - return result; + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowcountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); + return response; } } diff --git a/Models/ComUdtMemberGameInfoes.cs b/Models/ComUdtMemberGameInfoes.cs new file mode 100644 index 0000000..3d6e878 --- /dev/null +++ b/Models/ComUdtMemberGameInfoes.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class ComUdtMemberGameInfoesInputParams + { + public string MemberID { get; set; } + public string Level { get; set; } + public string Exps { get; set; } + public string Points { get; set; } + public string UserSTAT1 { get; set; } + public string UserSTAT2 { get; set; } + public string UserSTAT3 { get; set; } + public string UserSTAT4 { get; set; } + public string UserSTAT5 { get; set; } + public string UserSTAT6 { get; set; } + public string UserSTAT7 { get; set; } + public string UserSTAT8 { get; set; } + public string UserSTAT9 { get; set; } + public string UserSTAT10 { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + public string token { get; set; } + } +} \ No newline at end of file From f1a4ee848733a3cd8a5a2c17fe358583411f4fe7 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 01:56:27 +0900 Subject: [PATCH 11/36] adding crypt CBComUdtMemberGameInfoStagesController --- CloudBread.csproj | 1 + .../CBComUdtMemberGameInfoStagesController.cs | 79 ++++++++++--------- Models/ComUdtMemberGameInfoStages.cs | 40 ++++++++++ 3 files changed, 81 insertions(+), 39 deletions(-) create mode 100644 Models/ComUdtMemberGameInfoStages.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index bed4fd6..620d881 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -297,6 +297,7 @@ + diff --git a/Controllers/CBComUdtMemberGameInfoStagesController.cs b/Controllers/CBComUdtMemberGameInfoStagesController.cs index a9d9f9e..0ff17fa 100644 --- a/Controllers/CBComUdtMemberGameInfoStagesController.cs +++ b/Controllers/CBComUdtMemberGameInfoStagesController.cs @@ -30,57 +30,41 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBComUdtMemberGameInfoStagesController : ApiController { - public class InputParams + public HttpResponseMessage Post(ComUdtMemberGameInfoStagesInputParams p) { - public string MemberGameInfoStageID { get; set; } - public string MemberID { get; set; } - public string StageName { get; set; } - public string StageStatus { get; set; } - public string Category1 { get; set; } - public string Category2 { get; set; } - public string Category3 { get; set; } - public string Mission1 { get; set; } - public string Mission2 { get; set; } - public string Mission3 { get; set; } - public string Mission4 { get; set; } - public string Mission5 { get; set; } - public string Points { get; set; } - public string StageStat1 { get; set; } - public string StageStat2 { get; set; } - public string StageStat3 { get; set; } - public string StageStat4 { get; set; } - public string StageStat5 { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - - } + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } - public string Post(InputParams p) - { - string result = ""; - // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + RowcountResult rowcountResult = new RowcountResult(); + try { // task start log @@ -131,7 +115,7 @@ public string Post(InputParams p) { while (dreader.Read()) { - result = dreader[0].ToString(); + rowcountResult.result = dreader[0].ToString(); } dreader.Close(); } @@ -144,7 +128,24 @@ public string Post(InputParams p) logMessage.Message = jsonParam; Logging.RunLog(logMessage); - return result; + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowcountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); + return response; } } diff --git a/Models/ComUdtMemberGameInfoStages.cs b/Models/ComUdtMemberGameInfoStages.cs new file mode 100644 index 0000000..42c45da --- /dev/null +++ b/Models/ComUdtMemberGameInfoStages.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class ComUdtMemberGameInfoStagesInputParams + { + public string MemberGameInfoStageID { get; set; } + public string MemberID { get; set; } + public string StageName { get; set; } + public string StageStatus { get; set; } + public string Category1 { get; set; } + public string Category2 { get; set; } + public string Category3 { get; set; } + public string Mission1 { get; set; } + public string Mission2 { get; set; } + public string Mission3 { get; set; } + public string Mission4 { get; set; } + public string Mission5 { get; set; } + public string Points { get; set; } + public string StageStat1 { get; set; } + public string StageStat2 { get; set; } + public string StageStat3 { get; set; } + public string StageStat4 { get; set; } + public string StageStat5 { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + public string token { get; set; } + } +} \ No newline at end of file From 4e687d7a200c17d1d1eb3732fff68ef2a1b92050 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 02:02:22 +0900 Subject: [PATCH 12/36] adding crypt CBComUdtMemberItemController --- CloudBread.csproj | 1 + Controllers/CBComUdtMemberItemController.cs | 65 +++++++++++++-------- Models/ComUdtMemberItem.cs | 27 +++++++++ 3 files changed, 69 insertions(+), 24 deletions(-) create mode 100644 Models/ComUdtMemberItem.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index 620d881..16ae9e9 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -298,6 +298,7 @@ + diff --git a/Controllers/CBComUdtMemberItemController.cs b/Controllers/CBComUdtMemberItemController.cs index 8e61589..ba6df21 100644 --- a/Controllers/CBComUdtMemberItemController.cs +++ b/Controllers/CBComUdtMemberItemController.cs @@ -30,43 +30,43 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBComUdtMemberItemController : ApiController { - public class InputParams - { - public string MemberItemID { get; set; } - public string MemberID { get; set; } - public string ItemListID { get; set; } - public string ItemCount { get; set; } - public string ItemStatus { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - } + - public string Post(InputParams p) + public HttpResponseMessage Post(ComUdtMemberItemInputParams p) { - string result = ""; + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + RowcountResult rowcountResult = new RowcountResult(); + try { // task start log @@ -105,7 +105,7 @@ public string Post(InputParams p) { while (dreader.Read()) { - result = dreader[0].ToString(); + rowcountResult.result = dreader[0].ToString(); } dreader.Close(); } @@ -118,7 +118,24 @@ public string Post(InputParams p) logMessage.Message = jsonParam; Logging.RunLog(logMessage); - return result; + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowcountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); + return response; } } diff --git a/Models/ComUdtMemberItem.cs b/Models/ComUdtMemberItem.cs new file mode 100644 index 0000000..8e49cf5 --- /dev/null +++ b/Models/ComUdtMemberItem.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class ComUdtMemberItemInputParams + { + public string MemberItemID { get; set; } + public string MemberID { get; set; } + public string ItemListID { get; set; } + public string ItemCount { get; set; } + public string ItemStatus { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + public string token { get; set; } + } +} \ No newline at end of file From 59f32bd9e93d06a9f33eb056122ccceccb5579eb Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 02:13:06 +0900 Subject: [PATCH 13/36] adding crypt CBComUdtMemberItemPurchaseController --- CloudBread.csproj | 1 + Controllers/CBComUdtMemberItemController.cs | 5 -- .../CBComUdtMemberItemPurchaseController.cs | 84 +++++++++---------- Models/ComUdtMemberItemPurchase.cs | 43 ++++++++++ 4 files changed, 84 insertions(+), 49 deletions(-) create mode 100644 Models/ComUdtMemberItemPurchase.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index 16ae9e9..0b0e516 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -299,6 +299,7 @@ + diff --git a/Controllers/CBComUdtMemberItemController.cs b/Controllers/CBComUdtMemberItemController.cs index ba6df21..87011f7 100644 --- a/Controllers/CBComUdtMemberItemController.cs +++ b/Controllers/CBComUdtMemberItemController.cs @@ -37,8 +37,6 @@ namespace CloudBread.Controllers [MobileAppController] public class CBComUdtMemberItemController : ApiController { - - public HttpResponseMessage Post(ComUdtMemberItemInputParams p) { // try decrypt data @@ -82,7 +80,6 @@ public HttpResponseMessage Post(ComUdtMemberItemInputParams p) { using (SqlCommand command = new SqlCommand("uspComUdtMemberItem", connection)) { - command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@MemberItemID ", SqlDbType.NVarChar, -1).Value = p.MemberItemID; command.Parameters.Add("@MemberID ", SqlDbType.NVarChar, -1).Value = p.MemberID; @@ -137,7 +134,6 @@ public HttpResponseMessage Post(ComUdtMemberItemInputParams p) response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); return response; } - } } @@ -154,6 +150,5 @@ public HttpResponseMessage Post(ComUdtMemberItemInputParams p) throw; } } - } } diff --git a/Controllers/CBComUdtMemberItemPurchaseController.cs b/Controllers/CBComUdtMemberItemPurchaseController.cs index 2d3a304..a8297d2 100644 --- a/Controllers/CBComUdtMemberItemPurchaseController.cs +++ b/Controllers/CBComUdtMemberItemPurchaseController.cs @@ -30,60 +30,41 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBComUdtMemberItemPurchaseController : ApiController { - public class InputParams + public HttpResponseMessage Post(ComUdtMemberItemPurchaseInputParams p) { - public string MemberItemPurchaseID { get; set; } - public string MemberID { get; set; } - public string ItemListID { get; set; } - public string PurchaseQuantity { get; set; } - public string PurchasePrice { get; set; } - public string PGinfo1 { get; set; } - public string PGinfo2 { get; set; } - public string PGinfo3 { get; set; } - public string PGinfo4 { get; set; } - public string PGinfo5 { get; set; } - public string PurchaseDeviceID { get; set; } - public string PurchaseDeviceIPAddress { get; set; } - public string PurchaseDeviceMACAddress { get; set; } - public string PurchaseDT { get; set; } - public string PurchaseCancelYN { get; set; } - public string PurchaseCancelDT { get; set; } - public string PurchaseCancelingStatus { get; set; } - public string PurchaseCancelReturnedAmount { get; set; } - public string PurchaseCancelDeviceID { get; set; } - public string PurchaseCancelDeviceIPAddress { get; set; } - public string PurchaseCancelDeviceMACAddress { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - - } - - public string Post(InputParams p) - { - string result = ""; + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + RowcountResult rowcountResult = new RowcountResult(); + try { // task start log @@ -138,7 +119,7 @@ public string Post(InputParams p) { while (dreader.Read()) { - result = dreader[0].ToString(); + rowcountResult.result = dreader[0].ToString(); } dreader.Close(); } @@ -151,9 +132,25 @@ public string Post(InputParams p) logMessage.Message = jsonParam; Logging.RunLog(logMessage); - return result; - } + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowcountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); + return response; + } } } @@ -170,6 +167,5 @@ public string Post(InputParams p) throw; } } - } } diff --git a/Models/ComUdtMemberItemPurchase.cs b/Models/ComUdtMemberItemPurchase.cs new file mode 100644 index 0000000..98f02b9 --- /dev/null +++ b/Models/ComUdtMemberItemPurchase.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class ComUdtMemberItemPurchaseInputParams + { + public string MemberItemPurchaseID { get; set; } + public string MemberID { get; set; } + public string ItemListID { get; set; } + public string PurchaseQuantity { get; set; } + public string PurchasePrice { get; set; } + public string PGinfo1 { get; set; } + public string PGinfo2 { get; set; } + public string PGinfo3 { get; set; } + public string PGinfo4 { get; set; } + public string PGinfo5 { get; set; } + public string PurchaseDeviceID { get; set; } + public string PurchaseDeviceIPAddress { get; set; } + public string PurchaseDeviceMACAddress { get; set; } + public string PurchaseDT { get; set; } + public string PurchaseCancelYN { get; set; } + public string PurchaseCancelDT { get; set; } + public string PurchaseCancelingStatus { get; set; } + public string PurchaseCancelReturnedAmount { get; set; } + public string PurchaseCancelDeviceID { get; set; } + public string PurchaseCancelDeviceIPAddress { get; set; } + public string PurchaseCancelDeviceMACAddress { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + public string token { get; set; } + } +} \ No newline at end of file From e3340bd140dd3a303bc1b5c3c4f8f528f1172952 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 02:17:37 +0900 Subject: [PATCH 14/36] CBInsAnonymousRegMemberController is deplicated --- .../CBInsAnonymousRegMemberController.cs | 420 +++++++++--------- 1 file changed, 210 insertions(+), 210 deletions(-) diff --git a/Controllers/CBInsAnonymousRegMemberController.cs b/Controllers/CBInsAnonymousRegMemberController.cs index 054e2c0..b3b78dd 100644 --- a/Controllers/CBInsAnonymousRegMemberController.cs +++ b/Controllers/CBInsAnonymousRegMemberController.cs @@ -10,230 +10,230 @@ * @param members and MemberGameInfoes object * @return string value "2" affected rows count * @see uspInsAnonymousRegMember SP, BehaviorID : B03 -* @todo change return value to inserted data as json +* @todo this API is deplicated in v2.1 */ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Web.Http; -using Microsoft.Azure.Mobile.Server; -using Microsoft.Azure.Mobile.Server.Config; +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Net; +//using System.Net.Http; +//using System.Web.Http; +//using Microsoft.Azure.Mobile.Server; +//using Microsoft.Azure.Mobile.Server.Config; -using System.Threading.Tasks; -using System.Diagnostics; -using Logger.Logging; -using CloudBread.globals; -using CloudBreadLib.BAL.Crypto; -using System.Data; -using System.Data.Sql; -using System.Data.SqlClient; -using Newtonsoft.Json; -using CloudBreadAuth; -using System.Security.Claims; -using Microsoft.Practices.TransientFaultHandling; -using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +//using System.Threading.Tasks; +//using System.Diagnostics; +//using Logger.Logging; +//using CloudBread.globals; +//using CloudBreadLib.BAL.Crypto; +//using System.Data; +//using System.Data.Sql; +//using System.Data.SqlClient; +//using Newtonsoft.Json; +//using CloudBreadAuth; +//using System.Security.Claims; +//using Microsoft.Practices.TransientFaultHandling; +//using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; -namespace CloudBread.Controllers -{ - [MobileAppController] - public class CBInsAnonymousRegMemberController : ApiController - { +//namespace CloudBread.Controllers +//{ +// [MobileAppController] +// public class CBInsAnonymousRegMemberController : ApiController +// { - public class InputParams - { - public string MembersMemberID { get; set; } - public string MembersMemberPWD { get; set; } - public string MembersEmailAddress { get; set; } - public string MembersEmailConfirmedYN { get; set; } - public string MembersPhoneNumber1 { get; set; } - public string MembersPhoneNumber2 { get; set; } - public string MembersPINumber { get; set; } - public string MembersName1 { get; set; } - public string MembersName2 { get; set; } - public string MembersName3 { get; set; } - public string MembersDOB { get; set; } - public string MembersRecommenderID { get; set; } - public string MembersMemberGroup { get; set; } - public string MembersLastDeviceID { get; set; } - public string MembersLastIPaddress { get; set; } - public string MembersLastLoginDT { get; set; } - public string MembersLastLogoutDT { get; set; } - public string MembersLastMACAddress { get; set; } - public string MembersAccountBlockYN { get; set; } - public string MembersAccountBlockEndDT { get; set; } - public string MembersAnonymousYN { get; set; } - public string Members3rdAuthProvider { get; set; } - public string Members3rdAuthID { get; set; } - public string Members3rdAuthParam { get; set; } - public string MembersPushNotificationID { get; set; } - public string MembersPushNotificationProvider { get; set; } - public string MembersPushNotificationGroup { get; set; } - public string MemberssCol1 { get; set; } - public string MemberssCol2 { get; set; } - public string MemberssCol3 { get; set; } - public string MemberssCol4 { get; set; } - public string MemberssCol5 { get; set; } - public string MemberssCol6 { get; set; } - public string MemberssCol7 { get; set; } - public string MemberssCol8 { get; set; } - public string MemberssCol9 { get; set; } - public string MemberssCol10 { get; set; } - public string MembersTimeZoneID { get; set; } - public string MemberGameInfoesLevel { get; set; } - public string MemberGameInfoesExps { get; set; } - public string MemberGameInfoesPoints { get; set; } - public string MemberGameInfoesUserSTAT1 { get; set; } - public string MemberGameInfoesUserSTAT2 { get; set; } - public string MemberGameInfoesUserSTAT3 { get; set; } - public string MemberGameInfoesUserSTAT4 { get; set; } - public string MemberGameInfoesUserSTAT5 { get; set; } - public string MemberGameInfoesUserSTAT6 { get; set; } - public string MemberGameInfoesUserSTAT7 { get; set; } - public string MemberGameInfoesUserSTAT8 { get; set; } - public string MemberGameInfoesUserSTAT9 { get; set; } - public string MemberGameInfoesUserSTAT10 { get; set; } - public string MemberGameInfoessCol1 { get; set; } - public string MemberGameInfoessCol2 { get; set; } - public string MemberGameInfoessCol3 { get; set; } - public string MemberGameInfoessCol4 { get; set; } - public string MemberGameInfoessCol5 { get; set; } - public string MemberGameInfoessCol6 { get; set; } - public string MemberGameInfoessCol7 { get; set; } - public string MemberGameInfoessCol8 { get; set; } - public string MemberGameInfoessCol9 { get; set; } - public string MemberGameInfoessCol10 { get; set; } +// public class InputParams +// { +// public string MembersMemberID { get; set; } +// public string MembersMemberPWD { get; set; } +// public string MembersEmailAddress { get; set; } +// public string MembersEmailConfirmedYN { get; set; } +// public string MembersPhoneNumber1 { get; set; } +// public string MembersPhoneNumber2 { get; set; } +// public string MembersPINumber { get; set; } +// public string MembersName1 { get; set; } +// public string MembersName2 { get; set; } +// public string MembersName3 { get; set; } +// public string MembersDOB { get; set; } +// public string MembersRecommenderID { get; set; } +// public string MembersMemberGroup { get; set; } +// public string MembersLastDeviceID { get; set; } +// public string MembersLastIPaddress { get; set; } +// public string MembersLastLoginDT { get; set; } +// public string MembersLastLogoutDT { get; set; } +// public string MembersLastMACAddress { get; set; } +// public string MembersAccountBlockYN { get; set; } +// public string MembersAccountBlockEndDT { get; set; } +// public string MembersAnonymousYN { get; set; } +// public string Members3rdAuthProvider { get; set; } +// public string Members3rdAuthID { get; set; } +// public string Members3rdAuthParam { get; set; } +// public string MembersPushNotificationID { get; set; } +// public string MembersPushNotificationProvider { get; set; } +// public string MembersPushNotificationGroup { get; set; } +// public string MemberssCol1 { get; set; } +// public string MemberssCol2 { get; set; } +// public string MemberssCol3 { get; set; } +// public string MemberssCol4 { get; set; } +// public string MemberssCol5 { get; set; } +// public string MemberssCol6 { get; set; } +// public string MemberssCol7 { get; set; } +// public string MemberssCol8 { get; set; } +// public string MemberssCol9 { get; set; } +// public string MemberssCol10 { get; set; } +// public string MembersTimeZoneID { get; set; } +// public string MemberGameInfoesLevel { get; set; } +// public string MemberGameInfoesExps { get; set; } +// public string MemberGameInfoesPoints { get; set; } +// public string MemberGameInfoesUserSTAT1 { get; set; } +// public string MemberGameInfoesUserSTAT2 { get; set; } +// public string MemberGameInfoesUserSTAT3 { get; set; } +// public string MemberGameInfoesUserSTAT4 { get; set; } +// public string MemberGameInfoesUserSTAT5 { get; set; } +// public string MemberGameInfoesUserSTAT6 { get; set; } +// public string MemberGameInfoesUserSTAT7 { get; set; } +// public string MemberGameInfoesUserSTAT8 { get; set; } +// public string MemberGameInfoesUserSTAT9 { get; set; } +// public string MemberGameInfoesUserSTAT10 { get; set; } +// public string MemberGameInfoessCol1 { get; set; } +// public string MemberGameInfoessCol2 { get; set; } +// public string MemberGameInfoessCol3 { get; set; } +// public string MemberGameInfoessCol4 { get; set; } +// public string MemberGameInfoessCol5 { get; set; } +// public string MemberGameInfoessCol6 { get; set; } +// public string MemberGameInfoessCol7 { get; set; } +// public string MemberGameInfoessCol8 { get; set; } +// public string MemberGameInfoessCol9 { get; set; } +// public string MemberGameInfoessCol10 { get; set; } - } - public string Post(InputParams p) - { - string result = ""; +// } +// public string Post(InputParams p) +// { +// string result = ""; - // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MembersMemberID, claimsPrincipal); - p.MembersMemberID = sid; +// // Get the sid or memberID of the current user. +// var claimsPrincipal = this.User as ClaimsPrincipal; +// string sid = CBAuth.getMemberID(p.MembersMemberID, claimsPrincipal); +// p.MembersMemberID = sid; - Logging.CBLoggers logMessage = new Logging.CBLoggers(); - string jsonParam = JsonConvert.SerializeObject(p); +// Logging.CBLoggers logMessage = new Logging.CBLoggers(); +// string jsonParam = JsonConvert.SerializeObject(p); - try - { - // task start log - //logMessage.memberID = p.MembersMemberID; - //logMessage.Level = "INFO"; - //logMessage.Logger = "CBInsAnonymousRegMemberController"; - //logMessage.Message = jsonParam; - //Logging.RunLog(logMessage); +// try +// { +// // task start log +// //logMessage.memberID = p.MembersMemberID; +// //logMessage.Level = "INFO"; +// //logMessage.Logger = "CBInsAnonymousRegMemberController"; +// //logMessage.Message = jsonParam; +// //Logging.RunLog(logMessage); - /// Database connection retry policy - RetryPolicy retryPolicy = new RetryPolicy(globalVal.conRetryCount, TimeSpan.FromSeconds(globalVal.conRetryFromSeconds)); - using (SqlConnection connection = new SqlConnection(globalVal.DBConnectionString)) - { - using (SqlCommand command = new SqlCommand("uspInsAnonymousRegMember", connection)) - { - command.CommandType = CommandType.StoredProcedure; - command.Parameters.Add("@MembersMemberID", SqlDbType.NVarChar, -1).Value = p.MembersMemberID; - command.Parameters.Add("@MembersMemberPWD", SqlDbType.NVarChar, -1).Value = p.MembersMemberPWD; - command.Parameters.Add("@MembersEmailAddress", SqlDbType.NVarChar, -1).Value = p.MembersEmailAddress; - command.Parameters.Add("@MembersEmailConfirmedYN", SqlDbType.NVarChar, -1).Value = p.MembersEmailConfirmedYN; - command.Parameters.Add("@MembersPhoneNumber1", SqlDbType.NVarChar, -1).Value = p.MembersPhoneNumber1; - command.Parameters.Add("@MembersPhoneNumber2", SqlDbType.NVarChar, -1).Value = p.MembersPhoneNumber2; - command.Parameters.Add("@MembersPINumber", SqlDbType.NVarChar, -1).Value = p.MembersPINumber; - command.Parameters.Add("@MembersName1", SqlDbType.NVarChar, -1).Value = p.MembersName1; - command.Parameters.Add("@MembersName2", SqlDbType.NVarChar, -1).Value = p.MembersName2; - command.Parameters.Add("@MembersName3", SqlDbType.NVarChar, -1).Value = p.MembersName3; - command.Parameters.Add("@MembersDOB", SqlDbType.NVarChar, -1).Value = p.MembersDOB; - command.Parameters.Add("@MembersRecommenderID", SqlDbType.NVarChar, -1).Value = p.MembersRecommenderID; - command.Parameters.Add("@MembersMemberGroup", SqlDbType.NVarChar, -1).Value = p.MembersMemberGroup; - command.Parameters.Add("@MembersLastDeviceID", SqlDbType.NVarChar, -1).Value = p.MembersLastDeviceID; - command.Parameters.Add("@MembersLastIPaddress", SqlDbType.NVarChar, -1).Value = p.MembersLastIPaddress; - command.Parameters.Add("@MembersLastLoginDT", SqlDbType.NVarChar, -1).Value = p.MembersLastLoginDT; - command.Parameters.Add("@MembersLastLogoutDT", SqlDbType.NVarChar, -1).Value = p.MembersLastLogoutDT; - command.Parameters.Add("@MembersLastMACAddress", SqlDbType.NVarChar, -1).Value = p.MembersLastMACAddress; - command.Parameters.Add("@MembersAccountBlockYN", SqlDbType.NVarChar, -1).Value = p.MembersAccountBlockYN; - command.Parameters.Add("@MembersAccountBlockEndDT", SqlDbType.NVarChar, -1).Value = p.MembersAccountBlockEndDT; - command.Parameters.Add("@MembersAnonymousYN", SqlDbType.NVarChar, -1).Value = p.MembersAnonymousYN; - command.Parameters.Add("@Members3rdAuthProvider", SqlDbType.NVarChar, -1).Value = p.Members3rdAuthProvider; - command.Parameters.Add("@Members3rdAuthID", SqlDbType.NVarChar, -1).Value = p.Members3rdAuthID; - command.Parameters.Add("@Members3rdAuthParam", SqlDbType.NVarChar, -1).Value = p.Members3rdAuthParam; - command.Parameters.Add("@MembersPushNotificationID", SqlDbType.NVarChar, -1).Value = p.MembersPushNotificationID; - command.Parameters.Add("@MembersPushNotificationProvider", SqlDbType.NVarChar, -1).Value = p.MembersPushNotificationProvider; - command.Parameters.Add("@MembersPushNotificationGroup", SqlDbType.NVarChar, -1).Value = p.MembersPushNotificationGroup; - command.Parameters.Add("@MemberssCol1", SqlDbType.NVarChar, -1).Value = p.MemberssCol1; - command.Parameters.Add("@MemberssCol2", SqlDbType.NVarChar, -1).Value = p.MemberssCol2; - command.Parameters.Add("@MemberssCol3", SqlDbType.NVarChar, -1).Value = p.MemberssCol3; - command.Parameters.Add("@MemberssCol4", SqlDbType.NVarChar, -1).Value = p.MemberssCol4; - command.Parameters.Add("@MemberssCol5", SqlDbType.NVarChar, -1).Value = p.MemberssCol5; - command.Parameters.Add("@MemberssCol6", SqlDbType.NVarChar, -1).Value = p.MemberssCol6; - command.Parameters.Add("@MemberssCol7", SqlDbType.NVarChar, -1).Value = p.MemberssCol7; - command.Parameters.Add("@MemberssCol8", SqlDbType.NVarChar, -1).Value = p.MemberssCol8; - command.Parameters.Add("@MemberssCol9", SqlDbType.NVarChar, -1).Value = p.MemberssCol9; - command.Parameters.Add("@MemberssCol10", SqlDbType.NVarChar, -1).Value = p.MemberssCol10; - command.Parameters.Add("@MembersTimeZoneID", SqlDbType.NVarChar, -1).Value = p.MembersTimeZoneID; - command.Parameters.Add("@MemberGameInfoesLevel", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesLevel; - command.Parameters.Add("@MemberGameInfoesExps", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesExps; - command.Parameters.Add("@MemberGameInfoesPoints", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesPoints; - command.Parameters.Add("@MemberGameInfoesUserSTAT1", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT1; - command.Parameters.Add("@MemberGameInfoesUserSTAT2", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT2; - command.Parameters.Add("@MemberGameInfoesUserSTAT3", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT3; - command.Parameters.Add("@MemberGameInfoesUserSTAT4", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT4; - command.Parameters.Add("@MemberGameInfoesUserSTAT5", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT5; - command.Parameters.Add("@MemberGameInfoesUserSTAT6", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT6; - command.Parameters.Add("@MemberGameInfoesUserSTAT7", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT7; - command.Parameters.Add("@MemberGameInfoesUserSTAT8", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT8; - command.Parameters.Add("@MemberGameInfoesUserSTAT9", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT9; - command.Parameters.Add("@MemberGameInfoesUserSTAT10", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT10; - command.Parameters.Add("@MemberGameInfoessCol1", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol1; - command.Parameters.Add("@MemberGameInfoessCol2", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol2; - command.Parameters.Add("@MemberGameInfoessCol3", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol3; - command.Parameters.Add("@MemberGameInfoessCol4", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol4; - command.Parameters.Add("@MemberGameInfoessCol5", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol5; - command.Parameters.Add("@MemberGameInfoessCol6", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol6; - command.Parameters.Add("@MemberGameInfoessCol7", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol7; - command.Parameters.Add("@MemberGameInfoessCol8", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol8; - command.Parameters.Add("@MemberGameInfoessCol9", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol9; - command.Parameters.Add("@MemberGameInfoessCol10", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol10; +// /// Database connection retry policy +// RetryPolicy retryPolicy = new RetryPolicy(globalVal.conRetryCount, TimeSpan.FromSeconds(globalVal.conRetryFromSeconds)); +// using (SqlConnection connection = new SqlConnection(globalVal.DBConnectionString)) +// { +// using (SqlCommand command = new SqlCommand("uspInsAnonymousRegMember", connection)) +// { +// command.CommandType = CommandType.StoredProcedure; +// command.Parameters.Add("@MembersMemberID", SqlDbType.NVarChar, -1).Value = p.MembersMemberID; +// command.Parameters.Add("@MembersMemberPWD", SqlDbType.NVarChar, -1).Value = p.MembersMemberPWD; +// command.Parameters.Add("@MembersEmailAddress", SqlDbType.NVarChar, -1).Value = p.MembersEmailAddress; +// command.Parameters.Add("@MembersEmailConfirmedYN", SqlDbType.NVarChar, -1).Value = p.MembersEmailConfirmedYN; +// command.Parameters.Add("@MembersPhoneNumber1", SqlDbType.NVarChar, -1).Value = p.MembersPhoneNumber1; +// command.Parameters.Add("@MembersPhoneNumber2", SqlDbType.NVarChar, -1).Value = p.MembersPhoneNumber2; +// command.Parameters.Add("@MembersPINumber", SqlDbType.NVarChar, -1).Value = p.MembersPINumber; +// command.Parameters.Add("@MembersName1", SqlDbType.NVarChar, -1).Value = p.MembersName1; +// command.Parameters.Add("@MembersName2", SqlDbType.NVarChar, -1).Value = p.MembersName2; +// command.Parameters.Add("@MembersName3", SqlDbType.NVarChar, -1).Value = p.MembersName3; +// command.Parameters.Add("@MembersDOB", SqlDbType.NVarChar, -1).Value = p.MembersDOB; +// command.Parameters.Add("@MembersRecommenderID", SqlDbType.NVarChar, -1).Value = p.MembersRecommenderID; +// command.Parameters.Add("@MembersMemberGroup", SqlDbType.NVarChar, -1).Value = p.MembersMemberGroup; +// command.Parameters.Add("@MembersLastDeviceID", SqlDbType.NVarChar, -1).Value = p.MembersLastDeviceID; +// command.Parameters.Add("@MembersLastIPaddress", SqlDbType.NVarChar, -1).Value = p.MembersLastIPaddress; +// command.Parameters.Add("@MembersLastLoginDT", SqlDbType.NVarChar, -1).Value = p.MembersLastLoginDT; +// command.Parameters.Add("@MembersLastLogoutDT", SqlDbType.NVarChar, -1).Value = p.MembersLastLogoutDT; +// command.Parameters.Add("@MembersLastMACAddress", SqlDbType.NVarChar, -1).Value = p.MembersLastMACAddress; +// command.Parameters.Add("@MembersAccountBlockYN", SqlDbType.NVarChar, -1).Value = p.MembersAccountBlockYN; +// command.Parameters.Add("@MembersAccountBlockEndDT", SqlDbType.NVarChar, -1).Value = p.MembersAccountBlockEndDT; +// command.Parameters.Add("@MembersAnonymousYN", SqlDbType.NVarChar, -1).Value = p.MembersAnonymousYN; +// command.Parameters.Add("@Members3rdAuthProvider", SqlDbType.NVarChar, -1).Value = p.Members3rdAuthProvider; +// command.Parameters.Add("@Members3rdAuthID", SqlDbType.NVarChar, -1).Value = p.Members3rdAuthID; +// command.Parameters.Add("@Members3rdAuthParam", SqlDbType.NVarChar, -1).Value = p.Members3rdAuthParam; +// command.Parameters.Add("@MembersPushNotificationID", SqlDbType.NVarChar, -1).Value = p.MembersPushNotificationID; +// command.Parameters.Add("@MembersPushNotificationProvider", SqlDbType.NVarChar, -1).Value = p.MembersPushNotificationProvider; +// command.Parameters.Add("@MembersPushNotificationGroup", SqlDbType.NVarChar, -1).Value = p.MembersPushNotificationGroup; +// command.Parameters.Add("@MemberssCol1", SqlDbType.NVarChar, -1).Value = p.MemberssCol1; +// command.Parameters.Add("@MemberssCol2", SqlDbType.NVarChar, -1).Value = p.MemberssCol2; +// command.Parameters.Add("@MemberssCol3", SqlDbType.NVarChar, -1).Value = p.MemberssCol3; +// command.Parameters.Add("@MemberssCol4", SqlDbType.NVarChar, -1).Value = p.MemberssCol4; +// command.Parameters.Add("@MemberssCol5", SqlDbType.NVarChar, -1).Value = p.MemberssCol5; +// command.Parameters.Add("@MemberssCol6", SqlDbType.NVarChar, -1).Value = p.MemberssCol6; +// command.Parameters.Add("@MemberssCol7", SqlDbType.NVarChar, -1).Value = p.MemberssCol7; +// command.Parameters.Add("@MemberssCol8", SqlDbType.NVarChar, -1).Value = p.MemberssCol8; +// command.Parameters.Add("@MemberssCol9", SqlDbType.NVarChar, -1).Value = p.MemberssCol9; +// command.Parameters.Add("@MemberssCol10", SqlDbType.NVarChar, -1).Value = p.MemberssCol10; +// command.Parameters.Add("@MembersTimeZoneID", SqlDbType.NVarChar, -1).Value = p.MembersTimeZoneID; +// command.Parameters.Add("@MemberGameInfoesLevel", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesLevel; +// command.Parameters.Add("@MemberGameInfoesExps", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesExps; +// command.Parameters.Add("@MemberGameInfoesPoints", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesPoints; +// command.Parameters.Add("@MemberGameInfoesUserSTAT1", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT1; +// command.Parameters.Add("@MemberGameInfoesUserSTAT2", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT2; +// command.Parameters.Add("@MemberGameInfoesUserSTAT3", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT3; +// command.Parameters.Add("@MemberGameInfoesUserSTAT4", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT4; +// command.Parameters.Add("@MemberGameInfoesUserSTAT5", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT5; +// command.Parameters.Add("@MemberGameInfoesUserSTAT6", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT6; +// command.Parameters.Add("@MemberGameInfoesUserSTAT7", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT7; +// command.Parameters.Add("@MemberGameInfoesUserSTAT8", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT8; +// command.Parameters.Add("@MemberGameInfoesUserSTAT9", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT9; +// command.Parameters.Add("@MemberGameInfoesUserSTAT10", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoesUserSTAT10; +// command.Parameters.Add("@MemberGameInfoessCol1", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol1; +// command.Parameters.Add("@MemberGameInfoessCol2", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol2; +// command.Parameters.Add("@MemberGameInfoessCol3", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol3; +// command.Parameters.Add("@MemberGameInfoessCol4", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol4; +// command.Parameters.Add("@MemberGameInfoessCol5", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol5; +// command.Parameters.Add("@MemberGameInfoessCol6", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol6; +// command.Parameters.Add("@MemberGameInfoessCol7", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol7; +// command.Parameters.Add("@MemberGameInfoessCol8", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol8; +// command.Parameters.Add("@MemberGameInfoessCol9", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol9; +// command.Parameters.Add("@MemberGameInfoessCol10", SqlDbType.NVarChar, -1).Value = p.MemberGameInfoessCol10; - connection.OpenWithRetry(retryPolicy); - using (SqlDataReader dreader = command.ExecuteReaderWithRetry(retryPolicy)) - { - while (dreader.Read()) - { - result = dreader[0].ToString(); - } - dreader.Close(); - } - connection.Close(); +// connection.OpenWithRetry(retryPolicy); +// using (SqlDataReader dreader = command.ExecuteReaderWithRetry(retryPolicy)) +// { +// while (dreader.Read()) +// { +// result = dreader[0].ToString(); +// } +// dreader.Close(); +// } +// connection.Close(); - // task end log - logMessage.memberID = p.MembersMemberID; - logMessage.Level = "INFO"; - logMessage.Logger = "CBInsAnonymousRegMemberController"; - logMessage.Message = jsonParam; - Logging.RunLog(logMessage); +// // task end log +// logMessage.memberID = p.MembersMemberID; +// logMessage.Level = "INFO"; +// logMessage.Logger = "CBInsAnonymousRegMemberController"; +// logMessage.Message = jsonParam; +// Logging.RunLog(logMessage); - return result; - } - } - } +// return result; +// } +// } +// } - catch (Exception ex) - { - // error log - logMessage.memberID = p.MembersMemberID; - logMessage.Level = "ERROR"; - logMessage.Logger = "CBInsAnonymousRegMemberController"; - logMessage.Message = jsonParam; - logMessage.Exception = ex.ToString(); - Logging.RunLog(logMessage); +// catch (Exception ex) +// { +// // error log +// logMessage.memberID = p.MembersMemberID; +// logMessage.Level = "ERROR"; +// logMessage.Logger = "CBInsAnonymousRegMemberController"; +// logMessage.Message = jsonParam; +// logMessage.Exception = ex.ToString(); +// Logging.RunLog(logMessage); - throw; - } - } +// throw; +// } +// } - } -} +// } +//} From 0bbf8d1b4c4101dbf7cdf88a8e034836a4c14b38 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 02:20:46 +0900 Subject: [PATCH 15/36] adding crypt CBInsRegMemberController --- CloudBread.csproj | 1 + Controllers/CBInsRegMemberController.cs | 115 +++++++++--------------- Models/InsRegMember.cs | 73 +++++++++++++++ 3 files changed, 114 insertions(+), 75 deletions(-) create mode 100644 Models/InsRegMember.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index 0b0e516..2a64627 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -301,6 +301,7 @@ + diff --git a/Controllers/CBInsRegMemberController.cs b/Controllers/CBInsRegMemberController.cs index 5d59cce..8e97c01 100644 --- a/Controllers/CBInsRegMemberController.cs +++ b/Controllers/CBInsRegMemberController.cs @@ -34,91 +34,41 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBInsRegMemberController : ApiController { - - public class InputParams + public HttpResponseMessage Post(InsRegMemberInputParams p) { - public string MemberID_Members { get; set; } - public string MemberPWD_Members { get; set; } - public string EmailAddress_Members { get; set; } - public string EmailConfirmedYN_Members { get; set; } - public string PhoneNumber1_Members { get; set; } - public string PhoneNumber2_Members { get; set; } - public string PINumber_Members { get; set; } - public string Name1_Members { get; set; } - public string Name2_Members { get; set; } - public string Name3_Members { get; set; } - public string DOB_Members { get; set; } - public string RecommenderID_Members { get; set; } - public string MemberGroup_Members { get; set; } - public string LastDeviceID_Members { get; set; } - public string LastIPaddress_Members { get; set; } - public string LastLoginDT_Members { get; set; } - public string LastLogoutDT_Members { get; set; } - public string LastMACAddress_Members { get; set; } - public string AccountBlockYN_Members { get; set; } - public string AccountBlockEndDT_Members { get; set; } - public string AnonymousYN_Members { get; set; } - public string _3rdAuthProvider_Members { get; set; } - public string _3rdAuthID_Members { get; set; } - public string _3rdAuthParam_Members { get; set; } - public string PushNotificationID_Members { get; set; } - public string PushNotificationProvider_Members { get; set; } - public string PushNotificationGroup_Members { get; set; } - public string sCol1_Members { get; set; } - public string sCol2_Members { get; set; } - public string sCol3_Members { get; set; } - public string sCol4_Members { get; set; } - public string sCol5_Members { get; set; } - public string sCol6_Members { get; set; } - public string sCol7_Members { get; set; } - public string sCol8_Members { get; set; } - public string sCol9_Members { get; set; } - public string sCol10_Members { get; set; } - public string TimeZoneID_Members { get; set; } - public string Level_MemberGameInfoes { get; set; } - public string Exps_MemberGameInfoes { get; set; } - public string Points_MemberGameInfoes { get; set; } - public string UserSTAT1_MemberGameInfoes { get; set; } - public string UserSTAT2_MemberGameInfoes { get; set; } - public string UserSTAT3_MemberGameInfoes { get; set; } - public string UserSTAT4_MemberGameInfoes { get; set; } - public string UserSTAT5_MemberGameInfoes { get; set; } - public string UserSTAT6_MemberGameInfoes { get; set; } - public string UserSTAT7_MemberGameInfoes { get; set; } - public string UserSTAT8_MemberGameInfoes { get; set; } - public string UserSTAT9_MemberGameInfoes { get; set; } - public string UserSTAT10_MemberGameInfoes { get; set; } - public string sCol1_MemberGameInfoes { get; set; } - public string sCol2_MemberGameInfoes { get; set; } - public string sCol3_MemberGameInfoes { get; set; } - public string sCol4_MemberGameInfoes { get; set; } - public string sCol5_MemberGameInfoes { get; set; } - public string sCol6_MemberGameInfoes { get; set; } - public string sCol7_MemberGameInfoes { get; set; } - public string sCol8_MemberGameInfoes { get; set; } - public string sCol9_MemberGameInfoes { get; set; } - public string sCol10_MemberGameInfoes { get; set; } - - } - - public string Post(InputParams p) - { - string result = ""; + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID_Members, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID_Members, this.User as ClaimsPrincipal); p.MemberID_Members = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + RowcountResult rowcountResult = new RowcountResult(); + try { // task start log @@ -197,13 +147,12 @@ public string Post(InputParams p) command.Parameters.Add("@sCol9_MemberGameInfoes", SqlDbType.NVarChar, -1).Value = p.sCol9_MemberGameInfoes; command.Parameters.Add("@sCol10_MemberGameInfoes", SqlDbType.NVarChar, -1).Value = p.sCol10_MemberGameInfoes; - connection.OpenWithRetry(retryPolicy); using (SqlDataReader dreader = command.ExecuteReaderWithRetry(retryPolicy)) { while (dreader.Read()) { - result = dreader[0].ToString(); + rowcountResult.result = dreader[0].ToString(); } dreader.Close(); } @@ -216,9 +165,25 @@ public string Post(InputParams p) logMessage.Message = jsonParam; Logging.RunLog(logMessage); - return result; + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowcountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); + return response; } - } } diff --git a/Models/InsRegMember.cs b/Models/InsRegMember.cs new file mode 100644 index 0000000..218364d --- /dev/null +++ b/Models/InsRegMember.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class InsRegMemberInputParams + { + public string MemberID_Members { get; set; } + public string MemberPWD_Members { get; set; } + public string EmailAddress_Members { get; set; } + public string EmailConfirmedYN_Members { get; set; } + public string PhoneNumber1_Members { get; set; } + public string PhoneNumber2_Members { get; set; } + public string PINumber_Members { get; set; } + public string Name1_Members { get; set; } + public string Name2_Members { get; set; } + public string Name3_Members { get; set; } + public string DOB_Members { get; set; } + public string RecommenderID_Members { get; set; } + public string MemberGroup_Members { get; set; } + public string LastDeviceID_Members { get; set; } + public string LastIPaddress_Members { get; set; } + public string LastLoginDT_Members { get; set; } + public string LastLogoutDT_Members { get; set; } + public string LastMACAddress_Members { get; set; } + public string AccountBlockYN_Members { get; set; } + public string AccountBlockEndDT_Members { get; set; } + public string AnonymousYN_Members { get; set; } + public string _3rdAuthProvider_Members { get; set; } + public string _3rdAuthID_Members { get; set; } + public string _3rdAuthParam_Members { get; set; } + public string PushNotificationID_Members { get; set; } + public string PushNotificationProvider_Members { get; set; } + public string PushNotificationGroup_Members { get; set; } + public string sCol1_Members { get; set; } + public string sCol2_Members { get; set; } + public string sCol3_Members { get; set; } + public string sCol4_Members { get; set; } + public string sCol5_Members { get; set; } + public string sCol6_Members { get; set; } + public string sCol7_Members { get; set; } + public string sCol8_Members { get; set; } + public string sCol9_Members { get; set; } + public string sCol10_Members { get; set; } + public string TimeZoneID_Members { get; set; } + public string Level_MemberGameInfoes { get; set; } + public string Exps_MemberGameInfoes { get; set; } + public string Points_MemberGameInfoes { get; set; } + public string UserSTAT1_MemberGameInfoes { get; set; } + public string UserSTAT2_MemberGameInfoes { get; set; } + public string UserSTAT3_MemberGameInfoes { get; set; } + public string UserSTAT4_MemberGameInfoes { get; set; } + public string UserSTAT5_MemberGameInfoes { get; set; } + public string UserSTAT6_MemberGameInfoes { get; set; } + public string UserSTAT7_MemberGameInfoes { get; set; } + public string UserSTAT8_MemberGameInfoes { get; set; } + public string UserSTAT9_MemberGameInfoes { get; set; } + public string UserSTAT10_MemberGameInfoes { get; set; } + public string sCol1_MemberGameInfoes { get; set; } + public string sCol2_MemberGameInfoes { get; set; } + public string sCol3_MemberGameInfoes { get; set; } + public string sCol4_MemberGameInfoes { get; set; } + public string sCol5_MemberGameInfoes { get; set; } + public string sCol6_MemberGameInfoes { get; set; } + public string sCol7_MemberGameInfoes { get; set; } + public string sCol8_MemberGameInfoes { get; set; } + public string sCol9_MemberGameInfoes { get; set; } + public string sCol10_MemberGameInfoes { get; set; } + public string token { get; set; } + } +} \ No newline at end of file From 9c960aa76dfcc843bbc85a8c56b81800f37d121e Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 02:33:22 +0900 Subject: [PATCH 16/36] adding crypt CBSelGameEventsController --- CloudBread.csproj | 1 + Controllers/CBSelGameEventsController.cs | 77 ++++++++++++------------ Models/SelGameEvents.cs | 39 ++++++++++++ 3 files changed, 80 insertions(+), 37 deletions(-) create mode 100644 Models/SelGameEvents.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index 2a64627..cbb23fc 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -304,6 +304,7 @@ + diff --git a/Controllers/CBSelGameEventsController.cs b/Controllers/CBSelGameEventsController.cs index cf814d9..7a73312 100644 --- a/Controllers/CBSelGameEventsController.cs +++ b/Controllers/CBSelGameEventsController.cs @@ -32,54 +32,40 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBSelGameEventsController : ApiController { - - public class InputParams { public string MemberID; } - - public class Model + public HttpResponseMessage Post(SelGameEventsInputParams p) { - public string GameEventID { get; set; } - public string eventCategory1 { get; set; } - public string eventCategory2 { get; set; } - public string eventCategory3 { get; set; } - public string ItemListID { get; set; } - public string ItemCount { get; set; } - public string Itemstatus { get; set; } - public string TargetGroup { get; set; } - public string TargetOS { get; set; } - public string TargetDevice { get; set; } - public string EventImageLink { get; set; } - public string Title { get; set; } - public string Content { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - - } + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } - public List Post(InputParams p) - { // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); - List result = new List(); + List result = new List(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); try { @@ -97,7 +83,7 @@ public List Post(InputParams p) { while (dreader.Read()) { - Model workItem = new Model() + SelGameEventsModel workItem = new SelGameEventsModel() { GameEventID = dreader[0].ToString(), eventCategory1 = dreader[1].ToString(), @@ -129,7 +115,25 @@ public List Post(InputParams p) } connection.Close(); } - return result; + + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(result), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, result); + return response; } } @@ -146,6 +150,5 @@ public List Post(InputParams p) throw; } } - } } diff --git a/Models/SelGameEvents.cs b/Models/SelGameEvents.cs new file mode 100644 index 0000000..911be73 --- /dev/null +++ b/Models/SelGameEvents.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class SelGameEventsInputParams { + public string MemberID { get; set; } + public string token { get; set; } + } + + public class SelGameEventsModel + { + public string GameEventID { get; set; } + public string eventCategory1 { get; set; } + public string eventCategory2 { get; set; } + public string eventCategory3 { get; set; } + public string ItemListID { get; set; } + public string ItemCount { get; set; } + public string Itemstatus { get; set; } + public string TargetGroup { get; set; } + public string TargetOS { get; set; } + public string TargetDevice { get; set; } + public string EventImageLink { get; set; } + public string Title { get; set; } + public string Content { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + } +} \ No newline at end of file From ceb90d0b8527ed12710c3bc56f3815080a582d4f Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 10:36:12 +0900 Subject: [PATCH 17/36] adding crypt CBSelGiftItemToMeController --- CloudBread.csproj | 1 + Controllers/CBSelGiftItemToMeController.cs | 53 +++++++++++----------- Models/SelGiftItemToMe.cs | 32 +++++++++++++ 3 files changed, 59 insertions(+), 27 deletions(-) create mode 100644 Models/SelGiftItemToMe.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index cbb23fc..f07c6f0 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -305,6 +305,7 @@ + diff --git a/Controllers/CBSelGiftItemToMeController.cs b/Controllers/CBSelGiftItemToMeController.cs index 3280cc5..8b56121 100644 --- a/Controllers/CBSelGiftItemToMeController.cs +++ b/Controllers/CBSelGiftItemToMeController.cs @@ -30,44 +30,25 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBSelGiftItemToMeController : ApiController { - public class InputParams { public string MemberID;} - - public class Model - { - public string GiftDepositoryID { get; set; } - public string ItemListID { get; set; } - public string ItemCount { get; set; } - public string FromMemberID { get; set; } - public string ToMemberID { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - } - - public List Post(InputParams p) + public HttpResponseMessage Post(SelGiftItemToMeInputParams p) { // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); - List result = new List(); + List result = new List(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); try { @@ -85,7 +66,7 @@ public List Post(InputParams p) { while (dreader.Read()) { - Model workItem = new Model() + SelGiftItemToMeModel workItem = new SelGiftItemToMeModel() { GiftDepositoryID = dreader[0].ToString(), ItemListID = dreader[1].ToString(), @@ -109,7 +90,25 @@ public List Post(InputParams p) } connection.Close(); } - return result; + + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(result), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, result); + return response; } } diff --git a/Models/SelGiftItemToMe.cs b/Models/SelGiftItemToMe.cs new file mode 100644 index 0000000..665b192 --- /dev/null +++ b/Models/SelGiftItemToMe.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class SelGiftItemToMeInputParams + { + public string MemberID { get; set; } + public string token { get; set; } + } + + public class SelGiftItemToMeModel + { + public string GiftDepositoryID { get; set; } + public string ItemListID { get; set; } + public string ItemCount { get; set; } + public string FromMemberID { get; set; } + public string ToMemberID { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + } +} \ No newline at end of file From 23f2759e8003bcf5529d8251143873491d2e0284 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 10:38:38 +0900 Subject: [PATCH 18/36] fixed crypt CBSelGiftItemToMeController --- Controllers/CBSelGiftItemToMeController.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Controllers/CBSelGiftItemToMeController.cs b/Controllers/CBSelGiftItemToMeController.cs index 8b56121..c5e08bc 100644 --- a/Controllers/CBSelGiftItemToMeController.cs +++ b/Controllers/CBSelGiftItemToMeController.cs @@ -39,6 +39,21 @@ public class CBSelGiftItemToMeController : ApiController { public HttpResponseMessage Post(SelGiftItemToMeInputParams p) { + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } + // Get the sid or memberID of the current user. string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; From cdb7c670dfb4b61f1a1669b5a978b616e36e49e3 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 10:51:23 +0900 Subject: [PATCH 19/36] adding crypt CBSelItem1Controller --- CloudBread.csproj | 1 + Controllers/CBSelItem1Controller.cs | 73 ++++++++++++++++------------- Models/SelItem1.cs | 36 ++++++++++++++ 3 files changed, 77 insertions(+), 33 deletions(-) create mode 100644 Models/SelItem1.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index f07c6f0..b3915d0 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -306,6 +306,7 @@ + diff --git a/Controllers/CBSelItem1Controller.cs b/Controllers/CBSelItem1Controller.cs index 0fe4fca..ce637a7 100644 --- a/Controllers/CBSelItem1Controller.cs +++ b/Controllers/CBSelItem1Controller.cs @@ -32,50 +32,40 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBSelItem1Controller : ApiController { - public class InputParams { - public string MemberID; // log purpose - public string ItemListID; - } - - public class Model + public HttpResponseMessage Post(SelItem1InputParams p) { - public string ItemListID { get; set; } - public string ItemName { get; set; } - public string ItemDescription { get; set; } - public string ItemPrice { get; set; } - public string ItemSellPrice { get; set; } - public string ItemCategory1 { get; set; } - public string ItemCategory2 { get; set; } - public string ItemCategory3 { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - } + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } - public List Post(InputParams p) - { // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); - List result = new List(); + List result = new List(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); try { @@ -93,7 +83,7 @@ public List Post(InputParams p) { while (dreader.Read()) { - Model workItem = new Model() + SelItem1Model workItem = new SelItem1Model() { ItemListID = dreader[0].ToString(), ItemName = dreader[1].ToString(), @@ -120,7 +110,25 @@ public List Post(InputParams p) } connection.Close(); } - return result; + + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(result), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, result); + return response; } } @@ -137,6 +145,5 @@ public List Post(InputParams p) throw; } } - } } diff --git a/Models/SelItem1.cs b/Models/SelItem1.cs new file mode 100644 index 0000000..376157a --- /dev/null +++ b/Models/SelItem1.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class SelItem1InputParams + { + public string MemberID { get; set; } // log purpose + public string ItemListID { get; set; } + public string token { get; set; } + } + + public class SelItem1Model + { + public string ItemListID { get; set; } + public string ItemName { get; set; } + public string ItemDescription { get; set; } + public string ItemPrice { get; set; } + public string ItemSellPrice { get; set; } + public string ItemCategory1 { get; set; } + public string ItemCategory2 { get; set; } + public string ItemCategory3 { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + } +} \ No newline at end of file From 62ffd7640799afdf6bff77f3766407455fb4d192 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 10:59:54 +0900 Subject: [PATCH 20/36] adding crypt CBSelItemListAllController --- CloudBread.csproj | 1 + Controllers/CBSelItemListAllController.cs | 76 ++++++++++++----------- Models/SelItemListAll.cs | 38 ++++++++++++ 3 files changed, 79 insertions(+), 36 deletions(-) create mode 100644 Models/SelItemListAll.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index b3915d0..4a43e6c 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -307,6 +307,7 @@ + diff --git a/Controllers/CBSelItemListAllController.cs b/Controllers/CBSelItemListAllController.cs index 2274ff4..fd12bf4 100644 --- a/Controllers/CBSelItemListAllController.cs +++ b/Controllers/CBSelItemListAllController.cs @@ -32,53 +32,40 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBSelItemListAllController : ApiController { - - public class InputParams { - public string MemberID; // log purpose - public Int64 Page; - public Int64 PageSize;} - - public class Model + public HttpResponseMessage Post(SelItemListAllInputParams p) { - public string ROWNUM { get; set; } - public string ItemListID { get; set; } - public string ItemName { get; set; } - public string ItemDescription { get; set; } - public string ItemPrice { get; set; } - public string ItemSellPrice { get; set; } - public string ItemCategory1 { get; set; } - public string ItemCategory2 { get; set; } - public string ItemCategory3 { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - - } + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } - public List Post(InputParams p) - { // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); - List result = new List(); + List result = new List(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); try { @@ -97,7 +84,7 @@ public List Post(InputParams p) { while (dreader.Read()) { - Model workItem = new Model() + SelItemListAllModel workItem = new SelItemListAllModel() { ROWNUM = dreader[0].ToString(), ItemListID = dreader[1].ToString(), @@ -125,7 +112,25 @@ public List Post(InputParams p) } connection.Close(); } - return result; + + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(result), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, result); + return response; } } @@ -142,6 +147,5 @@ public List Post(InputParams p) throw ex; } } - } } diff --git a/Models/SelItemListAll.cs b/Models/SelItemListAll.cs new file mode 100644 index 0000000..9afad1e --- /dev/null +++ b/Models/SelItemListAll.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class SelItemListAllInputParams + { + public string MemberID { get; set; } // log purpose + public Int64 Page { get; set; } + public Int64 PageSize { get; set; } + public string token { get; set; } + } + + public class SelItemListAllModel + { + public string ROWNUM { get; set; } + public string ItemListID { get; set; } + public string ItemName { get; set; } + public string ItemDescription { get; set; } + public string ItemPrice { get; set; } + public string ItemSellPrice { get; set; } + public string ItemCategory1 { get; set; } + public string ItemCategory2 { get; set; } + public string ItemCategory3 { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + } +} \ No newline at end of file From 162c022e88af303bf8cca17bec7c410f3df1d0d6 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 11:11:08 +0900 Subject: [PATCH 21/36] adding crypt CBSelLoginIDDupeCheckController --- CloudBread.csproj | 1 + .../CBSelLoginIDDupeCheckController.cs | 57 +++++++++++++------ Models/SelLoginIDDupeCheck.cs | 19 +++++++ 3 files changed, 60 insertions(+), 17 deletions(-) create mode 100644 Models/SelLoginIDDupeCheck.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index 4a43e6c..933ccde 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -308,6 +308,7 @@ + diff --git a/Controllers/CBSelLoginIDDupeCheckController.cs b/Controllers/CBSelLoginIDDupeCheckController.cs index 876515c..d6b74db 100644 --- a/Controllers/CBSelLoginIDDupeCheckController.cs +++ b/Controllers/CBSelLoginIDDupeCheckController.cs @@ -31,32 +31,41 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBSelLoginIDDupeCheckController : ApiController { - - public class InputParams { public string memberID;} - - //return json - public class Result { public string result; } - - public Result Post(InputParams p) // //return json + public HttpResponseMessage Post(SelLoginIDDupeCheckInputParams p) { - //return json - //string result = ""; - Result r = new Result(); + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.memberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.memberID, this.User as ClaimsPrincipal); p.memberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); + SelLoginIDDupeCheckResult result = new SelLoginIDDupeCheckResult(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + try { /// Database connection retry policy @@ -72,16 +81,30 @@ public Result Post(InputParams p) // //return json { while (dreader.Read()) { - // change - r.result = dreader[0].ToString(); + result.result = dreader[0].ToString(); } dreader.Close(); } connection.Close(); - // return json - //return result; - return r; + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(result), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, result); + return response; } } } diff --git a/Models/SelLoginIDDupeCheck.cs b/Models/SelLoginIDDupeCheck.cs new file mode 100644 index 0000000..cbe93d0 --- /dev/null +++ b/Models/SelLoginIDDupeCheck.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class SelLoginIDDupeCheckInputParams + { + public string memberID { get; set; } + public string token { get; set; } + } + + //return json + public class SelLoginIDDupeCheckResult + { + public string result { get; set; } + } +} \ No newline at end of file From a23795b11c048cc42c779e6262a7db0bf51b4d2a Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 11:19:51 +0900 Subject: [PATCH 22/36] adding crypt CBSelLoginInfoController --- CloudBread.csproj | 1 + Controllers/CBSelLoginInfoController.cs | 101 +++++++++--------------- Models/SelLoginInfo.cs | 58 ++++++++++++++ 3 files changed, 98 insertions(+), 62 deletions(-) create mode 100644 Models/SelLoginInfo.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index 933ccde..b8233de 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -309,6 +309,7 @@ + diff --git a/Controllers/CBSelLoginInfoController.cs b/Controllers/CBSelLoginInfoController.cs index 49e5945..35d5726 100644 --- a/Controllers/CBSelLoginInfoController.cs +++ b/Controllers/CBSelLoginInfoController.cs @@ -30,76 +30,40 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBSelLoginInfoController : ApiController { - - public class InputParams { - public string memberID; - public string memberPWD; // Consider using 3rd party authentication. If using own autehtication, at least SHA512 from client device. - public string LastDeviceID = ""; - public string LastIPaddress = ""; - public string LastMACAddress=""; - } - - public class Model + public HttpResponseMessage Post(SelLoginInfoInputParams p) { - public string MemberID { get; set; } - public string MemberPWD { get; set; } - public string EmailAddress { get; set; } - public string EmailConfirmedYN { get; set; } - public string PhoneNumber1 { get; set; } - public string PhoneNumber2 { get; set; } - public string PINumber { get; set; } - public string Name1 { get; set; } - public string Name2 { get; set; } - public string Name3 { get; set; } - public string DOB { get; set; } - public string RecommenderID { get; set; } - public string MemberGroup { get; set; } - public string LastDeviceID { get; set; } - public string LastIPaddress { get; set; } - public string LastLoginDT { get; set; } - public string LastLogoutDT { get; set; } - public string LastMACAddress { get; set; } - public string AccountBlockYN { get; set; } - public string AccountBlockEndDT { get; set; } - public string AnonymousYN { get; set; } - - public string _3rdAuthProvider { get; set; } - public string _3rdAuthID { get; set; } - public string _3rdAuthParam { get; set; } - public string PushNotificationID { get; set; } - public string PushNotificationProvider { get; set; } - public string PushNotificationGroup { get; set; } - - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - - } + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } - public List Post(InputParams p) - { // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.memberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.memberID, this.User as ClaimsPrincipal); p.memberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); - List result = new List(); + List result = new List(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); try { @@ -129,7 +93,7 @@ public List Post(InputParams p) { while (dreader.Read()) { - Model workItem = new Model() + SelLoginInfoModel workItem = new SelLoginInfoModel() { MemberID = dreader[0].ToString(), MemberPWD = dreader[1].ToString(), @@ -149,18 +113,15 @@ public List Post(InputParams p) LastLoginDT = dreader[15].ToString(), LastLogoutDT = dreader[16].ToString(), LastMACAddress = dreader[17].ToString(), - AccountBlockYN = dreader[18].ToString(), AccountBlockEndDT = dreader[19].ToString(), AnonymousYN = dreader[20].ToString(), - _3rdAuthProvider = dreader[21].ToString(), _3rdAuthID = dreader[22].ToString(), _3rdAuthParam = dreader[23].ToString(), PushNotificationID = dreader[24].ToString(), PushNotificationProvider = dreader[25].ToString(), PushNotificationGroup = dreader[26].ToString(), - sCol1 = dreader[27].ToString(), sCol2 = dreader[28].ToString(), sCol3 = dreader[29].ToString(), @@ -186,7 +147,24 @@ public List Post(InputParams p) Logging.RunLog(logMessage); } - return result; + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(result), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, result); + return response; } } @@ -203,6 +181,5 @@ public List Post(InputParams p) throw; } } - } } diff --git a/Models/SelLoginInfo.cs b/Models/SelLoginInfo.cs new file mode 100644 index 0000000..d156c61 --- /dev/null +++ b/Models/SelLoginInfo.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class SelLoginInfoInputParams + { + public string memberID { get; set; } + public string memberPWD { get; set; } // Consider using 3rd party authentication. If using own autehtication, at least SHA512 from client device. + public string LastDeviceID { get; set; } + public string LastIPaddress { get; set; } + public string LastMACAddress { get; set; } + public string token { get; set; } + } + + public class SelLoginInfoModel + { + public string MemberID { get; set; } + public string MemberPWD { get; set; } + public string EmailAddress { get; set; } + public string EmailConfirmedYN { get; set; } + public string PhoneNumber1 { get; set; } + public string PhoneNumber2 { get; set; } + public string PINumber { get; set; } + public string Name1 { get; set; } + public string Name2 { get; set; } + public string Name3 { get; set; } + public string DOB { get; set; } + public string RecommenderID { get; set; } + public string MemberGroup { get; set; } + public string LastDeviceID { get; set; } + public string LastIPaddress { get; set; } + public string LastLoginDT { get; set; } + public string LastLogoutDT { get; set; } + public string LastMACAddress { get; set; } + public string AccountBlockYN { get; set; } + public string AccountBlockEndDT { get; set; } + public string AnonymousYN { get; set; } + public string _3rdAuthProvider { get; set; } + public string _3rdAuthID { get; set; } + public string _3rdAuthParam { get; set; } + public string PushNotificationID { get; set; } + public string PushNotificationProvider { get; set; } + public string PushNotificationGroup { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + } +} \ No newline at end of file From 6ba2e7445c5c4d75153a14bc85d92b806adb010e Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 11:26:06 +0900 Subject: [PATCH 23/36] adding CBSelMemberGameInfoStagesController --- CloudBread.csproj | 1 + .../CBSelMemberGameInfoStagesController.cs | 82 +++++++++---------- Models/SelMemberGameInfoStages.cs | 45 ++++++++++ 3 files changed, 86 insertions(+), 42 deletions(-) create mode 100644 Models/SelMemberGameInfoStages.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index b8233de..a54ae59 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -310,6 +310,7 @@ + diff --git a/Controllers/CBSelMemberGameInfoStagesController.cs b/Controllers/CBSelMemberGameInfoStagesController.cs index 26b9663..db7cf5c 100644 --- a/Controllers/CBSelMemberGameInfoStagesController.cs +++ b/Controllers/CBSelMemberGameInfoStagesController.cs @@ -30,60 +30,40 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBSelMemberGameInfoStagesController : ApiController { - - public class InputParams { public string memberID;} - - public class Model + public HttpResponseMessage Post(SelMemberGameInfoStagesInputParams p) { - public string MemberGameInfoStageID { get; set; } - public string MemberID { get; set; } - public string StageName { get; set; } - public string StageStatus { get; set; } - public string Category1 { get; set; } - public string Category2 { get; set; } - public string Category3 { get; set; } - public string Mission1 { get; set; } - public string Mission2 { get; set; } - public string Mission3 { get; set; } - public string Mission4 { get; set; } - public string Mission5 { get; set; } - public string Points { get; set; } - public string StageStat1 { get; set; } - public string StageStat2 { get; set; } - public string StageStat3 { get; set; } - public string StageStat4 { get; set; } - public string StageStat5 { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - - - } + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } - public List Post(InputParams p) - { // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.memberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.memberID, this.User as ClaimsPrincipal); p.memberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); - List result = new List(); + List result = new List(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); try { @@ -101,7 +81,7 @@ public List Post(InputParams p) { while (dreader.Read()) { - Model workItem = new Model() + SelMemberGameInfoStagesModel workItem = new SelMemberGameInfoStagesModel() { MemberGameInfoStageID = dreader[0].ToString(), MemberID = dreader[1].ToString(), @@ -139,7 +119,25 @@ public List Post(InputParams p) } connection.Close(); } - return result; + + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(result), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, result); + return response; } } diff --git a/Models/SelMemberGameInfoStages.cs b/Models/SelMemberGameInfoStages.cs new file mode 100644 index 0000000..0873fbe --- /dev/null +++ b/Models/SelMemberGameInfoStages.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class SelMemberGameInfoStagesInputParams + { + public string memberID { get; set; } + public string token { get; set; } + } + + public class SelMemberGameInfoStagesModel + { + public string MemberGameInfoStageID { get; set; } + public string MemberID { get; set; } + public string StageName { get; set; } + public string StageStatus { get; set; } + public string Category1 { get; set; } + public string Category2 { get; set; } + public string Category3 { get; set; } + public string Mission1 { get; set; } + public string Mission2 { get; set; } + public string Mission3 { get; set; } + public string Mission4 { get; set; } + public string Mission5 { get; set; } + public string Points { get; set; } + public string StageStat1 { get; set; } + public string StageStat2 { get; set; } + public string StageStat3 { get; set; } + public string StageStat4 { get; set; } + public string StageStat5 { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + } +} \ No newline at end of file From 15cfa45887cf6a726b7ed3251dd6150051849bff Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 11:32:29 +0900 Subject: [PATCH 24/36] adding crypt CBSelMemberItemsController --- CloudBread.csproj | 1 + Controllers/CBSelMemberItemsController.cs | 91 ++++++++++------------- Models/SelMemberItems.cs | 52 +++++++++++++ 3 files changed, 93 insertions(+), 51 deletions(-) create mode 100644 Models/SelMemberItems.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index a54ae59..e895684 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -311,6 +311,7 @@ + diff --git a/Controllers/CBSelMemberItemsController.cs b/Controllers/CBSelMemberItemsController.cs index ec79cd4..57f780f 100644 --- a/Controllers/CBSelMemberItemsController.cs +++ b/Controllers/CBSelMemberItemsController.cs @@ -32,67 +32,40 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBSelMemberItemsController : ApiController { - public class InputParams { - public string MemberID; - public Int64 Page; - public Int64 PageSize; - } - - public class Model + public HttpResponseMessage Post(SelMemberItemsInputParams p) { - public string ROWNUM { get; set; } - public string ItemListsItemName { get; set; } - public string ItemListsItemDescription { get; set; } - public string ItemListsItemPrice { get; set; } - public string ItemListsItemSellPrice { get; set; } - public string ItemListsItemCategory1 { get; set; } - public string ItemListsItemCategory2 { get; set; } - public string ItemListsItemCategory3 { get; set; } - public string ItemListssCol1 { get; set; } - public string ItemListssCol2 { get; set; } - public string ItemListssCol3 { get; set; } - public string ItemListssCol4 { get; set; } - public string ItemListssCol5 { get; set; } - public string ItemListssCol6 { get; set; } - public string ItemListssCol7 { get; set; } - public string ItemListssCol8 { get; set; } - public string ItemListssCol9 { get; set; } - public string ItemListssCol10 { get; set; } - public string MemberItemsMemberItemID { get; set; } - public string MemberItemsMemberID { get; set; } - public string MemberItemsItemListID { get; set; } - public string MemberItemsItemCount { get; set; } - public string MemberItemsItemStatus { get; set; } - public string MemberItemssCol1 { get; set; } - public string MemberItemssCol2 { get; set; } - public string MemberItemssCol3 { get; set; } - public string MemberItemssCol4 { get; set; } - public string MemberItemssCol5 { get; set; } - public string MemberItemssCol6 { get; set; } - public string MemberItemssCol7 { get; set; } - public string MemberItemssCol8 { get; set; } - public string MemberItemssCol9 { get; set; } - public string MemberItemssCol10 { get; set; } - - } + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } - public List Post(InputParams p) - { // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); - List result = new List(); + List result = new List(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); try { @@ -112,7 +85,7 @@ public List Post(InputParams p) { while (dreader.Read()) { - Model workItem = new Model() + SelMemberItemsModel workItem = new SelMemberItemsModel() { ROWNUM = dreader[0].ToString(), ItemListsItemName = dreader[1].ToString(), @@ -147,7 +120,6 @@ public List Post(InputParams p) MemberItemssCol8 = dreader[30].ToString(), MemberItemssCol9 = dreader[31].ToString(), MemberItemssCol10 = dreader[32].ToString() - }; result.Add(workItem); } @@ -155,7 +127,25 @@ public List Post(InputParams p) } connection.Close(); } - return result; + + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(result), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, result); + return response; } } @@ -172,6 +162,5 @@ public List Post(InputParams p) throw; } } - } } diff --git a/Models/SelMemberItems.cs b/Models/SelMemberItems.cs new file mode 100644 index 0000000..56a39b6 --- /dev/null +++ b/Models/SelMemberItems.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class SelMemberItemsInputParams + { + public string MemberID { get; set; } + public Int64 Page { get; set; } + public Int64 PageSize { get; set; } + public string token { get; set; } + } + + public class SelMemberItemsModel + { + public string ROWNUM { get; set; } + public string ItemListsItemName { get; set; } + public string ItemListsItemDescription { get; set; } + public string ItemListsItemPrice { get; set; } + public string ItemListsItemSellPrice { get; set; } + public string ItemListsItemCategory1 { get; set; } + public string ItemListsItemCategory2 { get; set; } + public string ItemListsItemCategory3 { get; set; } + public string ItemListssCol1 { get; set; } + public string ItemListssCol2 { get; set; } + public string ItemListssCol3 { get; set; } + public string ItemListssCol4 { get; set; } + public string ItemListssCol5 { get; set; } + public string ItemListssCol6 { get; set; } + public string ItemListssCol7 { get; set; } + public string ItemListssCol8 { get; set; } + public string ItemListssCol9 { get; set; } + public string ItemListssCol10 { get; set; } + public string MemberItemsMemberItemID { get; set; } + public string MemberItemsMemberID { get; set; } + public string MemberItemsItemListID { get; set; } + public string MemberItemsItemCount { get; set; } + public string MemberItemsItemStatus { get; set; } + public string MemberItemssCol1 { get; set; } + public string MemberItemssCol2 { get; set; } + public string MemberItemssCol3 { get; set; } + public string MemberItemssCol4 { get; set; } + public string MemberItemssCol5 { get; set; } + public string MemberItemssCol6 { get; set; } + public string MemberItemssCol7 { get; set; } + public string MemberItemssCol8 { get; set; } + public string MemberItemssCol9 { get; set; } + public string MemberItemssCol10 { get; set; } + } +} \ No newline at end of file From d44df18f96f1045b0e2ee5fe73fc5d57cb5ac7c7 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 12:33:17 +0900 Subject: [PATCH 25/36] adding crypt CBSelSendEmailToMemberController --- CloudBread.csproj | 1 + .../CBSelSendEmailToMemberController.cs | 54 ++++++++++++++----- Models/SelSendEmailToMember.cs | 13 +++++ 3 files changed, 55 insertions(+), 13 deletions(-) create mode 100644 Models/SelSendEmailToMember.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index e895684..0e10746 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -313,6 +313,7 @@ + diff --git a/Controllers/CBSelSendEmailToMemberController.cs b/Controllers/CBSelSendEmailToMemberController.cs index fd458e0..89a7bf4 100644 --- a/Controllers/CBSelSendEmailToMemberController.cs +++ b/Controllers/CBSelSendEmailToMemberController.cs @@ -34,29 +34,42 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBSelSendEmailToMemberController : ApiController { - - string result =""; - public class InputParams { - public string memberID; - } - - public string Post(InputParams p) + public HttpResponseMessage Post(SelSendEmailToMemberInputParams p) { + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } + // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.memberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.memberID, this.User as ClaimsPrincipal); p.memberID = sid; // check proper authentication of member who trigger this API (Admin or member with authorized) Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + RowcountResult rowcountResult = new RowcountResult(); + try { /// Database connection retry policy @@ -72,7 +85,7 @@ public string Post(InputParams p) { while (dreader.Read()) { - result = dreader[0].ToString(); + rowcountResult.result = dreader[0].ToString(); } ////////////////////////////////////////////////////////////////////////////////////// //// mail sending module - reference CloudBreadlib/BAL/SendSMTPMail @@ -85,9 +98,25 @@ public string Post(InputParams p) } connection.Close(); - return result; // or return mail send result string s - } + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowcountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); + return response; // or return mail send result string s + } } } @@ -104,6 +133,5 @@ public string Post(InputParams p) throw ; } } - } } diff --git a/Models/SelSendEmailToMember.cs b/Models/SelSendEmailToMember.cs new file mode 100644 index 0000000..174ce7f --- /dev/null +++ b/Models/SelSendEmailToMember.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class SelSendEmailToMemberInputParams + { + public string memberID { get; set; } + public string token { get; set; } + } +} \ No newline at end of file From 92406ef6d46f6ca36113774b1955c22462dd86f1 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 12:42:22 +0900 Subject: [PATCH 26/36] fixed deplicated API - CBUdtConfirmedEmailAddressController --- Controllers/CBSocketAuthController.cs | 3 +- .../CBUdtConfirmedEmailAddressController.cs | 161 +++++++++--------- 2 files changed, 83 insertions(+), 81 deletions(-) diff --git a/Controllers/CBSocketAuthController.cs b/Controllers/CBSocketAuthController.cs index e3a2616..831997f 100644 --- a/Controllers/CBSocketAuthController.cs +++ b/Controllers/CBSocketAuthController.cs @@ -50,8 +50,7 @@ public Payload Get() Payload payload = new Payload(); /// Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID("debug", claimsPrincipal); // only for log + string sid = CBAuth.getMemberID("debug", this.User as ClaimsPrincipal); // only for log payload.sid = sid; /// logging purpose diff --git a/Controllers/CBUdtConfirmedEmailAddressController.cs b/Controllers/CBUdtConfirmedEmailAddressController.cs index 89658b1..9526d0b 100644 --- a/Controllers/CBUdtConfirmedEmailAddressController.cs +++ b/Controllers/CBUdtConfirmedEmailAddressController.cs @@ -2,6 +2,9 @@ * @file CBUdtConfirmedEmailAddressController.cs * @brief !not implemented \n * Confirm email address of member. \n + +* Do not need this API in CloudBread v2. This API is deplicated in v2. + * Need todo : this controller made for email address validate and confirmation. \n * This controller could be accessed with mobile browser(without appkey authentication). \n * It has to be seperated in mobile app appkey authentication and provide hashed string for member email address param. \n @@ -12,94 +15,94 @@ * @todo implement code logic */ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Web.Http; -using Microsoft.Azure.Mobile.Server; -using Microsoft.Azure.Mobile.Server.Config; +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Net; +//using System.Net.Http; +//using System.Web.Http; +//using Microsoft.Azure.Mobile.Server; +//using Microsoft.Azure.Mobile.Server.Config; -using System.Threading.Tasks; -using System.Diagnostics; -using Logger.Logging; -using CloudBread.globals; -using CloudBreadLib.BAL.Crypto; -using System.Data; -using System.Data.Sql; -using System.Data.SqlClient; -using Newtonsoft.Json; -using CloudBreadAuth; -using System.Security.Claims; -using Microsoft.Practices.TransientFaultHandling; -using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +//using System.Threading.Tasks; +//using System.Diagnostics; +//using Logger.Logging; +//using CloudBread.globals; +//using CloudBreadLib.BAL.Crypto; +//using System.Data; +//using System.Data.Sql; +//using System.Data.SqlClient; +//using Newtonsoft.Json; +//using CloudBreadAuth; +//using System.Security.Claims; +//using Microsoft.Practices.TransientFaultHandling; +//using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; -namespace CloudBread.Controllers -{ - // detour mobile app appkey authentication - [MobileAppController] - public class CBUdtConfirmedEmailAddressController : ApiController - { - string result; +//namespace CloudBread.Controllers +//{ +// // detour mobile app appkey authentication +// [MobileAppController] +// public class CBUdtConfirmedEmailAddressController : ApiController +// { +// string result; - public class InputParams { - public string memberID; // todo list - public string memberPWD; - } +// public class InputParams { +// public string memberID; // todo list +// public string memberPWD; // not working in CloudBread v2. +// } - public string Post(InputParams p) - { - // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.memberID, claimsPrincipal); - p.memberID = sid; +// public string Post(InputParams p) +// { +// // Get the sid or memberID of the current user. +// var claimsPrincipal = this.User as ClaimsPrincipal; +// string sid = CBAuth.getMemberID(p.memberID, claimsPrincipal); +// p.memberID = sid; - Logging.CBLoggers logMessage = new Logging.CBLoggers(); - string jsonParam = JsonConvert.SerializeObject(p); +// Logging.CBLoggers logMessage = new Logging.CBLoggers(); +// string jsonParam = JsonConvert.SerializeObject(p); - try - { - /// Database connection retry policy - RetryPolicy retryPolicy = new RetryPolicy(globalVal.conRetryCount, TimeSpan.FromSeconds(globalVal.conRetryFromSeconds)); - using (SqlConnection connection = new SqlConnection(globalVal.DBConnectionString)) - { - using (SqlCommand command = new SqlCommand("uspUdtConfirmedEmailAddress", connection)) - { - command.CommandType = CommandType.StoredProcedure; - command.Parameters.Add("@MemberID", SqlDbType.NVarChar, -1).Value = p.memberID; - command.Parameters.Add("@MemberPWD", SqlDbType.NVarChar, -1).Value = p.memberPWD; /// do not use v2.0.0 - connection.OpenWithRetry(retryPolicy); - using (SqlDataReader dreader = command.ExecuteReaderWithRetry(retryPolicy)) - { - while (dreader.Read()) - { - result = dreader[0].ToString(); - } +// try +// { +// /// Database connection retry policy +// RetryPolicy retryPolicy = new RetryPolicy(globalVal.conRetryCount, TimeSpan.FromSeconds(globalVal.conRetryFromSeconds)); +// using (SqlConnection connection = new SqlConnection(globalVal.DBConnectionString)) +// { +// using (SqlCommand command = new SqlCommand("uspUdtConfirmedEmailAddress", connection)) +// { +// command.CommandType = CommandType.StoredProcedure; +// command.Parameters.Add("@MemberID", SqlDbType.NVarChar, -1).Value = p.memberID; +// command.Parameters.Add("@MemberPWD", SqlDbType.NVarChar, -1).Value = p.memberPWD; /// do not use v2.0.0 +// connection.OpenWithRetry(retryPolicy); +// using (SqlDataReader dreader = command.ExecuteReaderWithRetry(retryPolicy)) +// { +// while (dreader.Read()) +// { +// result = dreader[0].ToString(); +// } - dreader.Close(); - } - connection.Close(); +// dreader.Close(); +// } +// connection.Close(); - return result; - } +// return result; +// } - } - } +// } +// } - catch (Exception ex) - { - // error log - logMessage.memberID = p.memberID; - logMessage.Level = "ERROR"; - logMessage.Logger = "CBUdtConfirmedEmailAddressController"; - logMessage.Message = jsonParam; - logMessage.Exception = ex.ToString(); - Logging.RunLog(logMessage); +// catch (Exception ex) +// { +// // error log +// logMessage.memberID = p.memberID; +// logMessage.Level = "ERROR"; +// logMessage.Logger = "CBUdtConfirmedEmailAddressController"; +// logMessage.Message = jsonParam; +// logMessage.Exception = ex.ToString(); +// Logging.RunLog(logMessage); - throw; - } - } +// throw; +// } +// } - } -} +// } +//} From 12f87042f2e46f589db74edc4d817c57451a2d64 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 12:46:29 +0900 Subject: [PATCH 27/36] adding crypt CBUdtCouponMemberController --- CloudBread.csproj | 1 + Controllers/CBUdtCouponMemberController.cs | 84 +++++++++++----------- Models/UdtCouponMember.cs | 41 +++++++++++ 3 files changed, 82 insertions(+), 44 deletions(-) create mode 100644 Models/UdtCouponMember.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index 0e10746..6beb5c4 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -314,6 +314,7 @@ + diff --git a/Controllers/CBUdtCouponMemberController.cs b/Controllers/CBUdtCouponMemberController.cs index 00cd926..f8c6106 100644 --- a/Controllers/CBUdtCouponMemberController.cs +++ b/Controllers/CBUdtCouponMemberController.cs @@ -36,60 +36,42 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBUdtCouponMemberController : ApiController { - - public class InputParams + public HttpResponseMessage Post(UdtCouponMemberInputParams p) { - public string InsertORUpdate { get; set; } - public string CouponID_Coupon { get; set; } - public string MemberItemID_MemberItems { get; set; } - public string MemberID_MemberItems { get; set; } - public string ItemListID_MemberItems { get; set; } - public string ItemCount_MemberItems { get; set; } - public string ItemStatus_MemberItems { get; set; } - public string sCol1_MemberItems { get; set; } - public string sCol2_MemberItems { get; set; } - public string sCol3_MemberItems { get; set; } - public string sCol4_MemberItems { get; set; } - public string sCol5_MemberItems { get; set; } - public string sCol6_MemberItems { get; set; } - public string sCol7_MemberItems { get; set; } - public string sCol8_MemberItems { get; set; } - public string sCol9_MemberItems { get; set; } - public string sCol10_MemberItems { get; set; } - public string CouponID_CouponMember { get; set; } - public string MemberID_CouponMember { get; set; } - public string sCol1_CouponMember { get; set; } - public string sCol2_CouponMember { get; set; } - public string sCol3_CouponMember { get; set; } - public string sCol4_CouponMember { get; set; } - public string sCol5_CouponMember { get; set; } - public string sCol6_CouponMember { get; set; } - public string sCol7_CouponMember { get; set; } - public string sCol8_CouponMember { get; set; } - public string sCol9_CouponMember { get; set; } - public string sCol10_CouponMember { get; set; } - - } - - public string Post(InputParams p) - { - string result = ""; + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID_CouponMember, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID_CouponMember, this.User as ClaimsPrincipal); p.MemberID_CouponMember = sid; p.MemberID_MemberItems = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + RowcountResult rowcountResult = new RowcountResult(); + try { // start task log @@ -105,7 +87,6 @@ public string Post(InputParams p) { using (SqlCommand command = new SqlCommand("uspUdtCouponMember", connection)) { - command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@InsertORUpdate", SqlDbType.NVarChar, -1).Value = p.InsertORUpdate.ToUpper(); // or GAMEINFO command.Parameters.Add("@CouponID_Coupon", SqlDbType.NVarChar, -1).Value = p.CouponID_Coupon; @@ -142,7 +123,7 @@ public string Post(InputParams p) { while (dreader.Read()) { - result = dreader[0].ToString(); + rowcountResult.result = dreader[0].ToString(); } dreader.Close(); } @@ -155,9 +136,25 @@ public string Post(InputParams p) logMessage.Message = jsonParam; Logging.RunLog(logMessage); - return result; - } + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowcountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); + return response; + } } } @@ -174,6 +171,5 @@ public string Post(InputParams p) throw; } } - } } diff --git a/Models/UdtCouponMember.cs b/Models/UdtCouponMember.cs new file mode 100644 index 0000000..c9712c2 --- /dev/null +++ b/Models/UdtCouponMember.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class UdtCouponMemberInputParams + { + public string InsertORUpdate { get; set; } + public string CouponID_Coupon { get; set; } + public string MemberItemID_MemberItems { get; set; } + public string MemberID_MemberItems { get; set; } + public string ItemListID_MemberItems { get; set; } + public string ItemCount_MemberItems { get; set; } + public string ItemStatus_MemberItems { get; set; } + public string sCol1_MemberItems { get; set; } + public string sCol2_MemberItems { get; set; } + public string sCol3_MemberItems { get; set; } + public string sCol4_MemberItems { get; set; } + public string sCol5_MemberItems { get; set; } + public string sCol6_MemberItems { get; set; } + public string sCol7_MemberItems { get; set; } + public string sCol8_MemberItems { get; set; } + public string sCol9_MemberItems { get; set; } + public string sCol10_MemberItems { get; set; } + public string CouponID_CouponMember { get; set; } + public string MemberID_CouponMember { get; set; } + public string sCol1_CouponMember { get; set; } + public string sCol2_CouponMember { get; set; } + public string sCol3_CouponMember { get; set; } + public string sCol4_CouponMember { get; set; } + public string sCol5_CouponMember { get; set; } + public string sCol6_CouponMember { get; set; } + public string sCol7_CouponMember { get; set; } + public string sCol8_CouponMember { get; set; } + public string sCol9_CouponMember { get; set; } + public string sCol10_CouponMember { get; set; } + public string token { get; set; } + } +} \ No newline at end of file From dfcd4b7e730e24d173d0cdae873abd064ba1ca1d Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 12:55:08 +0900 Subject: [PATCH 28/36] adding crypt CBUdtGameEventMemberToItemController --- CloudBread.csproj | 1 + .../CBUdtGameEventMemberToItemController.cs | 82 +++++++++---------- Models/UdtGameEventMemberToItem.cs | 40 +++++++++ 3 files changed, 81 insertions(+), 42 deletions(-) create mode 100644 Models/UdtGameEventMemberToItem.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index 6beb5c4..8acd4b0 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -315,6 +315,7 @@ + diff --git a/Controllers/CBUdtGameEventMemberToItemController.cs b/Controllers/CBUdtGameEventMemberToItemController.cs index 7f734b3..137253a 100644 --- a/Controllers/CBUdtGameEventMemberToItemController.cs +++ b/Controllers/CBUdtGameEventMemberToItemController.cs @@ -32,59 +32,42 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBUdtGameEventMemberToItemController : ApiController { - - public class InputParams + public HttpResponseMessage Post(UdtGameEventMemberToItemInputParams p) { - public string InsertORUpdate { get; set; } - public string MemberItemID_MemberItems { get; set; } - public string MemberID_MemberItems { get; set; } - public string ItemListID_MemberItems { get; set; } - public string ItemCount_MemberItems { get; set; } - public string ItemStatus_MemberItems { get; set; } - public string sCol1_MemberItems { get; set; } - public string sCol2_MemberItems { get; set; } - public string sCol3_MemberItems { get; set; } - public string sCol4_MemberItems { get; set; } - public string sCol5_MemberItems { get; set; } - public string sCol6_MemberItems { get; set; } - public string sCol7_MemberItems { get; set; } - public string sCol8_MemberItems { get; set; } - public string sCol9_MemberItems { get; set; } - public string sCol10_MemberItems { get; set; } - public string eventID_GameEventMember { get; set; } - public string MemberID_GameEventMember { get; set; } - public string sCol1_GameEventMember { get; set; } - public string sCol2_GameEventMember { get; set; } - public string sCol3_GameEventMember { get; set; } - public string sCol4_GameEventMember { get; set; } - public string sCol5_GameEventMember { get; set; } - public string sCol6_GameEventMember { get; set; } - public string sCol7_GameEventMember { get; set; } - public string sCol8_GameEventMember { get; set; } - public string sCol9_GameEventMember { get; set; } - public string sCol10_GameEventMember { get; set; } - - } - - public string Post(InputParams p) - { - string result = ""; + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID_MemberItems, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID_MemberItems, this.User as ClaimsPrincipal); p.MemberID_MemberItems = sid; p.MemberID_GameEventMember = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + RowcountResult rowcountResult = new RowcountResult(); + try { // start task log @@ -100,7 +83,6 @@ public string Post(InputParams p) { using (SqlCommand command = new SqlCommand("uspUdtGameEventMemberToItem", connection)) { - command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@InsertORUpdate ", SqlDbType.NVarChar, -1).Value = p.InsertORUpdate.ToUpper(); command.Parameters.Add("@MemberItemID_MemberItems ", SqlDbType.NVarChar, -1).Value = p.MemberItemID_MemberItems; @@ -136,7 +118,7 @@ public string Post(InputParams p) { while (dreader.Read()) { - result = dreader[0].ToString(); + rowcountResult.result = dreader[0].ToString(); } dreader.Close(); } @@ -149,7 +131,24 @@ public string Post(InputParams p) logMessage.Message = jsonParam; Logging.RunLog(logMessage); - return result; + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowcountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); + return response; } } } @@ -167,6 +166,5 @@ public string Post(InputParams p) throw; } } - } } diff --git a/Models/UdtGameEventMemberToItem.cs b/Models/UdtGameEventMemberToItem.cs new file mode 100644 index 0000000..f25a00a --- /dev/null +++ b/Models/UdtGameEventMemberToItem.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class UdtGameEventMemberToItemInputParams + { + public string InsertORUpdate { get; set; } + public string MemberItemID_MemberItems { get; set; } + public string MemberID_MemberItems { get; set; } + public string ItemListID_MemberItems { get; set; } + public string ItemCount_MemberItems { get; set; } + public string ItemStatus_MemberItems { get; set; } + public string sCol1_MemberItems { get; set; } + public string sCol2_MemberItems { get; set; } + public string sCol3_MemberItems { get; set; } + public string sCol4_MemberItems { get; set; } + public string sCol5_MemberItems { get; set; } + public string sCol6_MemberItems { get; set; } + public string sCol7_MemberItems { get; set; } + public string sCol8_MemberItems { get; set; } + public string sCol9_MemberItems { get; set; } + public string sCol10_MemberItems { get; set; } + public string eventID_GameEventMember { get; set; } + public string MemberID_GameEventMember { get; set; } + public string sCol1_GameEventMember { get; set; } + public string sCol2_GameEventMember { get; set; } + public string sCol3_GameEventMember { get; set; } + public string sCol4_GameEventMember { get; set; } + public string sCol5_GameEventMember { get; set; } + public string sCol6_GameEventMember { get; set; } + public string sCol7_GameEventMember { get; set; } + public string sCol8_GameEventMember { get; set; } + public string sCol9_GameEventMember { get; set; } + public string sCol10_GameEventMember { get; set; } + public string token { get; set; } + } +} \ No newline at end of file From b74a3a54430c03cb68f1c70365775474d2fa3415 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 13:01:56 +0900 Subject: [PATCH 29/36] adding crypt CBUdtMemberGameInfoStageController --- CloudBread.csproj | 1 + .../CBUdtMemberGameInfoStageController.cs | 110 +++++++----------- Models/UdtMemberGameInfoStage.cs | 65 +++++++++++ 3 files changed, 106 insertions(+), 70 deletions(-) create mode 100644 Models/UdtMemberGameInfoStage.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index 8acd4b0..afd60f2 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -316,6 +316,7 @@ + diff --git a/Controllers/CBUdtMemberGameInfoStageController.cs b/Controllers/CBUdtMemberGameInfoStageController.cs index 3652366..ecc2b59 100644 --- a/Controllers/CBUdtMemberGameInfoStageController.cs +++ b/Controllers/CBUdtMemberGameInfoStageController.cs @@ -31,86 +31,42 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBUdtMemberGameInfoStageController : ApiController { - - public class InputParams + public HttpResponseMessage Post(UdtMemberGameInfoStageInputParams p) { - public string InsertORUpdate { get; set; } - public string MemberID_MemberGameInfoes { get; set; } - public string Level_MemberGameInfoes { get; set; } - public string Exps_MemberGameInfoes { get; set; } - public string Points_MemberGameInfoes { get; set; } - public string UserSTAT1_MemberGameInfoes { get; set; } - public string UserSTAT2_MemberGameInfoes { get; set; } - public string UserSTAT3_MemberGameInfoes { get; set; } - public string UserSTAT4_MemberGameInfoes { get; set; } - public string UserSTAT5_MemberGameInfoes { get; set; } - public string UserSTAT6_MemberGameInfoes { get; set; } - public string UserSTAT7_MemberGameInfoes { get; set; } - public string UserSTAT8_MemberGameInfoes { get; set; } - public string UserSTAT9_MemberGameInfoes { get; set; } - public string UserSTAT10_MemberGameInfoes { get; set; } - public string sCol1_MemberGameInfoes { get; set; } - public string sCol2_MemberGameInfoes { get; set; } - public string sCol3_MemberGameInfoes { get; set; } - public string sCol4_MemberGameInfoes { get; set; } - public string sCol5_MemberGameInfoes { get; set; } - public string sCol6_MemberGameInfoes { get; set; } - public string sCol7_MemberGameInfoes { get; set; } - public string sCol8_MemberGameInfoes { get; set; } - public string sCol9_MemberGameInfoes { get; set; } - public string sCol10_MemberGameInfoes { get; set; } - public string MemberGameInfoStageID_MemberGameInfoStages { get; set; } - public string MemberID_MemberGameInfoStages { get; set; } - public string StageName_MemberGameInfoStages { get; set; } - public string StageStatus_MemberGameInfoStages { get; set; } - public string Category1_MemberGameInfoStages { get; set; } - public string Category2_MemberGameInfoStages { get; set; } - public string Category3_MemberGameInfoStages { get; set; } - public string Mission1_MemberGameInfoStages { get; set; } - public string Mission2_MemberGameInfoStages { get; set; } - public string Mission3_MemberGameInfoStages { get; set; } - public string Mission4_MemberGameInfoStages { get; set; } - public string Mission5_MemberGameInfoStages { get; set; } - public string Points_MemberGameInfoStages { get; set; } - public string StageStat1_MemberGameInfoStages { get; set; } - public string StageStat2_MemberGameInfoStages { get; set; } - public string StageStat3_MemberGameInfoStages { get; set; } - public string StageStat4_MemberGameInfoStages { get; set; } - public string StageStat5_MemberGameInfoStages { get; set; } - public string sCol1_MemberGameInfoStages { get; set; } - public string sCol2_MemberGameInfoStages { get; set; } - public string sCol3_MemberGameInfoStages { get; set; } - public string sCol4_MemberGameInfoStages { get; set; } - public string sCol5_MemberGameInfoStages { get; set; } - public string sCol6_MemberGameInfoStages { get; set; } - public string sCol7_MemberGameInfoStages { get; set; } - public string sCol8_MemberGameInfoStages { get; set; } - public string sCol9_MemberGameInfoStages { get; set; } - public string sCol10_MemberGameInfoStages { get; set; } - - - - } - - public string Post(InputParams p) - { - string result = ""; + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID_MemberGameInfoes, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID_MemberGameInfoes, this.User as ClaimsPrincipal); p.MemberID_MemberGameInfoes = sid; p.MemberID_MemberGameInfoStages = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + RowcountResult rowcountResult = new RowcountResult(); + try { // task start log @@ -126,7 +82,6 @@ public string Post(InputParams p) { using (SqlCommand command = new SqlCommand("uspUdtMemberGameInfoStage", connection)) { - command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@InsertORUpdate", SqlDbType.NVarChar, -1).Value = p.InsertORUpdate.ToUpper(); command.Parameters.Add("@MemberID_MemberGameInfoes", SqlDbType.NVarChar, -1).Value = p.MemberID_MemberGameInfoes; @@ -187,7 +142,7 @@ public string Post(InputParams p) { while (dreader.Read()) { - result = dreader[0].ToString(); + rowcountResult.result = dreader[0].ToString(); } dreader.Close(); } @@ -200,9 +155,25 @@ public string Post(InputParams p) logMessage.Message = jsonParam; Logging.RunLog(logMessage); - return result; - } + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowcountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); + return response; + } } } @@ -219,6 +190,5 @@ public string Post(InputParams p) throw; } } - } } diff --git a/Models/UdtMemberGameInfoStage.cs b/Models/UdtMemberGameInfoStage.cs new file mode 100644 index 0000000..18b99b7 --- /dev/null +++ b/Models/UdtMemberGameInfoStage.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class UdtMemberGameInfoStageInputParams + { + public string InsertORUpdate { get; set; } + public string MemberID_MemberGameInfoes { get; set; } + public string Level_MemberGameInfoes { get; set; } + public string Exps_MemberGameInfoes { get; set; } + public string Points_MemberGameInfoes { get; set; } + public string UserSTAT1_MemberGameInfoes { get; set; } + public string UserSTAT2_MemberGameInfoes { get; set; } + public string UserSTAT3_MemberGameInfoes { get; set; } + public string UserSTAT4_MemberGameInfoes { get; set; } + public string UserSTAT5_MemberGameInfoes { get; set; } + public string UserSTAT6_MemberGameInfoes { get; set; } + public string UserSTAT7_MemberGameInfoes { get; set; } + public string UserSTAT8_MemberGameInfoes { get; set; } + public string UserSTAT9_MemberGameInfoes { get; set; } + public string UserSTAT10_MemberGameInfoes { get; set; } + public string sCol1_MemberGameInfoes { get; set; } + public string sCol2_MemberGameInfoes { get; set; } + public string sCol3_MemberGameInfoes { get; set; } + public string sCol4_MemberGameInfoes { get; set; } + public string sCol5_MemberGameInfoes { get; set; } + public string sCol6_MemberGameInfoes { get; set; } + public string sCol7_MemberGameInfoes { get; set; } + public string sCol8_MemberGameInfoes { get; set; } + public string sCol9_MemberGameInfoes { get; set; } + public string sCol10_MemberGameInfoes { get; set; } + public string MemberGameInfoStageID_MemberGameInfoStages { get; set; } + public string MemberID_MemberGameInfoStages { get; set; } + public string StageName_MemberGameInfoStages { get; set; } + public string StageStatus_MemberGameInfoStages { get; set; } + public string Category1_MemberGameInfoStages { get; set; } + public string Category2_MemberGameInfoStages { get; set; } + public string Category3_MemberGameInfoStages { get; set; } + public string Mission1_MemberGameInfoStages { get; set; } + public string Mission2_MemberGameInfoStages { get; set; } + public string Mission3_MemberGameInfoStages { get; set; } + public string Mission4_MemberGameInfoStages { get; set; } + public string Mission5_MemberGameInfoStages { get; set; } + public string Points_MemberGameInfoStages { get; set; } + public string StageStat1_MemberGameInfoStages { get; set; } + public string StageStat2_MemberGameInfoStages { get; set; } + public string StageStat3_MemberGameInfoStages { get; set; } + public string StageStat4_MemberGameInfoStages { get; set; } + public string StageStat5_MemberGameInfoStages { get; set; } + public string sCol1_MemberGameInfoStages { get; set; } + public string sCol2_MemberGameInfoStages { get; set; } + public string sCol3_MemberGameInfoStages { get; set; } + public string sCol4_MemberGameInfoStages { get; set; } + public string sCol5_MemberGameInfoStages { get; set; } + public string sCol6_MemberGameInfoStages { get; set; } + public string sCol7_MemberGameInfoStages { get; set; } + public string sCol8_MemberGameInfoStages { get; set; } + public string sCol9_MemberGameInfoStages { get; set; } + public string sCol10_MemberGameInfoStages { get; set; } + public string token { get; set; } + } +} \ No newline at end of file From 1c7bb012808160d9236ad4492a5bc92147f067d5 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 13:08:56 +0900 Subject: [PATCH 30/36] adding crypt CBUdtMoveGiftController --- CloudBread.csproj | 1 + Controllers/CBUdtMoveGiftController.cs | 70 +++++++++++++++----------- Models/UdtMoveGift.cs | 29 +++++++++++ 3 files changed, 70 insertions(+), 30 deletions(-) create mode 100644 Models/UdtMoveGift.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index afd60f2..e60e50d 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -317,6 +317,7 @@ + diff --git a/Controllers/CBUdtMoveGiftController.cs b/Controllers/CBUdtMoveGiftController.cs index e6054a7..f578c0f 100644 --- a/Controllers/CBUdtMoveGiftController.cs +++ b/Controllers/CBUdtMoveGiftController.cs @@ -32,46 +32,41 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBUdtMoveGiftController : ApiController { - - public class InputParams + public HttpResponseMessage Post(UdtMoveGiftInputParams p) { - public string InsertORUpdate { get; set; } - public string GiftDepositoryID { get; set; } - public string MemberItemID { get; set; } - public string MemberID { get; set; } - public string ItemListID { get; set; } - public string ItemCount { get; set; } - public string ItemStatus { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - } - - public string Post(InputParams p) - { - string result = ""; + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + RowcountResult rowcountResult = new RowcountResult(); + try { // task start log @@ -111,7 +106,7 @@ public string Post(InputParams p) { while (dreader.Read()) { - result = dreader[0].ToString(); + rowcountResult.result = dreader[0].ToString(); } dreader.Close(); } @@ -124,9 +119,25 @@ public string Post(InputParams p) logMessage.Message = jsonParam; Logging.RunLog(logMessage); - return result; - } + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowcountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); + return response; + } } } @@ -143,6 +154,5 @@ public string Post(InputParams p) throw; } } - } } diff --git a/Models/UdtMoveGift.cs b/Models/UdtMoveGift.cs new file mode 100644 index 0000000..f695b35 --- /dev/null +++ b/Models/UdtMoveGift.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class UdtMoveGiftInputParams + { + public string InsertORUpdate { get; set; } + public string GiftDepositoryID { get; set; } + public string MemberItemID { get; set; } + public string MemberID { get; set; } + public string ItemListID { get; set; } + public string ItemCount { get; set; } + public string ItemStatus { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + public string token { get; set; } + } +} \ No newline at end of file From 204afc4672ef26e46880a0490f0ad0725a02aef0 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 13:18:00 +0900 Subject: [PATCH 31/36] adding crypt CBUdtReturnItemController --- CloudBread.csproj | 1 + Controllers/CBUdtReturnItemController.cs | 126 +++++++---------------- Models/UdtReturnItem.cs | 83 +++++++++++++++ 3 files changed, 124 insertions(+), 86 deletions(-) create mode 100644 Models/UdtReturnItem.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index e60e50d..afc2d4d 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -318,6 +318,7 @@ + diff --git a/Controllers/CBUdtReturnItemController.cs b/Controllers/CBUdtReturnItemController.cs index 1be4777..00475dc 100644 --- a/Controllers/CBUdtReturnItemController.cs +++ b/Controllers/CBUdtReturnItemController.cs @@ -34,96 +34,32 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBUdtReturnItemController : ApiController { - - public class InputParams + public HttpResponseMessage Post(UdtReturnItemInputParams p) { - public string DeleteORUpdate { get; set; } - public string MemberItemID_MemberItems { get; set; } - public string MemberID_MemberItems { get; set; } - public string ItemListID_MemberItems { get; set; } - public string ItemCount_MemberItems { get; set; } - public string ItemStatus_MemberItems { get; set; } - public string sCol1_MemberItems { get; set; } - public string sCol2_MemberItems { get; set; } - public string sCol3_MemberItems { get; set; } - public string sCol4_MemberItems { get; set; } - public string sCol5_MemberItems { get; set; } - public string sCol6_MemberItems { get; set; } - public string sCol7_MemberItems { get; set; } - public string sCol8_MemberItems { get; set; } - public string sCol9_MemberItems { get; set; } - public string sCol10_MemberItems { get; set; } - public string MemberItemPurchaseID_MemberItemPurchases { get; set; } - public string MemberID_MemberItemPurchases { get; set; } - public string ItemListID_MemberItemPurchases { get; set; } - public string PurchaseQuantity_MemberItemPurchases { get; set; } - public string PurchasePrice_MemberItemPurchases { get; set; } - public string PGinfo1_MemberItemPurchases { get; set; } - public string PGinfo2_MemberItemPurchases { get; set; } - public string PGinfo3_MemberItemPurchases { get; set; } - public string PGinfo4_MemberItemPurchases { get; set; } - public string PGinfo5_MemberItemPurchases { get; set; } - public string PurchaseDeviceID_MemberItemPurchases { get; set; } - public string PurchaseDeviceIPAddress_MemberItemPurchases { get; set; } - public string PurchaseDeviceMACAddress_MemberItemPurchases { get; set; } - public string PurchaseDT_MemberItemPurchases { get; set; } - public string PurchaseCancelYN_MemberItemPurchases { get; set; } - public string PurchaseCancelDT_MemberItemPurchases { get; set; } - public string PurchaseCancelingStatus_MemberItemPurchases { get; set; } - public string PurchaseCancelReturnedAmount_MemberItemPurchases { get; set; } - public string PurchaseCancelDeviceID_MemberItemPurchases { get; set; } - public string PurchaseCancelDeviceIPAddress_MemberItemPurchases { get; set; } - public string PurchaseCancelDeviceMACAddress_MemberItemPurchases { get; set; } - public string sCol1_MemberItemPurchases { get; set; } - public string sCol2_MemberItemPurchases { get; set; } - public string sCol3_MemberItemPurchases { get; set; } - public string sCol4_MemberItemPurchases { get; set; } - public string sCol5_MemberItemPurchases { get; set; } - public string sCol6_MemberItemPurchases { get; set; } - public string sCol7_MemberItemPurchases { get; set; } - public string sCol8_MemberItemPurchases { get; set; } - public string sCol9_MemberItemPurchases { get; set; } - public string sCol10_MemberItemPurchases { get; set; } - public string MemberID_MemberGameInfoes { get; set; } - public string Level_MemberGameInfoes { get; set; } - public string Exps_MemberGameInfoes { get; set; } - public string Points_MemberGameInfoes { get; set; } - public string UserSTAT1_MemberGameInfoes { get; set; } - public string UserSTAT2_MemberGameInfoes { get; set; } - public string UserSTAT3_MemberGameInfoes { get; set; } - public string UserSTAT4_MemberGameInfoes { get; set; } - public string UserSTAT5_MemberGameInfoes { get; set; } - public string UserSTAT6_MemberGameInfoes { get; set; } - public string UserSTAT7_MemberGameInfoes { get; set; } - public string UserSTAT8_MemberGameInfoes { get; set; } - public string UserSTAT9_MemberGameInfoes { get; set; } - public string UserSTAT10_MemberGameInfoes { get; set; } - public string sCol1_MemberGameInfoes { get; set; } - public string sCol2_MemberGameInfoes { get; set; } - public string sCol3_MemberGameInfoes { get; set; } - public string sCol4_MemberGameInfoes { get; set; } - public string sCol5_MemberGameInfoes { get; set; } - public string sCol6_MemberGameInfoes { get; set; } - public string sCol7_MemberGameInfoes { get; set; } - public string sCol8_MemberGameInfoes { get; set; } - public string sCol9_MemberGameInfoes { get; set; } - public string sCol10_MemberGameInfoes { get; set; } - - } - - public string Post(InputParams p) - { - string result = ""; + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID_MemberGameInfoes, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID_MemberGameInfoes, this.User as ClaimsPrincipal); p.MemberID_MemberGameInfoes = sid; p.MemberID_MemberItemPurchases = sid; p.MemberID_MemberItems = sid; @@ -131,6 +67,10 @@ public string Post(InputParams p) Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + RowcountResult rowcountResult = new RowcountResult(); + try { // task start log @@ -163,7 +103,6 @@ public string Post(InputParams p) command.Parameters.Add("@sCol8_MemberItems", SqlDbType.NVarChar, -1).Value = p.sCol8_MemberItems; command.Parameters.Add("@sCol9_MemberItems", SqlDbType.NVarChar, -1).Value = p.sCol9_MemberItems; command.Parameters.Add("@sCol10_MemberItems", SqlDbType.NVarChar, -1).Value = p.sCol10_MemberItems; - command.Parameters.Add("@MemberItemPurchaseID_MemberItemPurchases", SqlDbType.NVarChar, -1).Value = p.MemberItemPurchaseID_MemberItemPurchases; command.Parameters.Add("@MemberID_MemberItemPurchases", SqlDbType.NVarChar, -1).Value = p.MemberID_MemberItemPurchases; command.Parameters.Add("@ItemListID_MemberItemPurchases", SqlDbType.NVarChar, -1).Value = p.ItemListID_MemberItemPurchases; @@ -225,7 +164,7 @@ public string Post(InputParams p) { while (dreader.Read()) { - result = dreader[0].ToString(); + rowcountResult.result = dreader[0].ToString(); } dreader.Close(); } @@ -238,9 +177,25 @@ public string Post(InputParams p) logMessage.Message = jsonParam; Logging.RunLog(logMessage); - return result; - } + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowcountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); + return response; + } } } @@ -257,6 +212,5 @@ public string Post(InputParams p) throw; } } - } } diff --git a/Models/UdtReturnItem.cs b/Models/UdtReturnItem.cs new file mode 100644 index 0000000..b1ca24b --- /dev/null +++ b/Models/UdtReturnItem.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class UdtReturnItemInputParams + { + public string DeleteORUpdate { get; set; } + public string MemberItemID_MemberItems { get; set; } + public string MemberID_MemberItems { get; set; } + public string ItemListID_MemberItems { get; set; } + public string ItemCount_MemberItems { get; set; } + public string ItemStatus_MemberItems { get; set; } + public string sCol1_MemberItems { get; set; } + public string sCol2_MemberItems { get; set; } + public string sCol3_MemberItems { get; set; } + public string sCol4_MemberItems { get; set; } + public string sCol5_MemberItems { get; set; } + public string sCol6_MemberItems { get; set; } + public string sCol7_MemberItems { get; set; } + public string sCol8_MemberItems { get; set; } + public string sCol9_MemberItems { get; set; } + public string sCol10_MemberItems { get; set; } + public string MemberItemPurchaseID_MemberItemPurchases { get; set; } + public string MemberID_MemberItemPurchases { get; set; } + public string ItemListID_MemberItemPurchases { get; set; } + public string PurchaseQuantity_MemberItemPurchases { get; set; } + public string PurchasePrice_MemberItemPurchases { get; set; } + public string PGinfo1_MemberItemPurchases { get; set; } + public string PGinfo2_MemberItemPurchases { get; set; } + public string PGinfo3_MemberItemPurchases { get; set; } + public string PGinfo4_MemberItemPurchases { get; set; } + public string PGinfo5_MemberItemPurchases { get; set; } + public string PurchaseDeviceID_MemberItemPurchases { get; set; } + public string PurchaseDeviceIPAddress_MemberItemPurchases { get; set; } + public string PurchaseDeviceMACAddress_MemberItemPurchases { get; set; } + public string PurchaseDT_MemberItemPurchases { get; set; } + public string PurchaseCancelYN_MemberItemPurchases { get; set; } + public string PurchaseCancelDT_MemberItemPurchases { get; set; } + public string PurchaseCancelingStatus_MemberItemPurchases { get; set; } + public string PurchaseCancelReturnedAmount_MemberItemPurchases { get; set; } + public string PurchaseCancelDeviceID_MemberItemPurchases { get; set; } + public string PurchaseCancelDeviceIPAddress_MemberItemPurchases { get; set; } + public string PurchaseCancelDeviceMACAddress_MemberItemPurchases { get; set; } + public string sCol1_MemberItemPurchases { get; set; } + public string sCol2_MemberItemPurchases { get; set; } + public string sCol3_MemberItemPurchases { get; set; } + public string sCol4_MemberItemPurchases { get; set; } + public string sCol5_MemberItemPurchases { get; set; } + public string sCol6_MemberItemPurchases { get; set; } + public string sCol7_MemberItemPurchases { get; set; } + public string sCol8_MemberItemPurchases { get; set; } + public string sCol9_MemberItemPurchases { get; set; } + public string sCol10_MemberItemPurchases { get; set; } + public string MemberID_MemberGameInfoes { get; set; } + public string Level_MemberGameInfoes { get; set; } + public string Exps_MemberGameInfoes { get; set; } + public string Points_MemberGameInfoes { get; set; } + public string UserSTAT1_MemberGameInfoes { get; set; } + public string UserSTAT2_MemberGameInfoes { get; set; } + public string UserSTAT3_MemberGameInfoes { get; set; } + public string UserSTAT4_MemberGameInfoes { get; set; } + public string UserSTAT5_MemberGameInfoes { get; set; } + public string UserSTAT6_MemberGameInfoes { get; set; } + public string UserSTAT7_MemberGameInfoes { get; set; } + public string UserSTAT8_MemberGameInfoes { get; set; } + public string UserSTAT9_MemberGameInfoes { get; set; } + public string UserSTAT10_MemberGameInfoes { get; set; } + public string sCol1_MemberGameInfoes { get; set; } + public string sCol2_MemberGameInfoes { get; set; } + public string sCol3_MemberGameInfoes { get; set; } + public string sCol4_MemberGameInfoes { get; set; } + public string sCol5_MemberGameInfoes { get; set; } + public string sCol6_MemberGameInfoes { get; set; } + public string sCol7_MemberGameInfoes { get; set; } + public string sCol8_MemberGameInfoes { get; set; } + public string sCol9_MemberGameInfoes { get; set; } + public string sCol10_MemberGameInfoes { get; set; } + public string token { get; set; } + } +} \ No newline at end of file From 8de6c674a8fcc9b889306b42b2f72dd9fa87b538 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 13:29:13 +0900 Subject: [PATCH 32/36] adding crypt CBUdtSendGiftController --- CloudBread.csproj | 1 + Controllers/CBUdtSendGiftController.cs | 87 ++++++++++++-------------- Models/UdtSendGift.cs | 43 +++++++++++++ 3 files changed, 84 insertions(+), 47 deletions(-) create mode 100644 Models/UdtSendGift.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index afc2d4d..ca22577 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -319,6 +319,7 @@ + diff --git a/Controllers/CBUdtSendGiftController.cs b/Controllers/CBUdtSendGiftController.cs index f245563..8580f26 100644 --- a/Controllers/CBUdtSendGiftController.cs +++ b/Controllers/CBUdtSendGiftController.cs @@ -32,62 +32,41 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBUdtSendGiftController : ApiController { - - public class InputParams + public HttpResponseMessage Post(UdtSendGiftInputParams p) { - public string DeleteORUpdate { get; set; } - public string MemberItemID_MemberItem { get; set; } - public string MemberID_MemberItem { get; set; } - public string ItemListID_MemberItem { get; set; } - public string ItemCount_MemberItem { get; set; } - public string ItemStatus_MemberItem { get; set; } - public string sCol1_MemberItem { get; set; } - public string sCol2_MemberItem { get; set; } - public string sCol3_MemberItem { get; set; } - public string sCol4_MemberItem { get; set; } - public string sCol5_MemberItem { get; set; } - public string sCol6_MemberItem { get; set; } - public string sCol7_MemberItem { get; set; } - public string sCol8_MemberItem { get; set; } - public string sCol9_MemberItem { get; set; } - public string sCol10_MemberItem { get; set; } - public string GiftDepositoryID_GiftDepository { get; set; } - public string ItemListID_GiftDepository { get; set; } - public string ItemCount_GiftDepository { get; set; } - public string FromMemberID_GiftDepository { get; set; } - public string ToMemberID_GiftDepository { get; set; } - public string sCol1_GiftDepository { get; set; } - public string sCol2_GiftDepository { get; set; } - public string sCol3_GiftDepository { get; set; } - public string sCol4_GiftDepository { get; set; } - public string sCol5_GiftDepository { get; set; } - public string sCol6_GiftDepository { get; set; } - public string sCol7_GiftDepository { get; set; } - public string sCol8_GiftDepository { get; set; } - public string sCol9_GiftDepository { get; set; } - public string sCol10_GiftDepository { get; set; } - - - } - - public string Post(InputParams p) - { - string result = ""; + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID_MemberItem, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID_MemberItem, this.User as ClaimsPrincipal); p.MemberID_MemberItem = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + RowcountResult rowcountResult = new RowcountResult(); + try { // task start log @@ -136,13 +115,12 @@ public string Post(InputParams p) command.Parameters.Add("@sCol9_GiftDepository", SqlDbType.NVarChar, -1).Value = p.sCol9_GiftDepository; command.Parameters.Add("@sCol10_GiftDepository", SqlDbType.NVarChar, -1).Value = p.sCol10_GiftDepository; - connection.OpenWithRetry(retryPolicy); using (SqlDataReader dreader = command.ExecuteReaderWithRetry(retryPolicy)) { while (dreader.Read()) { - result = dreader[0].ToString(); + rowcountResult.result = dreader[0].ToString(); } dreader.Close(); } @@ -155,9 +133,25 @@ public string Post(InputParams p) logMessage.Message = jsonParam; Logging.RunLog(logMessage); - return result; - } + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowcountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); + return response; + } } } @@ -174,6 +168,5 @@ public string Post(InputParams p) throw; } } - } } diff --git a/Models/UdtSendGift.cs b/Models/UdtSendGift.cs new file mode 100644 index 0000000..4595fdd --- /dev/null +++ b/Models/UdtSendGift.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class UdtSendGiftInputParams + { + public string DeleteORUpdate { get; set; } + public string MemberItemID_MemberItem { get; set; } + public string MemberID_MemberItem { get; set; } + public string ItemListID_MemberItem { get; set; } + public string ItemCount_MemberItem { get; set; } + public string ItemStatus_MemberItem { get; set; } + public string sCol1_MemberItem { get; set; } + public string sCol2_MemberItem { get; set; } + public string sCol3_MemberItem { get; set; } + public string sCol4_MemberItem { get; set; } + public string sCol5_MemberItem { get; set; } + public string sCol6_MemberItem { get; set; } + public string sCol7_MemberItem { get; set; } + public string sCol8_MemberItem { get; set; } + public string sCol9_MemberItem { get; set; } + public string sCol10_MemberItem { get; set; } + public string GiftDepositoryID_GiftDepository { get; set; } + public string ItemListID_GiftDepository { get; set; } + public string ItemCount_GiftDepository { get; set; } + public string FromMemberID_GiftDepository { get; set; } + public string ToMemberID_GiftDepository { get; set; } + public string sCol1_GiftDepository { get; set; } + public string sCol2_GiftDepository { get; set; } + public string sCol3_GiftDepository { get; set; } + public string sCol4_GiftDepository { get; set; } + public string sCol5_GiftDepository { get; set; } + public string sCol6_GiftDepository { get; set; } + public string sCol7_GiftDepository { get; set; } + public string sCol8_GiftDepository { get; set; } + public string sCol9_GiftDepository { get; set; } + public string sCol10_GiftDepository { get; set; } + public string token { get; set; } + } +} \ No newline at end of file From d37b5f94321d60e4c00ac32f5c2e1d82b1722083 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 13:41:54 +0900 Subject: [PATCH 33/36] adding crypt CBAddUseMemberItemController --- CloudBread.csproj | 1 + Controllers/CBAddUseMemberItemController.cs | 94 +++++++++------------ Models/AddUseMemberItem.cs | 52 ++++++++++++ 3 files changed, 93 insertions(+), 54 deletions(-) create mode 100644 Models/AddUseMemberItem.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index ca22577..b8139b1 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -287,6 +287,7 @@ Global.asax + diff --git a/Controllers/CBAddUseMemberItemController.cs b/Controllers/CBAddUseMemberItemController.cs index fac0949..f881d42 100644 --- a/Controllers/CBAddUseMemberItemController.cs +++ b/Controllers/CBAddUseMemberItemController.cs @@ -33,71 +33,42 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBAddUseMemberItemController : ApiController { - - public class InputParams - { - public string InsertORUpdateORDelete; - public string MemberItemID_MemberItem; - public string MemberID_MemberItem; - public string ItemListID_MemberItem; - public string ItemCount_MemberItem; - public string ItemStatus_MemberItem; - public string sCol1_MemberItem; - public string sCol2_MemberItem; - public string sCol3_MemberItem; - public string sCol4_MemberItem; - public string sCol5_MemberItem; - public string sCol6_MemberItem; - public string sCol7_MemberItem; - public string sCol8_MemberItem; - public string sCol9_MemberItem; - public string sCol10_MemberItem; - public string MemberID_MemberGameInfoes; - public string Level_MemberGameInfoes; - public string Exps_MemberGameInfoes; - public string Points_MemberGameInfoes; - public string UserSTAT1_MemberGameInfoes; - public string UserSTAT2_MemberGameInfoes; - public string UserSTAT3_MemberGameInfoes; - public string UserSTAT4_MemberGameInfoes; - public string UserSTAT5_MemberGameInfoes; - public string UserSTAT6_MemberGameInfoes; - public string UserSTAT7_MemberGameInfoes; - public string UserSTAT8_MemberGameInfoes; - public string UserSTAT9_MemberGameInfoes; - public string UserSTAT10_MemberGameInfoes; - public string sCol1_MemberGameInfoes; - public string sCol2_MemberGameInfoes; - public string sCol3_MemberGameInfoes; - public string sCol4_MemberGameInfoes; - public string sCol5_MemberGameInfoes; - public string sCol6_MemberGameInfoes; - public string sCol7_MemberGameInfoes; - public string sCol8_MemberGameInfoes; - public string sCol9_MemberGameInfoes; - public string sCol10_MemberGameInfoes; - } - - public string Post(InputParams p) + public HttpResponseMessage Post(AddUseMemberItemInputParams p) { - - string result = ""; + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID_MemberGameInfoes, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID_MemberGameInfoes, this.User as ClaimsPrincipal); p.MemberID_MemberGameInfoes = sid; p.MemberID_MemberItem = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + RowcountResult rowcountResult = new RowcountResult(); + try { // start task log @@ -160,7 +131,7 @@ public string Post(InputParams p) { while (dreader.Read()) { - result = dreader[0].ToString(); + rowcountResult.result = dreader[0].ToString(); } dreader.Close(); } @@ -173,9 +144,25 @@ public string Post(InputParams p) logMessage.Message = jsonParam; Logging.RunLog(logMessage); - return result; - } + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowcountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); + return response; + } } } @@ -192,6 +179,5 @@ public string Post(InputParams p) throw; } } - } } diff --git a/Models/AddUseMemberItem.cs b/Models/AddUseMemberItem.cs new file mode 100644 index 0000000..59e263a --- /dev/null +++ b/Models/AddUseMemberItem.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class AddUseMemberItemInputParams + { + public string InsertORUpdateORDelete { get; set; } + public string MemberItemID_MemberItem { get; set; } + public string MemberID_MemberItem { get; set; } + public string ItemListID_MemberItem { get; set; } + public string ItemCount_MemberItem { get; set; } + public string ItemStatus_MemberItem { get; set; } + public string sCol1_MemberItem { get; set; } + public string sCol2_MemberItem { get; set; } + public string sCol3_MemberItem { get; set; } + public string sCol4_MemberItem { get; set; } + public string sCol5_MemberItem { get; set; } + public string sCol6_MemberItem { get; set; } + public string sCol7_MemberItem { get; set; } + public string sCol8_MemberItem { get; set; } + public string sCol9_MemberItem { get; set; } + public string sCol10_MemberItem { get; set; } + public string MemberID_MemberGameInfoes { get; set; } + public string Level_MemberGameInfoes { get; set; } + public string Exps_MemberGameInfoes { get; set; } + public string Points_MemberGameInfoes { get; set; } + public string UserSTAT1_MemberGameInfoes { get; set; } + public string UserSTAT2_MemberGameInfoes { get; set; } + public string UserSTAT3_MemberGameInfoes { get; set; } + public string UserSTAT4_MemberGameInfoes { get; set; } + public string UserSTAT5_MemberGameInfoes { get; set; } + public string UserSTAT6_MemberGameInfoes { get; set; } + public string UserSTAT7_MemberGameInfoes { get; set; } + public string UserSTAT8_MemberGameInfoes { get; set; } + public string UserSTAT9_MemberGameInfoes { get; set; } + public string UserSTAT10_MemberGameInfoes { get; set; } + public string sCol1_MemberGameInfoes { get; set; } + public string sCol2_MemberGameInfoes { get; set; } + public string sCol3_MemberGameInfoes { get; set; } + public string sCol4_MemberGameInfoes { get; set; } + public string sCol5_MemberGameInfoes { get; set; } + public string sCol6_MemberGameInfoes { get; set; } + public string sCol7_MemberGameInfoes { get; set; } + public string sCol8_MemberGameInfoes { get; set; } + public string sCol9_MemberGameInfoes { get; set; } + public string sCol10_MemberGameInfoes { get; set; } + public string token { get; set; } + } +} \ No newline at end of file From 48a5b9d239208e826aac045054f15f590d627192 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 14:12:24 +0900 Subject: [PATCH 34/36] adding crypt CBComInsMemberItemPurchaseController --- CloudBread.csproj | 1 + ...sMemberItemPurchaseControllerController.cs | 85 +++++++++---------- Models/ComInsMemberItemPurchase.cs | 43 ++++++++++ 3 files changed, 84 insertions(+), 45 deletions(-) create mode 100644 Models/ComInsMemberItemPurchase.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index b8139b1..8d1cd8c 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -288,6 +288,7 @@ + diff --git a/Controllers/CBComInsMemberItemPurchaseControllerController.cs b/Controllers/CBComInsMemberItemPurchaseControllerController.cs index eb00bea..d4c8c17 100644 --- a/Controllers/CBComInsMemberItemPurchaseControllerController.cs +++ b/Controllers/CBComInsMemberItemPurchaseControllerController.cs @@ -30,60 +30,41 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBComInsMemberItemPurchaseController : ApiController { - public class InputParams + public HttpResponseMessage Post(ComInsMemberItemPurchaseInputParams p) { - public string MemberItemPurchaseID { get; set; } - public string MemberID { get; set; } - public string ItemListID { get; set; } - public string PurchaseQuantity { get; set; } - public string PurchasePrice { get; set; } - public string PGinfo1 { get; set; } - public string PGinfo2 { get; set; } - public string PGinfo3 { get; set; } - public string PGinfo4 { get; set; } - public string PGinfo5 { get; set; } - public string PurchaseDeviceID { get; set; } - public string PurchaseDeviceIPAddress { get; set; } - public string PurchaseDeviceMACAddress { get; set; } - public string PurchaseDT { get; set; } - public string PurchaseCancelYN { get; set; } - public string PurchaseCancelDT { get; set; } - public string PurchaseCancelingStatus { get; set; } - public string PurchaseCancelReturnedAmount { get; set; } - public string PurchaseCancelDeviceID { get; set; } - public string PurchaseCancelDeviceIPAddress { get; set; } - public string PurchaseCancelDeviceMACAddress { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - - } - - public string Post(InputParams p) - { - string result = ""; + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); + RowcountResult rowcountResult = new RowcountResult(); + try { // task start log @@ -99,7 +80,6 @@ public string Post(InputParams p) { using (SqlCommand command = new SqlCommand("uspComInsMemberItemPurchase", connection)) { - command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@MemberItemPurchaseID", SqlDbType.NVarChar, -1).Value = p.MemberItemPurchaseID; command.Parameters.Add("@MemberID", SqlDbType.NVarChar, -1).Value = p.MemberID; @@ -138,7 +118,7 @@ public string Post(InputParams p) { while (dreader.Read()) { - result = dreader[0].ToString(); + rowcountResult.result = dreader[0].ToString(); } dreader.Close(); } @@ -151,9 +131,25 @@ public string Post(InputParams p) logMessage.Message = jsonParam; Logging.RunLog(logMessage); - return result; - } + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(rowcountResult), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + response = Request.CreateResponse(HttpStatusCode.OK, rowcountResult); + return response; + } } } @@ -170,6 +166,5 @@ public string Post(InputParams p) throw; } } - } } diff --git a/Models/ComInsMemberItemPurchase.cs b/Models/ComInsMemberItemPurchase.cs new file mode 100644 index 0000000..617ea18 --- /dev/null +++ b/Models/ComInsMemberItemPurchase.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class ComInsMemberItemPurchaseInputParams + { + public string MemberItemPurchaseID { get; set; } + public string MemberID { get; set; } + public string ItemListID { get; set; } + public string PurchaseQuantity { get; set; } + public string PurchasePrice { get; set; } + public string PGinfo1 { get; set; } + public string PGinfo2 { get; set; } + public string PGinfo3 { get; set; } + public string PGinfo4 { get; set; } + public string PGinfo5 { get; set; } + public string PurchaseDeviceID { get; set; } + public string PurchaseDeviceIPAddress { get; set; } + public string PurchaseDeviceMACAddress { get; set; } + public string PurchaseDT { get; set; } + public string PurchaseCancelYN { get; set; } + public string PurchaseCancelDT { get; set; } + public string PurchaseCancelingStatus { get; set; } + public string PurchaseCancelReturnedAmount { get; set; } + public string PurchaseCancelDeviceID { get; set; } + public string PurchaseCancelDeviceIPAddress { get; set; } + public string PurchaseCancelDeviceMACAddress { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + public string token { get; set; } + } +} \ No newline at end of file From 880d3b666641eff50831c84c9e0bcec2352c6793 Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 14:20:18 +0900 Subject: [PATCH 35/36] adding crypt CBComSelCouponController --- CloudBread.csproj | 1 + Controllers/CBComSelCouponController.cs | 82 ++++++++++++------------- Models/ComSelCoupon.cs | 40 ++++++++++++ 3 files changed, 81 insertions(+), 42 deletions(-) create mode 100644 Models/ComSelCoupon.cs diff --git a/CloudBread.csproj b/CloudBread.csproj index 8d1cd8c..0942677 100644 --- a/CloudBread.csproj +++ b/CloudBread.csproj @@ -289,6 +289,7 @@ + diff --git a/Controllers/CBComSelCouponController.cs b/Controllers/CBComSelCouponController.cs index 66b9761..8e44f5c 100644 --- a/Controllers/CBComSelCouponController.cs +++ b/Controllers/CBComSelCouponController.cs @@ -30,57 +30,39 @@ using System.Security.Claims; using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; +using CloudBread.Models; namespace CloudBread.Controllers { [MobileAppController] public class CBComSelCouponController : ApiController { - - public class InputParams - { - public string MemberID; // log purpose - public string CouponID; - } - - public class Model - { - public string CouponID { get; set; } - public string CouponCategory1 { get; set; } - public string CouponCategory2 { get; set; } - public string CouponCategory3 { get; set; } - public string ItemListID { get; set; } - public string ItemCount { get; set; } - public string ItemStatus { get; set; } - public string TargetGroup { get; set; } - public string TargetOS { get; set; } - public string TargetDevice { get; set; } - public string Title { get; set; } - public string Content { get; set; } - public string sCol1 { get; set; } - public string sCol2 { get; set; } - public string sCol3 { get; set; } - public string sCol4 { get; set; } - public string sCol5 { get; set; } - public string sCol6 { get; set; } - public string sCol7 { get; set; } - public string sCol8 { get; set; } - public string sCol9 { get; set; } - public string sCol10 { get; set; } - - } - - public List Post(InputParams p) + public HttpResponseMessage Post(ComSelCouponInputParams p) { + // try decrypt data + if (!string.IsNullOrEmpty(p.token) && globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + string decrypted = Crypto.AES_decrypt(p.token, globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + p = JsonConvert.DeserializeObject(decrypted); + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex); + throw ex; + } + } // Get the sid or memberID of the current user. - var claimsPrincipal = this.User as ClaimsPrincipal; - string sid = CBAuth.getMemberID(p.MemberID, claimsPrincipal); + string sid = CBAuth.getMemberID(p.MemberID, this.User as ClaimsPrincipal); p.MemberID = sid; Logging.CBLoggers logMessage = new Logging.CBLoggers(); string jsonParam = JsonConvert.SerializeObject(p); - List result = new List(); + List result = new List(); + HttpResponseMessage response = new HttpResponseMessage(); + EncryptedData encryptedResult = new EncryptedData(); try { @@ -98,7 +80,7 @@ public List Post(InputParams p) { while (dreader.Read()) { - Model workItem = new Model() + ComSelCouponModel workItem = new ComSelCouponModel() { CouponID = dreader[0].ToString(), CouponCategory1 = dreader[1].ToString(), @@ -122,7 +104,6 @@ public List Post(InputParams p) sCol8 = dreader[19].ToString(), sCol9 = dreader[20].ToString(), sCol10 = dreader[21].ToString(), - }; result.Add(workItem); } @@ -130,7 +111,25 @@ public List Post(InputParams p) } connection.Close(); } - return result; + + /// Encrypt the result response + if (globalVal.CloudBreadCryptSetting == "AES256") + { + try + { + encryptedResult.token = Crypto.AES_encrypt(JsonConvert.SerializeObject(result), globalVal.CloudBreadCryptKey, globalVal.CloudBreadCryptIV); + response = Request.CreateResponse(HttpStatusCode.OK, encryptedResult); + return response; + } + catch (Exception ex) + { + ex = (Exception)Activator.CreateInstance(ex.GetType(), "Encrypt Error", ex); + throw ex; + } + } + + response = Request.CreateResponse(HttpStatusCode.OK, result); + return response; } } @@ -147,6 +146,5 @@ public List Post(InputParams p) throw; } } - } } diff --git a/Models/ComSelCoupon.cs b/Models/ComSelCoupon.cs new file mode 100644 index 0000000..c77c40d --- /dev/null +++ b/Models/ComSelCoupon.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace CloudBread.Models +{ + public class ComSelCouponInputParams + { + public string MemberID { get; set; } // log purpose + public string CouponID { get; set; } + public string token { get; set; } + } + + public class ComSelCouponModel + { + public string CouponID { get; set; } + public string CouponCategory1 { get; set; } + public string CouponCategory2 { get; set; } + public string CouponCategory3 { get; set; } + public string ItemListID { get; set; } + public string ItemCount { get; set; } + public string ItemStatus { get; set; } + public string TargetGroup { get; set; } + public string TargetOS { get; set; } + public string TargetDevice { get; set; } + public string Title { get; set; } + public string Content { get; set; } + public string sCol1 { get; set; } + public string sCol2 { get; set; } + public string sCol3 { get; set; } + public string sCol4 { get; set; } + public string sCol5 { get; set; } + public string sCol6 { get; set; } + public string sCol7 { get; set; } + public string sCol8 { get; set; } + public string sCol9 { get; set; } + public string sCol10 { get; set; } + } +} \ No newline at end of file From 106450526b059815941b64111ceac75d0626a08b Mon Sep 17 00:00:00 2001 From: dwkim Date: Fri, 25 Mar 2016 14:32:27 +0900 Subject: [PATCH 36/36] changed web.config added Encryption configuration --- web.config | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/web.config b/web.config index 605c9f3..15ea22a 100644 --- a/web.config +++ b/web.config @@ -18,19 +18,27 @@ - + + + + + + + - - - - - + + + +