Skip to content

Commit

Permalink
Merge pull request #71 from CyberSource/test-secure
Browse files Browse the repository at this point in the history
Testing SecureString
  • Loading branch information
gnongsie authored Jul 18, 2024
2 parents 971442c + 143ccec commit d503fd1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47985,7 +47985,7 @@ public partial class PayerAuthEnrollService : object, System.ComponentModel.INot

private string loginIDField;

private string passwordField;
private System.Security.SecureString passwordField;

private string merchantIDField;

Expand Down Expand Up @@ -48227,10 +48227,11 @@ public string loginID {
[System.Xml.Serialization.XmlElementAttribute(Order=9)]
public string password {
get {
return this.passwordField;
return ConvertToUnsecureString(this.passwordField);
}
set {
this.passwordField = value;
this.passwordField = new System.Net.NetworkCredential(string.Empty, value).SecurePassword;
this.passwordField.MakeReadOnly();
this.RaisePropertyChanged("password");
}
}
Expand Down Expand Up @@ -49011,6 +49012,25 @@ protected void RaisePropertyChanged(string propertyName) {
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}
}

public static string ConvertToUnsecureString(System.Security.SecureString secureString)
{
if (secureString == null)
{
return string.Empty;
}

System.IntPtr unmanagedString = System.IntPtr.Zero;
try
{
unmanagedString = System.Runtime.InteropServices.Marshal.SecureStringToGlobalAllocUnicode(secureString);
return System.Runtime.InteropServices.Marshal.PtrToStringUni(unmanagedString);
}
finally
{
System.Runtime.InteropServices.Marshal.ZeroFreeGlobalAllocUnicode(unmanagedString);
}
}
}

/// <remarks/>
Expand Down
2 changes: 0 additions & 2 deletions CyberSourceSamples/src/soap/SoapSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using CyberSource.Clients;
using CyberSource.Clients.SoapServiceReference;
using System.Security.Cryptography;
//using SoapSampleTransactions;


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

// this sample requests auth and capture

// Credit Card Authorization
request.ccAuthService = new CCAuthService();
request.ccAuthService.run = "true";
Expand Down

0 comments on commit d503fd1

Please sign in to comment.