Skip to content

Commit d503fd1

Browse files
authored
Merge pull request #71 from CyberSource/test-secure
Testing SecureString
2 parents 971442c + 143ccec commit d503fd1

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47985,7 +47985,7 @@ public partial class PayerAuthEnrollService : object, System.ComponentModel.INot
4798547985

4798647986
private string loginIDField;
4798747987

47988-
private string passwordField;
47988+
private System.Security.SecureString passwordField;
4798947989

4799047990
private string merchantIDField;
4799147991

@@ -48227,10 +48227,11 @@ public string loginID {
4822748227
[System.Xml.Serialization.XmlElementAttribute(Order=9)]
4822848228
public string password {
4822948229
get {
48230-
return this.passwordField;
48230+
return ConvertToUnsecureString(this.passwordField);
4823148231
}
4823248232
set {
48233-
this.passwordField = value;
48233+
this.passwordField = new System.Net.NetworkCredential(string.Empty, value).SecurePassword;
48234+
this.passwordField.MakeReadOnly();
4823448235
this.RaisePropertyChanged("password");
4823548236
}
4823648237
}
@@ -49011,6 +49012,25 @@ protected void RaisePropertyChanged(string propertyName) {
4901149012
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
4901249013
}
4901349014
}
49015+
49016+
public static string ConvertToUnsecureString(System.Security.SecureString secureString)
49017+
{
49018+
if (secureString == null)
49019+
{
49020+
return string.Empty;
49021+
}
49022+
49023+
System.IntPtr unmanagedString = System.IntPtr.Zero;
49024+
try
49025+
{
49026+
unmanagedString = System.Runtime.InteropServices.Marshal.SecureStringToGlobalAllocUnicode(secureString);
49027+
return System.Runtime.InteropServices.Marshal.PtrToStringUni(unmanagedString);
49028+
}
49029+
finally
49030+
{
49031+
System.Runtime.InteropServices.Marshal.ZeroFreeGlobalAllocUnicode(unmanagedString);
49032+
}
49033+
}
4901449034
}
4901549035

4901649036
/// <remarks/>

CyberSourceSamples/src/soap/SoapSample.cs

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

109

1110
namespace CyberSource.Samples
@@ -845,7 +844,6 @@ public RequestMessage saleRequest()
845844
// you would set a merchantID in each request.
846845

847846
// this sample requests auth and capture
848-
849847
// Credit Card Authorization
850848
request.ccAuthService = new CCAuthService();
851849
request.ccAuthService.run = "true";

0 commit comments

Comments
 (0)