Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding encryption feature to CloudBread v2 #42

Merged
merged 36 commits into from
Mar 25, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7a048fd
updated logger - error log save on ATS
CloudBreadPaPa Mar 23, 2016
556f3d5
adding crypt feature
CloudBreadPaPa Mar 24, 2016
ee184b4
add crypt CBComSelMemberController
CloudBreadPaPa Mar 24, 2016
56c5472
adding crypt CBComSelMemberGameInfoesController
CloudBreadPaPa Mar 24, 2016
6312921
adding crypt CBComSelMemberGameInfoStagesController
CloudBreadPaPa Mar 24, 2016
04955e5
adding crypt CBComSelMemberItemController
CloudBreadPaPa Mar 24, 2016
c51e066
adding crypt CBComSelMemberItemPurchaseController
CloudBreadPaPa Mar 24, 2016
c52a8d8
adding crypt CBComUdtGiftDepositoryController
CloudBreadPaPa Mar 24, 2016
b85137f
adding crypt CBCOMUdtMemberController
CloudBreadPaPa Mar 24, 2016
105ae53
adding crypt CBComUdtMemberGameInfoesController
CloudBreadPaPa Mar 24, 2016
f1a4ee8
adding crypt CBComUdtMemberGameInfoStagesController
CloudBreadPaPa Mar 24, 2016
4e687d7
adding crypt CBComUdtMemberItemController
CloudBreadPaPa Mar 24, 2016
59f32bd
adding crypt CBComUdtMemberItemPurchaseController
CloudBreadPaPa Mar 24, 2016
e3340bd
CBInsAnonymousRegMemberController is deplicated
CloudBreadPaPa Mar 24, 2016
0bbf8d1
adding crypt CBInsRegMemberController
CloudBreadPaPa Mar 24, 2016
9c960aa
adding crypt CBSelGameEventsController
CloudBreadPaPa Mar 24, 2016
ceb90d0
adding crypt CBSelGiftItemToMeController
CloudBreadPaPa Mar 25, 2016
23f2759
fixed crypt CBSelGiftItemToMeController
CloudBreadPaPa Mar 25, 2016
cdb7c67
adding crypt CBSelItem1Controller
CloudBreadPaPa Mar 25, 2016
62ffd76
adding crypt CBSelItemListAllController
CloudBreadPaPa Mar 25, 2016
162c022
adding crypt CBSelLoginIDDupeCheckController
CloudBreadPaPa Mar 25, 2016
a23795b
adding crypt CBSelLoginInfoController
CloudBreadPaPa Mar 25, 2016
6ba2e74
adding CBSelMemberGameInfoStagesController
CloudBreadPaPa Mar 25, 2016
15cfa45
adding crypt CBSelMemberItemsController
CloudBreadPaPa Mar 25, 2016
d44df18
adding crypt CBSelSendEmailToMemberController
CloudBreadPaPa Mar 25, 2016
92406ef
fixed deplicated API - CBUdtConfirmedEmailAddressController
CloudBreadPaPa Mar 25, 2016
12f8704
adding crypt CBUdtCouponMemberController
CloudBreadPaPa Mar 25, 2016
dfcd4b7
adding crypt CBUdtGameEventMemberToItemController
CloudBreadPaPa Mar 25, 2016
b74a3a5
adding crypt CBUdtMemberGameInfoStageController
CloudBreadPaPa Mar 25, 2016
1c7bb01
adding crypt CBUdtMoveGiftController
CloudBreadPaPa Mar 25, 2016
204afc4
adding crypt CBUdtReturnItemController
CloudBreadPaPa Mar 25, 2016
8de6c67
adding crypt CBUdtSendGiftController
CloudBreadPaPa Mar 25, 2016
d37b5f9
adding crypt CBAddUseMemberItemController
CloudBreadPaPa Mar 25, 2016
48a5b9d
adding crypt CBComInsMemberItemPurchaseController
CloudBreadPaPa Mar 25, 2016
880d3b6
adding crypt CBComSelCouponController
CloudBreadPaPa Mar 25, 2016
1064505
changed web.config
CloudBreadPaPa Mar 25, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adding crypt CBSelItem1Controller
  • Loading branch information
CloudBreadPaPa committed Mar 25, 2016
commit cdb7c670dfb4b61f1a1669b5a978b616e36e49e3
1 change: 1 addition & 0 deletions CloudBread.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@
<Compile Include="Models\RowcountResult.cs" />
<Compile Include="Models\SelGameEvents.cs" />
<Compile Include="Models\SelGiftItemToMe.cs" />
<Compile Include="Models\SelItem1.cs" />
<Compile Include="Models\SelNotices.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Startup.cs" />
Expand Down
73 changes: 40 additions & 33 deletions Controllers/CBSelItem1Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SelItem1InputParams>(decrypted);
}
catch (Exception ex)
{
ex = (Exception)Activator.CreateInstance(ex.GetType(), "Decrypt Error", ex);
throw ex;
}
}

public List<Model> 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<Model> result = new List<Model>();
List<SelItem1Model> result = new List<SelItem1Model>();
HttpResponseMessage response = new HttpResponseMessage();
EncryptedData encryptedResult = new EncryptedData();

try
{
Expand All @@ -93,7 +83,7 @@ public List<Model> Post(InputParams p)
{
while (dreader.Read())
{
Model workItem = new Model()
SelItem1Model workItem = new SelItem1Model()
{
ItemListID = dreader[0].ToString(),
ItemName = dreader[1].ToString(),
Expand All @@ -120,7 +110,25 @@ public List<Model> 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;
}
}

Expand All @@ -137,6 +145,5 @@ public List<Model> Post(InputParams p)
throw;
}
}

}
}
36 changes: 36 additions & 0 deletions Models/SelItem1.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}