Skip to content

Commit 5e1cbc2

Browse files
committed
Fix for JWT cache issue
1 parent b9dd793 commit 5e1cbc2

File tree

4 files changed

+67
-12
lines changed

4 files changed

+67
-12
lines changed

Source/Configuration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class Configuration
1111

1212
public Dictionary<string, string> GetConfiguration()
1313
{
14-
_configurationDictionary.Add("authenticationType", "HTTP_SIGNATURE");
14+
_configurationDictionary.Add("authenticationType", "JWT");
1515
_configurationDictionary.Add("merchantID", "testrest");
1616
_configurationDictionary.Add("merchantsecretKey", "yBJxy6LjM2TmcPGu+GaJrHtkke25fPpUX+UY6/L/1tE=");
1717
_configurationDictionary.Add("merchantKeyId", "08c94330-f618-42a3-b09d-e1e43be5efda");
@@ -43,7 +43,7 @@ public Dictionary<string, string> GetConfiguration()
4343

4444
public Dictionary<string, string> GetAlternativeConfiguration()
4545
{
46-
_configurationDictionary.Add("authenticationType", "HTTP_SIGNATURE");
46+
_configurationDictionary.Add("authenticationType", "JWT");
4747
_configurationDictionary.Add("merchantID", "testrest_cpctv");
4848
_configurationDictionary.Add("merchantsecretKey", "JXm4dqKYIxWofM1TIbtYY9HuYo7Cg1HPHxn29f6waRo=");
4949
_configurationDictionary.Add("merchantKeyId", "e547c3d3-16e4-444c-9313-2a08784b906a");

Source/SampleCode.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.IO;
44
using System.Linq;
55
using System.Net;
6+
using System.Threading.Tasks;
67
using NLog;
78

89
namespace Cybersource_rest_samples_dotnet
@@ -64,6 +65,40 @@ public static void Main(string[] args)
6465
logger.Trace("PROGRAM EXECUTION ENDS");
6566
}
6667

68+
public static async Task MultiThreadedTogglingCredentials()
69+
{
70+
int taskCount = 10;
71+
72+
List<Task> tasks = new List<Task>();
73+
for (int i = 0; i < taskCount; i++)
74+
{
75+
string program = string.Empty;
76+
tasks.Add(new Task(() =>
77+
{
78+
for (int j = 0; j < taskCount; j++)
79+
{
80+
if (j % 2 == 0)
81+
{
82+
program = "SimpleAuthorizationInternet";
83+
}
84+
else
85+
{
86+
program = "IncrementalAuthorization";
87+
}
88+
89+
RunSample(program);
90+
}
91+
}));
92+
}
93+
94+
foreach (var task in tasks)
95+
{
96+
task.Start();
97+
}
98+
99+
await Task.WhenAll(tasks);
100+
}
101+
67102
public static void RunSample(string cmdLineArg = null)
68103
{
69104
try
@@ -87,6 +122,10 @@ public static void RunSample(string cmdLineArg = null)
87122

88123
Console.WriteLine("\n\nTotal number of Sample run : " + sampleCount);
89124
}
125+
else if (_sampleToRun.ToUpper().Contains("GAMWOR"))
126+
{
127+
MultiThreadedTogglingCredentials();
128+
}
90129
else
91130
{
92131
foreach (var path in SampleCodeClassesPathList)

cybersource-rest-samples-csharp.csproj

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,10 @@
3737
<SpecificVersion>False</SpecificVersion>
3838
<HintPath>Source\lib\net461\ApiSdk.dll</HintPath>
3939
</Reference>
40-
<Reference Include="AuthenticationSdk">
41-
<SpecificVersion>False</SpecificVersion>
42-
<HintPath>packages\CyberSource.Authentication.0.0.0.12\lib\AuthenticationSdk.dll</HintPath>
43-
</Reference>
44-
<Reference Include="cybersource-rest-client-dotnet">
45-
<SpecificVersion>False</SpecificVersion>
46-
<HintPath>packages\CyberSource.Rest.Client.0.0.1.19\lib\cybersource-rest-client-dotnet.dll</HintPath>
47-
</Reference>
4840
<Reference Include="jose-jwt">
4941
<HintPath>packages\jose-jwt.2.4.0\lib\net461\jose-jwt.dll</HintPath>
5042
</Reference>
43+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
5144
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
5245
<HintPath>packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
5346
<Private>True</Private>
@@ -56,6 +49,9 @@
5649
<HintPath>packages\NLog.4.5.10\lib\net45\NLog.dll</HintPath>
5750
<Private>True</Private>
5851
</Reference>
52+
<Reference Include="nunit.framework">
53+
<HintPath>packages\NUnit.3.10.1\lib\net45\nunit.framework.dll</HintPath>
54+
</Reference>
5955
<Reference Include="RestSharp, Version=106.12.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
6056
<SpecificVersion>False</SpecificVersion>
6157
<HintPath>packages\RestSharp.106.12.0\lib\net452\RestSharp.dll</HintPath>
@@ -170,7 +166,6 @@
170166
<Compile Include="Source\Samples\Payments\Payments\IncrementalAuthorization.cs" />
171167
<Compile Include="Source\Samples\Payments\Payments\LevelIIData.cs" />
172168
<Compile Include="Source\Samples\Payments\Payments\LevelIIIData.cs" />
173-
<Compile Include="Source\Samples\Payments\Payments\ParallelAuth.cs" />
174169
<Compile Include="Source\Samples\Payments\Payments\PartialAuthorization.cs" />
175170
<Compile Include="Source\Samples\Payments\Payments\PaymentNetworkTokenization.cs" />
176171
<Compile Include="Source\Samples\Payments\Payments\PaymentWithFlexToken.cs" />
@@ -328,7 +323,16 @@
328323
<Content Include="Source\Resource\jwsToken.txt" />
329324
<Content Include="Source\Resource\signatureHeaderValue.txt" />
330325
</ItemGroup>
331-
<ItemGroup />
326+
<ItemGroup>
327+
<ProjectReference Include="..\cybersource-rest-auth-dotnet\AuthenticationSdk\AuthenticationSdk\AuthenticationSdk.csproj">
328+
<Project>{910f28d1-8bd0-4359-aacb-b96c04cf68e8}</Project>
329+
<Name>AuthenticationSdk</Name>
330+
</ProjectReference>
331+
<ProjectReference Include="..\cybersource-rest-client-dotnet\cybersource-rest-client-dotnet.csproj">
332+
<Project>{8c08b6dc-4da0-4434-a6c5-709932dddde5}</Project>
333+
<Name>cybersource-rest-client-dotnet</Name>
334+
</ProjectReference>
335+
</ItemGroup>
332336
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
333337
<PropertyGroup>
334338
<PostBuildEvent>DEL /S /Q ..\..\..\obj\*</PostBuildEvent>

cybersource-rest-samples-csharp.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ VisualStudioVersion = 16.0.31624.102
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cybersource-rest-samples-csharp", "cybersource-rest-samples-csharp.csproj", "{97FF11A4-924D-4C87-A028-2AAF64655954}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AuthenticationSdk", "..\cybersource-rest-auth-dotnet\AuthenticationSdk\AuthenticationSdk\AuthenticationSdk.csproj", "{910F28D1-8BD0-4359-AACB-B96C04CF68E8}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cybersource-rest-client-dotnet", "..\cybersource-rest-client-dotnet\cybersource-rest-client-dotnet.csproj", "{8C08B6DC-4DA0-4434-A6C5-709932DDDDE5}"
11+
EndProject
812
Global
913
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1014
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +19,14 @@ Global
1519
{97FF11A4-924D-4C87-A028-2AAF64655954}.Debug|Any CPU.Build.0 = Debug|Any CPU
1620
{97FF11A4-924D-4C87-A028-2AAF64655954}.Release|Any CPU.ActiveCfg = Release|Any CPU
1721
{97FF11A4-924D-4C87-A028-2AAF64655954}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{910F28D1-8BD0-4359-AACB-B96C04CF68E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{910F28D1-8BD0-4359-AACB-B96C04CF68E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{910F28D1-8BD0-4359-AACB-B96C04CF68E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{910F28D1-8BD0-4359-AACB-B96C04CF68E8}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{8C08B6DC-4DA0-4434-A6C5-709932DDDDE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{8C08B6DC-4DA0-4434-A6C5-709932DDDDE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{8C08B6DC-4DA0-4434-A6C5-709932DDDDE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{8C08B6DC-4DA0-4434-A6C5-709932DDDDE5}.Release|Any CPU.Build.0 = Release|Any CPU
1830
EndGlobalSection
1931
GlobalSection(SolutionProperties) = preSolution
2032
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)