Skip to content

Commit d699b23

Browse files
committed
Changes to test SecureString
1 parent 971442c commit d699b23

File tree

2 files changed

+37
-13
lines changed

2 files changed

+37
-13
lines changed

CyberSource/Client/Service References/SoapServiceReference/Reference.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31953,7 +31953,7 @@ public partial class BillTo : object, System.ComponentModel.INotifyPropertyChang
3195331953

3195431954
private string phoneNumberField;
3195531955

31956-
private string emailField;
31956+
private System.Security.SecureString emailField;
3195731957

3195831958
private string ipAddressField;
3195931959

@@ -32281,12 +32281,13 @@ public string phoneNumber {
3228132281

3228232282
/// <remarks/>
3228332283
[System.Xml.Serialization.XmlElementAttribute(Order=20)]
32284-
public string email {
32284+
public System.Security.SecureString email {
3228532285
get {
3228632286
return this.emailField;
3228732287
}
3228832288
set {
3228932289
this.emailField = value;
32290+
this.emailField.MakeReadOnly();
3229032291
this.RaisePropertyChanged("email");
3229132292
}
3229232293
}
@@ -47985,7 +47986,7 @@ public partial class PayerAuthEnrollService : object, System.ComponentModel.INot
4798547986

4798647987
private string loginIDField;
4798747988

47988-
private string passwordField;
47989+
private System.Security.SecureString passwordField;
4798947990

4799047991
private string merchantIDField;
4799147992

@@ -48225,12 +48226,19 @@ public string loginID {
4822548226

4822648227
/// <remarks/>
4822748228
[System.Xml.Serialization.XmlElementAttribute(Order=9)]
48228-
public string password {
48229+
public System.Security.SecureString password {
4822948230
get {
4823048231
return this.passwordField;
4823148232
}
4823248233
set {
48233-
this.passwordField = value;
48234+
if (value == null)
48235+
{
48236+
this.passwordField = null;
48237+
}
48238+
else {
48239+
this.passwordField = value;
48240+
this.passwordField.MakeReadOnly();
48241+
}
4823448242
this.RaisePropertyChanged("password");
4823548243
}
4823648244
}

CyberSourceSamples/src/soap/SoapSample.cs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using CyberSource.Clients;
66
using CyberSource.Clients.SoapServiceReference;
77
using System.Security.Cryptography;
8+
using System.Security;
89
//using SoapSampleTransactions;
910

1011

@@ -386,7 +387,7 @@ public RequestMessage authRequest()
386387
billTo.state = "CA";
387388
billTo.postalCode = "94043";
388389
billTo.country = "US";
389-
billTo.email = "[email protected]";
390+
billTo.email = convertToSecureString("[email protected]");
390391
billTo.ipAddress = "10.7.111.111";
391392
request.billTo = billTo;
392393

@@ -417,6 +418,22 @@ public RequestMessage authRequest()
417418
return request;
418419
}
419420

421+
private static SecureString convertToSecureString(string originalString)
422+
{
423+
if (originalString == null)
424+
{
425+
return null;
426+
}
427+
428+
var secureString = new SecureString();
429+
430+
foreach (char c in originalString)
431+
secureString.AppendChar(c);
432+
433+
secureString.MakeReadOnly();
434+
return secureString;
435+
}
436+
420437
public RequestMessage authRevRequest()
421438
{
422439
RequestMessage request = new RequestMessage();
@@ -431,7 +448,7 @@ public RequestMessage authRevRequest()
431448

432449
request.ccAuthReversalService = new CCAuthReversalService();
433450
request.ccAuthReversalService.run = "true";
434-
request.ccAuthReversalService.authRequestID = "auth-request-id";
451+
request.ccAuthReversalService.authRequestID = "7195524478506344304010";
435452

436453
request.merchantReferenceCode = "your_merchant_reference_code";
437454

@@ -595,7 +612,7 @@ public RequestMessage paymentNetworkTokenizationRequest()
595612
billTo.state = "CA";
596613
billTo.postalCode = "94043";
597614
billTo.country = "US";
598-
billTo.email = "[email protected]";
615+
billTo.email = convertToSecureString("[email protected]");
599616
billTo.ipAddress = "10.7.111.111";
600617
request.billTo = billTo;
601618

@@ -656,7 +673,7 @@ public RequestMessage refundRequest()
656673
billTo.state = "CA";
657674
billTo.postalCode = "94043";
658675
billTo.country = "US";
659-
billTo.email = "[email protected]";
676+
billTo.email = convertToSecureString("[email protected]");
660677
billTo.ipAddress = "10.7.111.111";
661678
request.billTo = billTo;
662679

@@ -732,7 +749,7 @@ public RequestMessage androidPayAuthRequest()
732749
billTo.state = "CA";
733750
billTo.postalCode = "94043";
734751
billTo.country = "US";
735-
billTo.email = "[email protected]";
752+
billTo.email = convertToSecureString("[email protected]");
736753
billTo.ipAddress = "10.7.111.111";
737754
request.billTo = billTo;
738755

@@ -800,7 +817,7 @@ public RequestMessage applePayAuthRequest()
800817
billTo.state = "CA";
801818
billTo.postalCode = "94043";
802819
billTo.country = "US";
803-
billTo.email = "[email protected]";
820+
billTo.email = convertToSecureString("[email protected]");
804821
billTo.ipAddress = "10.7.111.111";
805822
request.billTo = billTo;
806823

@@ -845,7 +862,6 @@ public RequestMessage saleRequest()
845862
// you would set a merchantID in each request.
846863

847864
// this sample requests auth and capture
848-
849865
// Credit Card Authorization
850866
request.ccAuthService = new CCAuthService();
851867
request.ccAuthService.run = "true";
@@ -867,7 +883,7 @@ public RequestMessage saleRequest()
867883
billTo.state = "CA";
868884
billTo.postalCode = "94043";
869885
billTo.country = "US";
870-
billTo.email = "[email protected]";
886+
billTo.email = convertToSecureString("[email protected]");
871887
billTo.ipAddress = "10.7.111.111";
872888
request.billTo = billTo;
873889

0 commit comments

Comments
 (0)