Skip to content

Commit e64c0a7

Browse files
authored
Merge pull request #59 from mahendya1002/future
adding meta key feature support
2 parents 017da6e + 6b2137b commit e64c0a7

23 files changed

+66285
-65032
lines changed

CyberSource/Base/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
//
3232
// You can specify all the values or you can default the Revision and Build Numbers
3333
// by using the '*' as shown below:
34-
[assembly: AssemblyVersion("1.4.3")]
35-
[assembly: AssemblyFileVersion("1.4.3")]
34+
[assembly: AssemblyVersion("1.4.4")]
35+
[assembly: AssemblyFileVersion("1.4.4")]

CyberSource/Client/BaseClient.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public abstract class BaseClient
1919
/// <summary>
2020
/// Version of this client.
2121
/// </summary>
22-
public const string CLIENT_LIBRARY_VERSION = "1.4.3";
22+
public const string CLIENT_LIBRARY_VERSION = "1.4.4";
2323
public const string CYBS_SUBJECT_NAME = "CyberSource_SJC_US";
2424

2525
/// <summary>
@@ -196,6 +196,10 @@ int boolVal
196196
= AppSettings.GetSetting(
197197
merchantID, Configuration.KEY_FILENAME);
198198

199+
config.KeyAlias
200+
= AppSettings.GetSetting(
201+
merchantID, Configuration.KEY_ALIAS);
202+
199203
config.Password
200204
= AppSettings.GetSetting(
201205
merchantID, Configuration.PASSWORD);

CyberSource/Client/Configuration.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class Configuration
1919
internal const string SERVER_URL = "serverURL";
2020
internal const string CYBERSOURCE_URL = "cybersourceURL";
2121
internal const string KEY_FILENAME = "keyFilename";
22+
internal const string KEY_ALIAS = "keyAlias";
2223
internal const string PASSWORD = "password";
2324
internal const string LOG_FILENAME = "logFilename";
2425
internal const string LOG_MAXIMUM_SIZE = "logMaximumSize";
@@ -63,6 +64,7 @@ public class Configuration
6364
private string logDirectory = null;
6465
private string serverURL = null;
6566
private string keyFilename = null;
67+
private string keyAlias = null;
6668
private string password = null;
6769
private string logFilename = null;
6870
private int logMaximumSize = -1;
@@ -175,6 +177,18 @@ public string KeyFilename
175177
set { keyFilename = value; }
176178
}
177179

180+
public string KeyAlias
181+
{
182+
get
183+
{
184+
return (
185+
keyAlias != null
186+
? keyAlias
187+
: merchantID);
188+
}
189+
set { keyAlias = value; }
190+
}
191+
178192
/// <summary>
179193
/// Corresponds to [cybs.][merchantID].password
180194
///
@@ -325,6 +339,11 @@ public string LogString
325339
buf += NVP_SEPARATOR + KEY_FILENAME + NV_SEPARATOR + keyFilename;
326340
}
327341

342+
if (keyAlias != null)
343+
{
344+
buf += NVP_SEPARATOR + KEY_ALIAS + NV_SEPARATOR + keyAlias;
345+
}
346+
328347
if (timeout != -1)
329348
{
330349
buf += NVP_SEPARATOR + TIMEOUT + NV_SEPARATOR + timeout;

CyberSource/Client/NVPClient.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ public static Hashtable RunTransaction(
8080
X509Certificate2 cybsCert = null;
8181
DateTime dateFile = File.GetLastWriteTime(keyFilePath);
8282
if (config.CertificateCacheEnabled)
83-
{
84-
if (!merchantIdentities.ContainsKey(config.MerchantID) || IsMerchantCertExpired(logger, config.MerchantID, dateFile, merchantIdentities))
83+
{
84+
if (!merchantIdentities.ContainsKey(config.KeyAlias) || IsMerchantCertExpired(logger, config.KeyAlias, dateFile, merchantIdentities))
8585
{
8686
if (logger != null)
87-
{
88-
logger.LogInfo("Loading certificate for merchantID " + config.MerchantID);
87+
{
88+
logger.LogInfo("Loading certificate for " + config.KeyAlias);
8989
}
9090
X509Certificate2Collection collection = new X509Certificate2Collection();
9191
collection.Import(keyFilePath, config.EffectivePassword, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet);
@@ -94,8 +94,8 @@ public static Hashtable RunTransaction(
9494
X509Certificate2 newCybsCert = null;
9595

9696
foreach (X509Certificate2 cert1 in collection)
97-
{
98-
if (cert1.Subject.Contains(config.MerchantID))
97+
{
98+
if (cert1.Subject.Contains(config.KeyAlias))
9999
{
100100
newMerchantCert = cert1;
101101
}
@@ -111,12 +111,12 @@ public static Hashtable RunTransaction(
111111
CybsCert = newCybsCert,
112112
MerchantCert = newMerchantCert
113113
};
114-
merchantIdentities.AddOrUpdate(config.MerchantID, newCert, (x, y) => newCert);
114+
merchantIdentities.AddOrUpdate(config.KeyAlias, newCert, (x, y) => newCert);
115115
}
116-
merchantCert = GetOrFindValidMerchantCertFromStore(config.MerchantID, merchantIdentities);
116+
merchantCert = GetOrFindValidMerchantCertFromStore(config.KeyAlias, merchantIdentities);
117117
if (config.UseSignedAndEncrypted)
118118
{
119-
cybsCert = GetOrFindValidCybsCertFromStore(config.MerchantID, merchantIdentities);
119+
cybsCert = GetOrFindValidCybsCertFromStore(config.KeyAlias, merchantIdentities);
120120
}
121121
}
122122
else
@@ -127,7 +127,7 @@ public static Hashtable RunTransaction(
127127

128128
foreach (X509Certificate2 cert1 in collection)
129129
{
130-
if (cert1.Subject.Contains(config.MerchantID))
130+
if (cert1.Subject.Contains(config.KeyAlias))
131131
{
132132
merchantCert = cert1;
133133
break;
@@ -138,7 +138,6 @@ public static Hashtable RunTransaction(
138138
{
139139
foreach (X509Certificate2 cert2 in collection)
140140
{
141-
//Console.WriteLine(cert1.Subject);
142141
if (cert2.Subject.Contains(CYBERSOURCE_PUBLIC_KEY))
143142
{
144143
cybsCert = cert2;
@@ -281,7 +280,7 @@ private static void SetVersionInformation(Hashtable request)
281280
request["clientLibrary"] = ".NET NVP";
282281
request["clientLibraryVersion"] = CLIENT_LIBRARY_VERSION;
283282
request["clientEnvironment"] = mEnvironmentInfo;
284-
request["clientSecurityLibraryVersion"] =".Net 1.4.3";
283+
request["clientSecurityLibraryVersion"] =".Net 1.4.4";
285284
}
286285
}
287286
}

CyberSource/Client/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
//
3232
// You can specify all the values or you can default the Revision and Build Numbers
3333
// by using the '*' as shown below:
34-
[assembly: AssemblyVersion("1.4.3")]
35-
[assembly: AssemblyFileVersion("1.4.3")]
34+
[assembly: AssemblyVersion("1.4.4")]
35+
[assembly: AssemblyFileVersion("1.4.4")]

0 commit comments

Comments
 (0)